Repository: nf-core/tools

Issue:
Linting should fail if pipeline module file is edited
In https://github.com/ewels/nf-core-methylseq/pull/2 I have edited a module file that was pulled from nf-core/modules. I shouldn't be allowed to do this.

The linting warns me that something is amiss:

```
│ bismark/align                            │ modules/nf-cor… │ Local copy of   │
│                                          │                 │ module outdated │
```

But it should be checking the git sha in `modules.json` and recognising that it doesn't match what it expects. Then throwing a hard error.

Possible that the code for this is lurking in a PR that's waiting to be merged..


Discussion:

Resolving patch:
diff --git a/nf_core/modules/lint/module_changes.py b/nf_core/modules/lint/module_changes.py
--- a/nf_core/modules/lint/module_changes.py
+++ b/nf_core/modules/lint/module_changes.py
@@ -49,10 +49,10 @@ def module_changes(module_lint_object, module):
                 remote_copy = r.content.decode("utf-8")
 
                 if local_copy != remote_copy:
-                    module.warned.append(
+                    module.failed.append(
                         (
                             "check_local_copy",
-                            "Local copy of module outdated",
+                            "Local copy of module does not match remote",
                             f"{os.path.join(module.module_dir, f)}",
                         )
                     )


Test patch:
diff --git a/tests/modules/bump_versions.py b/tests/modules/bump_versions.py
--- a/tests/modules/bump_versions.py
+++ b/tests/modules/bump_versions.py
@@ -8,15 +8,15 @@
 
 def test_modules_bump_versions_single_module(self):
     """Test updating a single module"""
-    # Change the star/align version to an older version
-    main_nf_path = os.path.join(self.nfcore_modules, "modules", "star", "align", "main.nf")
+    # Change the bpipe/test version to an older version
+    main_nf_path = os.path.join(self.nfcore_modules, "modules", "bpipe", "test", "main.nf")
     with open(main_nf_path, "r") as fh:
         content = fh.read()
     new_content = re.sub(r"bioconda::star=\d.\d.\d\D?", r"bioconda::star=2.6.1d", content)
     with open(main_nf_path, "w") as fh:
         fh.write(new_content)
     version_bumper = nf_core.modules.ModuleVersionBumper(pipeline_dir=self.nfcore_modules)
-    version_bumper.bump_versions(module="star/align")
+    version_bumper.bump_versions(module="bpipe/test")
     assert len(version_bumper.failed) == 0
 
 
@@ -37,13 +37,13 @@ def test_modules_bump_versions_fail(self):
 
 def test_modules_bump_versions_fail_unknown_version(self):
     """Fail because of an unknown version"""
-    # Change the star/align version to an older version
-    main_nf_path = os.path.join(self.nfcore_modules, "modules", "star", "align", "main.nf")
+    # Change the bpipe/test version to an older version
+    main_nf_path = os.path.join(self.nfcore_modules, "modules", "bpipe", "test", "main.nf")
     with open(main_nf_path, "r") as fh:
         content = fh.read()
-    new_content = re.sub(r"bioconda::star=\d.\d.\d\D?", r"bioconda::star=xxx", content)
+    new_content = re.sub(r"bioconda::bpipe=\d.\d.\d\D?", r"bioconda::bpipe=xxx", content)
     with open(main_nf_path, "w") as fh:
         fh.write(new_content)
     version_bumper = nf_core.modules.ModuleVersionBumper(pipeline_dir=self.nfcore_modules)
-    version_bumper.bump_versions(module="star/align")
+    version_bumper.bump_versions(module="bpipe/test")
     assert "Conda package had unknown version" in version_bumper.failed[0][0]
diff --git a/tests/modules/create_test_yml.py b/tests/modules/create_test_yml.py
--- a/tests/modules/create_test_yml.py
+++ b/tests/modules/create_test_yml.py
@@ -42,18 +42,18 @@ def test_modules_create_test_yml_get_md5(self, test_file_dir):
 
 def test_modules_create_test_yml_entry_points(self):
     """Test extracting test entry points from a main.nf file"""
-    meta_builder = nf_core.modules.ModulesTestYmlBuilder("star/align", False, "./", False, True)
-    meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "star", "align", "main.nf")
+    meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", False, "./", False, True)
+    meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf")
     meta_builder.scrape_workflow_entry_points()
-    assert meta_builder.entry_points[0] == "test_star_align"
+    assert meta_builder.entry_points[0] == "test_bpipe_test"
 
 
 def test_modules_create_test_yml_check_inputs(self):
     """Test the check_inputs() function - raise UserWarning because test.yml exists"""
     cwd = os.getcwd()
     os.chdir(self.nfcore_modules)
-    meta_builder = nf_core.modules.ModulesTestYmlBuilder("star/align", False, "./", False, True)
-    meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "star", "align", "main.nf")
+    meta_builder = nf_core.modules.ModulesTestYmlBuilder("bpipe/test", False, "./", False, True)
+    meta_builder.module_test_main = os.path.join(self.nfcore_modules, "tests", "modules", "bpipe", "test", "main.nf")
     with pytest.raises(UserWarning) as excinfo:
         meta_builder.check_inputs()
     os.chdir(cwd)
diff --git a/tests/test_modules.py b/tests/test_modules.py
--- a/tests/test_modules.py
+++ b/tests/test_modules.py
@@ -22,7 +22,8 @@ def create_modules_repo_dummy(tmp_dir):
     with open(os.path.join(root_dir, "README.md"), "w") as fh:
         fh.writelines(["# ![nf-core/modules](docs/images/nfcore-modules_logo.png)", "\n"])
 
-    module_create = nf_core.modules.ModuleCreate(root_dir, "star/align", "@author", "process_medium", False, False)
+    # bpipe is a valid package on bioconda that is very unlikely to ever be added to nf-core/modules
+    module_create = nf_core.modules.ModuleCreate(root_dir, "bpipe/test", "@author", "process_medium", False, False)
     module_create.create()
 
     return root_dir