Skip to content

Commit

Permalink
Merge pull request #2213 from anoronh4/feature/fail_enable_conda
Browse files Browse the repository at this point in the history
Lint check for params.enable_conda
  • Loading branch information
anoronh4 authored Mar 29, 2023
2 parents 14951aa + ff84a09 commit bb533fc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

### Linting

- Update modules lint test to fail if enable_conda is found ([#2213](https://github.com/nf-core/tools/pull/2213))
- Read module lint configuration from `.nf-core.yml`, not `.nf-core-lint.yml` ([#2221](https://github.com/nf-core/tools/pull/2221))
- `nf-core schema lint` now defaults to linting `nextflow_schema.json` if no filename is provided ([#2225](https://github.com/nf-core/tools/pull/2225))

Expand Down
4 changes: 3 additions & 1 deletion nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,9 @@ def build(dir, no_prompts, web_only, url):

# nf-core schema lint
@schema.command()
@click.argument("schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="<pipeline schema>")
@click.argument(
"schema_path", type=click.Path(exists=True), default="nextflow_schema.json", metavar="<pipeline schema>"
)
def lint(schema_path):
"""
Check that a given pipeline schema is valid.
Expand Down
27 changes: 22 additions & 5 deletions nf_core/modules/lint/main_nf.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,26 @@ def check_process_section(self, lines, fix_version, progress_bar):
self.warned.append(("process_standard_label", "Process label unspecified", self.main_nf))
for i, l in enumerate(lines):
url = None
if _container_type(l) == "bioconda":
bioconda_packages = [b for b in l.split() if "bioconda::" in b]
l = l.strip(" '\"")
if _container_type(l) == "conda":
bioconda_packages = [b for b in l.split() if "bioconda::" in b]
match = re.search(r"params\.enable_conda", l)
if match is None:
self.passed.append(
(
"deprecated_enable_conda",
f"Deprecated parameter 'params.enable_conda' correctly not found in the conda definition",
self.main_nf,
)
)
else:
self.failed.append(
(
"deprecated_enable_conda",
f"Found deprecated parameter 'params.enable_conda' in the conda definition",
self.main_nf,
)
)
if _container_type(l) == "singularity":
# e.g. "https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' :" -> v1.2.0_cv1
# e.g. "https://depot.galaxyproject.org/singularity/fastqc:0.11.9--0' :" -> 0.11.9--0
Expand Down Expand Up @@ -471,7 +488,7 @@ def _fix_module_version(self, current_version, latest_version, singularity_tag,
for line in lines:
l = line.strip(" '\"")
build_type = _container_type(l)
if build_type == "bioconda":
if build_type == "conda":
new_lines.append(re.sub(rf"{current_version}", f"{latest_version}", line))
elif build_type in ("singularity", "docker"):
# Check that the new url is valid
Expand Down Expand Up @@ -516,8 +533,8 @@ def _get_build(response):

def _container_type(line):
"""Returns the container type of a build."""
if re.search("bioconda::", line):
return "bioconda"
if line.startswith("conda"):
return "conda"
if line.startswith("https://containers") or line.startswith("https://depot"):
# Look for a http download URL.
# Thanks Stack Overflow for the regex: https://stackoverflow.com/a/3809435/713980
Expand Down
6 changes: 3 additions & 3 deletions tests/modules/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def test_modules_lint_gitlab_modules(self):
self.mods_install_gitlab.install("multiqc")
module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL)
module_lint.lint(print_results=False, all_modules=True)
assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 2
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

Expand All @@ -77,7 +77,7 @@ def test_modules_lint_multiple_remotes(self):
self.mods_install_gitlab.install("multiqc")
module_lint = nf_core.modules.ModuleLint(dir=self.pipeline_dir, remote_url=GITLAB_URL)
module_lint.lint(print_results=False, all_modules=True)
assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 1
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

Expand All @@ -103,6 +103,6 @@ def test_modules_lint_patched_modules(self):
all_modules=True,
)

assert len(module_lint.failed) == 0
assert len(module_lint.failed) == 1
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

0 comments on commit bb533fc

Please sign in to comment.