From 20b83e824cb205536de2a94c22bb0236059e7dc4 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 6 May 2024 16:17:31 +0200 Subject: [PATCH 1/4] set correct sha before running component lint tests --- nf_core/modules/lint/__init__.py | 4 ++++ nf_core/subworkflows/lint/__init__.py | 4 ++++ nf_core/synced_repo.py | 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index b2816dab6a..94c6eb3b60 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -213,6 +213,10 @@ def lint_module(self, mod, progress_bar, registry, local=False, fix_version=Fals # Otherwise run all the lint tests else: + # Set correct sha + version = self.modules_json.get_module_version(mod.component_name, mod.repo_url, mod.org) + mod.git_sha = version + for test_name in self.lint_tests: if test_name == "main_nf": getattr(self, test_name)(mod, fix_version, self.registry, progress_bar) diff --git a/nf_core/subworkflows/lint/__init__.py b/nf_core/subworkflows/lint/__init__.py index 96d2e0ab92..df02e3376b 100644 --- a/nf_core/subworkflows/lint/__init__.py +++ b/nf_core/subworkflows/lint/__init__.py @@ -207,6 +207,10 @@ def lint_subworkflow(self, swf, progress_bar, registry, local=False): # Otherwise run all the lint tests else: + # Set correct sha + version = self.modules_json.get_subworkflow_version(swf.component_name, swf.repo_url, swf.org) + swf.git_sha = version + for test_name in self.lint_tests: getattr(self, test_name)(swf) diff --git a/nf_core/synced_repo.py b/nf_core/synced_repo.py index 5c31e96911..28e017840a 100644 --- a/nf_core/synced_repo.py +++ b/nf_core/synced_repo.py @@ -319,9 +319,9 @@ def component_files_identical(self, component_name, base_path, commit, component component_dir = self.get_component_dir(component_name, component_type) for file in component_files: try: - files_identical[file] = filecmp.cmp(os.path.join(component_dir, file), os.path.join(base_path, file)) + files_identical[file] = filecmp.cmp(Path(component_dir, file), Path(base_path, file)) except FileNotFoundError: - log.debug(f"Could not open file: {os.path.join(component_dir, file)}") + log.debug(f"Could not open file: {Path(component_dir, file)}") continue self.checkout_branch() return files_identical From 83d1f1de79ea95700dbb47661484fed8e568bbba Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Mon, 6 May 2024 14:22:14 +0000 Subject: [PATCH 2/4] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88ce77a3b8..69cda3587a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ - Only match assignments of params in `main.nf` and not references like `params.aligner == ` ([#2833](https://github.com/nf-core/tools/pull/2833)) - Include test for presence of versions in snapshot ([#2888](https://github.com/nf-core/tools/pull/2888)) +- Components: set correct sha before running component lint tests ([#2952](https://github.com/nf-core/tools/pull/2952)) ### Download From f69fe301b29f54237157bb6c68365d99e7d7c96e Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 6 May 2024 16:49:59 +0200 Subject: [PATCH 3/4] only get component version when linting a pipeline repo --- nf_core/modules/lint/__init__.py | 7 ++++--- nf_core/subworkflows/lint/__init__.py | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index 94c6eb3b60..02ea700ea4 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -213,9 +213,10 @@ def lint_module(self, mod, progress_bar, registry, local=False, fix_version=Fals # Otherwise run all the lint tests else: - # Set correct sha - version = self.modules_json.get_module_version(mod.component_name, mod.repo_url, mod.org) - mod.git_sha = version + if self.repo_type == "pipeline": + # Set correct sha + version = self.modules_json.get_module_version(mod.component_name, mod.repo_url, mod.org) + mod.git_sha = version for test_name in self.lint_tests: if test_name == "main_nf": diff --git a/nf_core/subworkflows/lint/__init__.py b/nf_core/subworkflows/lint/__init__.py index df02e3376b..b7627cb3f7 100644 --- a/nf_core/subworkflows/lint/__init__.py +++ b/nf_core/subworkflows/lint/__init__.py @@ -207,9 +207,10 @@ def lint_subworkflow(self, swf, progress_bar, registry, local=False): # Otherwise run all the lint tests else: - # Set correct sha - version = self.modules_json.get_subworkflow_version(swf.component_name, swf.repo_url, swf.org) - swf.git_sha = version + if self.repo_type == "pipeline": + # Set correct sha + version = self.modules_json.get_subworkflow_version(swf.component_name, swf.repo_url, swf.org) + swf.git_sha = version for test_name in self.lint_tests: getattr(self, test_name)(swf) From 65f7647503ef875649ae3cc02ad4c4f554758c47 Mon Sep 17 00:00:00 2001 From: mirpedrol Date: Mon, 6 May 2024 17:19:22 +0200 Subject: [PATCH 4/4] fix pytest by checking if modules_json exists --- nf_core/modules/lint/__init__.py | 2 +- nf_core/subworkflows/lint/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nf_core/modules/lint/__init__.py b/nf_core/modules/lint/__init__.py index 02ea700ea4..f96683089c 100644 --- a/nf_core/modules/lint/__init__.py +++ b/nf_core/modules/lint/__init__.py @@ -213,7 +213,7 @@ def lint_module(self, mod, progress_bar, registry, local=False, fix_version=Fals # Otherwise run all the lint tests else: - if self.repo_type == "pipeline": + if self.repo_type == "pipeline" and self.modules_json: # Set correct sha version = self.modules_json.get_module_version(mod.component_name, mod.repo_url, mod.org) mod.git_sha = version diff --git a/nf_core/subworkflows/lint/__init__.py b/nf_core/subworkflows/lint/__init__.py index b7627cb3f7..cc79ed8639 100644 --- a/nf_core/subworkflows/lint/__init__.py +++ b/nf_core/subworkflows/lint/__init__.py @@ -207,7 +207,7 @@ def lint_subworkflow(self, swf, progress_bar, registry, local=False): # Otherwise run all the lint tests else: - if self.repo_type == "pipeline": + if self.repo_type == "pipeline" and self.modules_json: # Set correct sha version = self.modules_json.get_subworkflow_version(swf.component_name, swf.repo_url, swf.org) swf.git_sha = version