Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint validation #853

Merged
merged 3 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nf_core/lint/files_exist.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def files_exist(self):
'docs/usage.md',
'.github/workflows/branch.yml',
'.github/workflows/ci.yml',
'.github/workflows/linting.yml'
'.github/workflows/linting.yml',
'lib/NfcoreSchema.groovy',
'lib/nfcore_external_java_deps.jar'

Files that *should* be present::

Expand Down Expand Up @@ -71,6 +73,8 @@ def files_exist(self):
[os.path.join(".github", "workflows", "branch.yml")],
[os.path.join(".github", "workflows", "ci.yml")],
[os.path.join(".github", "workflows", "linting.yml")],
[os.path.join("lib", "NfcoreSchema.groovy")],
[os.path.join("lib", "nfcore_external_java_deps.jar")],
]
files_warn = [
["main.nf"],
Expand Down
22 changes: 13 additions & 9 deletions nf_core/lint/files_unchanged.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def files_unchanged(self):
'bin/markdown_to_html.py',
'conf/charliecloud.config',
'docs/README.md',
'docs/images/nf-core-PIPELINE_logo.png'
'docs/images/nf-core-PIPELINE_logo.png',
'lib/NfcoreSchema.groovy',
'lib/nfcore_external_java_deps.jar'

Files that can have additional content but must include the template contents::

Expand Down Expand Up @@ -97,6 +99,8 @@ def files_unchanged(self):
[os.path.join("conf", "charliecloud.config")],
[os.path.join("docs", "README.md")],
[os.path.join("docs", "images", "nf-core-{}_logo.png".format(short_name))],
[os.path.join("lib", "NfcoreSchema.groovy")],
[os.path.join("lib", "nfcore_external_java_deps.jar")],
]
files_partial = [
[".gitignore", "foo"],
Expand Down Expand Up @@ -144,15 +148,15 @@ def _tf(file_path):
for f in files:
try:
if filecmp.cmp(_pf(f), _tf(f), shallow=True):
passed.append(f"'{f}' matches the template")
passed.append(f"`{f}` matches the template")
else:
if "files_unchanged" in self.fix:
# Try to fix the problem by overwriting the pipeline file
shutil.copy(_tf(f), _pf(f))
passed.append(f"'{f}' matches the template")
fixed.append(f"'{f}' overwritten with template file")
passed.append(f"`{f}` matches the template")
fixed.append(f"`{f}` overwritten with template file")
else:
failed.append(f"'{f}' does not match the template")
failed.append(f"`{f}` does not match the template")
could_fix = True
except FileNotFoundError:
pass
Expand All @@ -178,18 +182,18 @@ def _tf(file_path):
with open(_tf(f), "r") as fh:
template_file = fh.read()
if template_file in pipeline_file:
passed.append(f"'{f}' matches the template")
passed.append(f"`{f}` matches the template")
else:
if "files_unchanged" in self.fix:
# Try to fix the problem by overwriting the pipeline file
with open(_tf(f), "r") as fh:
template_file = fh.read()
with open(_pf(f), "w") as fh:
fh.write(template_file)
passed.append(f"'{f}' matches the template")
fixed.append(f"'{f}' overwritten with template file")
passed.append(f"`{f}` matches the template")
fixed.append(f"`{f}` overwritten with template file")
else:
failed.append(f"'{f}' does not match the template")
failed.append(f"`{f}` does not match the template")
could_fix = True
except FileNotFoundError:
pass
Expand Down