Skip to content

Commit

Permalink
Merge pull request #853 from ewels/lint-validation
Browse files Browse the repository at this point in the history
Lint validation
  • Loading branch information
ewels authored Feb 16, 2021
2 parents 3f44a18 + daca4be commit 95b9d6f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
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

0 comments on commit 95b9d6f

Please sign in to comment.