From 9825d89ebb7b0616d100b70f09bf2962d055f3f3 Mon Sep 17 00:00:00 2001 From: jvfe Date: Fri, 21 Jun 2024 15:42:18 -0300 Subject: [PATCH 1/5] tests: Add test case for cross-organization subwf Strangely it is passing at the moment, it seems the install command returns a passing exit code regardless of installing all modules. - Addresses sanger-tol/nf-core-tools#2 --- tests/subworkflows/install.py | 9 +++++++++ tests/test_subworkflows.py | 1 + tests/utils.py | 1 + 3 files changed, 11 insertions(+) diff --git a/tests/subworkflows/install.py b/tests/subworkflows/install.py index dfe71686fb..477818b261 100644 --- a/tests/subworkflows/install.py +++ b/tests/subworkflows/install.py @@ -6,7 +6,9 @@ from nf_core.subworkflows.install import SubworkflowInstall from ..utils import ( + CROSS_ORGANIZATION_URL, GITLAB_BRANCH_TEST_BRANCH, + GITLAB_DEFAULT_BRANCH, GITLAB_REPO, GITLAB_SUBWORKFLOWS_BRANCH, GITLAB_SUBWORKFLOWS_ORG_PATH_BRANCH, @@ -79,6 +81,13 @@ def test_subworkflows_install_different_branch_fail(self): assert install_obj.install("bam_stats_samtools") is False +def test_subworkflows_install_across_organizations(self): + """Test installing a subworkflow with modules from different organizations""" + install_obj = SubworkflowInstall(self.pipeline_dir, remote_url=CROSS_ORGANIZATION_URL, branch=GITLAB_DEFAULT_BRANCH) + # The hic_bwamem2 subworkflow contains modules from different organizations + assert install_obj.install("hic_bwamem2") is True + + def test_subworkflows_install_tracking(self): """Test installing a subworkflow and finding the correct entries in installed_by section of modules.json""" self.subworkflow_install.install("bam_sort_stats_samtools") diff --git a/tests/test_subworkflows.py b/tests/test_subworkflows.py index 0a9224002a..eeee62bda1 100644 --- a/tests/test_subworkflows.py +++ b/tests/test_subworkflows.py @@ -120,6 +120,7 @@ def tearDown(self): ) from .subworkflows.install import ( # type: ignore[misc] test_subworkflow_install_nopipeline, + test_subworkflows_install_across_organizations, test_subworkflows_install_alternate_remote, test_subworkflows_install_bam_sort_stats_samtools, test_subworkflows_install_bam_sort_stats_samtools_twice, diff --git a/tests/utils.py b/tests/utils.py index 89c1328818..34c899ccf3 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -15,6 +15,7 @@ OLD_TRIMGALORE_SHA = "9b7a3bdefeaad5d42324aa7dd50f87bea1b04386" OLD_TRIMGALORE_BRANCH = "mimic-old-trimgalore" GITLAB_URL = "https://gitlab.com/nf-core/modules-test.git" +CROSS_ORGANIZATION_URL = "https://github.com/jvfe/test-subworkflow-remote.git" GITLAB_REPO = "nf-core-test" GITLAB_DEFAULT_BRANCH = "main" GITLAB_SUBWORKFLOWS_BRANCH = "subworkflows" From 568363a4b025d6bdfbce031a12e9898df3ca0137 Mon Sep 17 00:00:00 2001 From: jvfe Date: Fri, 28 Jun 2024 15:33:56 -0300 Subject: [PATCH 2/5] tests: Check module on module list instead --- tests/subworkflows/install.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/subworkflows/install.py b/tests/subworkflows/install.py index 477818b261..44856ad033 100644 --- a/tests/subworkflows/install.py +++ b/tests/subworkflows/install.py @@ -85,7 +85,13 @@ def test_subworkflows_install_across_organizations(self): """Test installing a subworkflow with modules from different organizations""" install_obj = SubworkflowInstall(self.pipeline_dir, remote_url=CROSS_ORGANIZATION_URL, branch=GITLAB_DEFAULT_BRANCH) # The hic_bwamem2 subworkflow contains modules from different organizations - assert install_obj.install("hic_bwamem2") is True + install_obj.install("hic_bwamem2") + # Verify that the installed_by entry was added correctly + modules_json = ModulesJson(self.pipeline_dir) + mod_json = modules_json.get_modules_json() + assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["samtools/merge"]["installed_by"] == [ + "hic_bwamem2" + ] def test_subworkflows_install_tracking(self): From 534da92b483587a4287ab9fa75331c57e06c87de Mon Sep 17 00:00:00 2001 From: jvfe Date: Mon, 1 Jul 2024 08:41:07 -0300 Subject: [PATCH 3/5] chore: Dummy commit to test action --- tests/subworkflows/install.py | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/subworkflows/install.py b/tests/subworkflows/install.py index 44856ad033..b654921674 100644 --- a/tests/subworkflows/install.py +++ b/tests/subworkflows/install.py @@ -89,6 +89,7 @@ def test_subworkflows_install_across_organizations(self): # Verify that the installed_by entry was added correctly modules_json = ModulesJson(self.pipeline_dir) mod_json = modules_json.get_modules_json() + # Dummy comment assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["samtools/merge"]["installed_by"] == [ "hic_bwamem2" ] From 286ab86263be1cb2d31c0093c58554f7c05c1e8f Mon Sep 17 00:00:00 2001 From: jvfe Date: Mon, 1 Jul 2024 08:45:13 -0300 Subject: [PATCH 4/5] Revert "chore: Dummy commit to test action" This reverts commit 534da92b483587a4287ab9fa75331c57e06c87de. --- tests/subworkflows/install.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/subworkflows/install.py b/tests/subworkflows/install.py index b654921674..44856ad033 100644 --- a/tests/subworkflows/install.py +++ b/tests/subworkflows/install.py @@ -89,7 +89,6 @@ def test_subworkflows_install_across_organizations(self): # Verify that the installed_by entry was added correctly modules_json = ModulesJson(self.pipeline_dir) mod_json = modules_json.get_modules_json() - # Dummy comment assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["samtools/merge"]["installed_by"] == [ "hic_bwamem2" ] From 423517ef1a268da1186f707d84d82de466d50df6 Mon Sep 17 00:00:00 2001 From: jvfe Date: Tue, 2 Jul 2024 18:46:48 -0300 Subject: [PATCH 5/5] tests: Change installed subworkflow --- tests/subworkflows/install.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/subworkflows/install.py b/tests/subworkflows/install.py index 44856ad033..f872b1f7fb 100644 --- a/tests/subworkflows/install.py +++ b/tests/subworkflows/install.py @@ -85,12 +85,12 @@ def test_subworkflows_install_across_organizations(self): """Test installing a subworkflow with modules from different organizations""" install_obj = SubworkflowInstall(self.pipeline_dir, remote_url=CROSS_ORGANIZATION_URL, branch=GITLAB_DEFAULT_BRANCH) # The hic_bwamem2 subworkflow contains modules from different organizations - install_obj.install("hic_bwamem2") + install_obj.install("get_genome_annotation") # Verify that the installed_by entry was added correctly modules_json = ModulesJson(self.pipeline_dir) mod_json = modules_json.get_modules_json() - assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["samtools/merge"]["installed_by"] == [ - "hic_bwamem2" + assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["prokka"]["installed_by"] == [ + "get_genome_annotation" ]