From 3cf57a85d3b0104679ecda719ea8227a7883045c Mon Sep 17 00:00:00 2001 From: itrujnara Date: Fri, 10 May 2024 15:52:42 +0200 Subject: [PATCH 1/3] Added nf-schema as condition to exclude Java deps file --- nf_core/lint/files_exist.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/nf_core/lint/files_exist.py b/nf_core/lint/files_exist.py index d801caf704..0c87100622 100644 --- a/nf_core/lint/files_exist.py +++ b/nf_core/lint/files_exist.py @@ -200,8 +200,8 @@ def files_exist(self) -> Dict[str, Union[List[str], bool]]: Path("Singularity"), ] files_warn_ifexists = [Path(".travis.yml")] - files_fail_ifinconfig: List[Tuple[Path, Dict[str, str]]] = [ - (Path("lib", "nfcore_external_java_deps.jar"), {"plugins": "nf-validation"}), + files_fail_ifinconfig: List[Tuple[Path, List[Dict[str, str]]]] = [ + (Path("lib", "nfcore_external_java_deps.jar"), [{"plugins": "nf-validation"}, {"plugins": "nf-schema"}]), ] # Remove files that should be ignored according to the linting config @@ -246,10 +246,11 @@ def pf(file_path: Union[str, Path]) -> Path: if str(file_cond[0]) in ignore_files: continue in_config = False - config_key, config_value = list(file_cond[1].items())[0] - if config_key in self.nf_config and config_value in self.nf_config[config_key]: - log.debug(f"Found {config_key} in nextflow.config with value {config_value}") - in_config = True + for condition in file_cond[1]: + config_key, config_value = list(condition.items())[0] + if config_key in self.nf_config and config_value in self.nf_config[config_key]: + log.debug(f"Found {config_key} in nextflow.config with value {config_value}") + in_config = True if pf(file_cond[0]).is_file() and in_config: failed.append(f"File must be removed: {self._wrap_quotes(file_cond[0])}") elif pf(file_cond[0]).is_file() and not in_config: From 0bdd4dd99bd0f0da6375c57c0fafa27e1d03bfc6 Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 10 May 2024 16:47:07 +0200 Subject: [PATCH 2/3] add explicit test for nf-schema --- tests/lint/files_exist.py | 17 +++++++++++++++++ tests/test_lint.py | 1 + 2 files changed, 18 insertions(+) diff --git a/tests/lint/files_exist.py b/tests/lint/files_exist.py index 5081522899..08da7f14db 100644 --- a/tests/lint/files_exist.py +++ b/tests/lint/files_exist.py @@ -79,3 +79,20 @@ def test_files_exist_fail_conditional(self): results = lint_obj.files_exist() assert results["failed"] == ["File must be removed: `lib/nfcore_external_java_deps.jar`"] assert results["ignored"] == [] + + +def test_files_exist_pass_conditional_nfschema(self): + new_pipeline = self._make_pipeline_copy() + # replace nf-validation with nf-schema in nextflow.config + with open(Path(new_pipeline, "nextflow.config")) as f: + config = f.read() + config = config.replace("nf-validation", "nf-schema") + with open(Path(new_pipeline, "nextflow.config"), "w") as f: + f.write(config) + + lint_obj = nf_core.lint.PipelineLint(new_pipeline) + lint_obj._load() + lint_obj.nf_config["manifest.schema"] = "nf-core" + results = lint_obj.files_exist() + assert results["failed"] == [] + assert results["ignored"] == [] diff --git a/tests/test_lint.py b/tests/test_lint.py index b72a6bfdfa..15c1550e72 100644 --- a/tests/test_lint.py +++ b/tests/test_lint.py @@ -212,6 +212,7 @@ def test_sphinx_md_files(self): test_files_exist_missing_main, test_files_exist_pass, test_files_exist_pass_conditional, + test_files_exist_pass_conditional_nfschema, ) from .lint.files_unchanged import ( # type: ignore[misc] test_files_unchanged_fail, From c3e2844b77fddd43c812fa3ea1c734f1b72cc0ae Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 10 May 2024 14:49:13 +0000 Subject: [PATCH 3/3] [automated] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f46a265cc..6dd09482b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ ### Linting +- Fix linting fail on nfcore_external_java_deps if nf_schema is used ([#2976](https://github.com/nf-core/tools/pull/2976)) + ### Download ### Components