From 3063f161c8948e79f185acf921f4766950b3a87f Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 10:02:25 +0100 Subject: [PATCH 01/12] meta-tests: Add initial ideas from brainstorm --- tests/main.nf | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/main.nf diff --git a/tests/main.nf b/tests/main.nf new file mode 100644 index 00000000000..ea3e3a11325 --- /dev/null +++ b/tests/main.nf @@ -0,0 +1,31 @@ +params.module_nf_file = "../modules/nf-core/samtools/view/main.nf" +params.module_test_file = "../modules/nf-core/samtools/view/tests/main.nf.test" +params.repo = "../../modules/" + +workflow { + NFTEST_MODULE ( + params.module_nf_file, + params.module_test_file, + [], // TODO + false + ) +} + +process NFTEST_MODULE { + input: + path module_file + path test_file + path full_repo // optional for subworkflow + val update_snapshot + + output: + path "*.snap", emit: snapshot + + script: + // TODO if update_snapshot then --updateSnapshot + """ + # TODO cd $full_repo + nf-test test ${test_file} ${update_snapshot} --profile docker + """ + +} From 948a9910f387e4ce4fd8d104ec0c16ac67e9cfa7 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 11:28:54 +0100 Subject: [PATCH 02/12] meta-tests: Use file --- tests/main.nf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/main.nf b/tests/main.nf index ea3e3a11325..b7f7b7666e3 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -4,8 +4,8 @@ params.repo = "../../modules/" workflow { NFTEST_MODULE ( - params.module_nf_file, - params.module_test_file, + file(params.module_nf_file), + file(params.module_test_file), [], // TODO false ) From 216508d01da3bbafe5dc92d9bd2dbf0f955338cb Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 11:33:33 +0100 Subject: [PATCH 03/12] meta-test: MVP PoC --- tests/main.nf | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/main.nf b/tests/main.nf index b7f7b7666e3..fa0e9b3538b 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -1,5 +1,5 @@ -params.module_nf_file = "../modules/nf-core/samtools/view/main.nf" -params.module_test_file = "../modules/nf-core/samtools/view/tests/main.nf.test" +params.module_nf_file = "./modules/nf-core/samtools/view/main.nf" +params.module_test_file = "./modules/nf-core/samtools/view/tests" params.repo = "../../modules/" workflow { @@ -25,7 +25,7 @@ process NFTEST_MODULE { // TODO if update_snapshot then --updateSnapshot """ # TODO cd $full_repo - nf-test test ${test_file} ${update_snapshot} --profile docker + nf-test test tests/*.nf.test --profile docker """ } From 35de4c8546e62db6b6f1e3225068783a68186d01 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 11:40:27 +0100 Subject: [PATCH 04/12] meta-test: Make snapsnot optional --- tests/main.nf | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/main.nf b/tests/main.nf index fa0e9b3538b..d9b7960f9a8 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -19,7 +19,7 @@ process NFTEST_MODULE { val update_snapshot output: - path "*.snap", emit: snapshot + path "*.snap", emit: snapshot, optional: true script: // TODO if update_snapshot then --updateSnapshot @@ -27,5 +27,4 @@ process NFTEST_MODULE { # TODO cd $full_repo nf-test test tests/*.nf.test --profile docker """ - } From 8e535d6c7eee716723803d5529be252aab283112 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 11:52:22 +0100 Subject: [PATCH 05/12] meta-test: Add snapshot update --- tests/main.nf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/main.nf b/tests/main.nf index d9b7960f9a8..91ef6e4729f 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -22,9 +22,11 @@ process NFTEST_MODULE { path "*.snap", emit: snapshot, optional: true script: - // TODO if update_snapshot then --updateSnapshot + def snapshot = update_snapshot ? '--update-snapshot': '' """ # TODO cd $full_repo - nf-test test tests/*.nf.test --profile docker + nf-test test tests/*.nf.test \\ + --profile docker \\ + $snapshot """ } From e32bd9e7f4a5f60c190b39c06ecf04141744c417 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 11:54:52 +0100 Subject: [PATCH 06/12] meta-tests: I need more Nextflow --- tests/main.nf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/main.nf b/tests/main.nf index 91ef6e4729f..ff7c2589c8a 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -27,6 +27,8 @@ process NFTEST_MODULE { # TODO cd $full_repo nf-test test tests/*.nf.test \\ --profile docker \\ - $snapshot + $snapshot \\ + --silent \\ + --verbose """ } From 6d3ee7f517c355605a0508d9176d6fde03febb2d Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 12:00:30 +0100 Subject: [PATCH 07/12] meta-tests: Just pass a directory with a module --- tests/main.nf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/main.nf b/tests/main.nf index ff7c2589c8a..288fcba7c9e 100644 --- a/tests/main.nf +++ b/tests/main.nf @@ -1,11 +1,10 @@ -params.module_nf_file = "./modules/nf-core/samtools/view/main.nf" -params.module_test_file = "./modules/nf-core/samtools/view/tests" +params.module_dir = "./modules/nf-core/samtools/view" params.repo = "../../modules/" workflow { NFTEST_MODULE ( - file(params.module_nf_file), - file(params.module_test_file), + file(params.module_dir + "/main.nf"), + file(params.module_dir + "/tests"), [], // TODO false ) From c4d4f0d961c7bf239c66b8c9c71585fd5769b721 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 12:04:29 +0100 Subject: [PATCH 08/12] docs: Add a blurb --- tests/Meta-tests.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 tests/Meta-tests.md diff --git a/tests/Meta-tests.md b/tests/Meta-tests.md new file mode 100644 index 00000000000..feda2003746 --- /dev/null +++ b/tests/Meta-tests.md @@ -0,0 +1,11 @@ +# Meta Tests + +Minimal Proof of Concept to run nf-test on Tower. + +Mainly for testing modules with full sized data(the stuff that really ends up breaking it) for optimization. + +So we thought what if we wrap nf-test in a Nextflow process, and then let it test the module? + +Then we could spin all of the tests up, and even get snapshots out of full test-data + +It's a Nextflow workflow that wraps nf-test, which itself wraps Nextflow. From 1930f9fe351efa8be80c0b86d0fba7af20fe077c Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 13:22:52 +0100 Subject: [PATCH 09/12] refactor: Move everything to a meta directory --- tests/{Meta-tests.md => meta/README.md} | 0 tests/{ => meta}/main.nf | 12 +++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) rename tests/{Meta-tests.md => meta/README.md} (100%) rename tests/{ => meta}/main.nf (65%) diff --git a/tests/Meta-tests.md b/tests/meta/README.md similarity index 100% rename from tests/Meta-tests.md rename to tests/meta/README.md diff --git a/tests/main.nf b/tests/meta/main.nf similarity index 65% rename from tests/main.nf rename to tests/meta/main.nf index 288fcba7c9e..0e55503a70c 100644 --- a/tests/main.nf +++ b/tests/meta/main.nf @@ -1,10 +1,16 @@ +// TODO What if we took nf-test list? params.module_dir = "./modules/nf-core/samtools/view" -params.repo = "../../modules/" +params.repo = "../modules/" +params.nftest_config = "nf-test.config" +params.nextflow_config = "./config/nextflow.config" + workflow { NFTEST_MODULE ( file(params.module_dir + "/main.nf"), file(params.module_dir + "/tests"), + file(params.nftest_config), + file(params.nextflow_config), [], // TODO false ) @@ -14,6 +20,8 @@ process NFTEST_MODULE { input: path module_file path test_file + path nftest_config + path nextflow_config path full_repo // optional for subworkflow val update_snapshot @@ -23,6 +31,8 @@ process NFTEST_MODULE { script: def snapshot = update_snapshot ? '--update-snapshot': '' """ + mkdir tests/config/ + mv $nextflow_config tests/config/nf-test.config # TODO cd $full_repo nf-test test tests/*.nf.test \\ --profile docker \\ From 2896841a1714186692ebe51fe15b73c793258c13 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Fri, 9 Feb 2024 13:31:35 +0100 Subject: [PATCH 10/12] refactor: Add in configs --- tests/meta/main.nf | 9 ++++--- tests/meta/nf-test.config | 13 ++++++++++ tests/meta/nf.config | 50 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 tests/meta/nf-test.config create mode 100644 tests/meta/nf.config diff --git a/tests/meta/main.nf b/tests/meta/main.nf index 0e55503a70c..52701fe0d0a 100644 --- a/tests/meta/main.nf +++ b/tests/meta/main.nf @@ -1,8 +1,8 @@ // TODO What if we took nf-test list? params.module_dir = "./modules/nf-core/samtools/view" params.repo = "../modules/" -params.nftest_config = "nf-test.config" -params.nextflow_config = "./config/nextflow.config" +params.nftest_config = "./tests/meta/nf-test.config" +params.nextflow_config = "./tests/meta/nf.config" workflow { @@ -31,13 +31,12 @@ process NFTEST_MODULE { script: def snapshot = update_snapshot ? '--update-snapshot': '' """ - mkdir tests/config/ - mv $nextflow_config tests/config/nf-test.config # TODO cd $full_repo nf-test test tests/*.nf.test \\ --profile docker \\ $snapshot \\ --silent \\ - --verbose + --verbose \\ + -c $nftest_config """ } diff --git a/tests/meta/nf-test.config b/tests/meta/nf-test.config new file mode 100644 index 00000000000..77842f66cea --- /dev/null +++ b/tests/meta/nf-test.config @@ -0,0 +1,13 @@ +config { + // location for all nf-tests + testsDir "." + + // nf-test directory including temporary files for each test + workDir System.getenv("NFT_WORKDIR") ?: ".nf-test" + + // location of an optional nextflow.config file specific for executing tests + configFile "nf.config" + + // run all test with the defined docker profile from the main nextflow.config + profile "" +} diff --git a/tests/meta/nf.config b/tests/meta/nf.config new file mode 100644 index 00000000000..bd228704a07 --- /dev/null +++ b/tests/meta/nf.config @@ -0,0 +1,50 @@ +params { + publish_dir_mode = "copy" + singularity_pull_docker_container = false + test_data_base = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules' + modules_testdata_base_path = 's3://ngi-igenomes/testdata/nf-core/modules/' +} + +process { + cpus = 2 + memory = 3.GB + time = 2.h +} + +profiles { + singularity { + singularity.enabled = true + singularity.autoMounts = true + } + conda { + conda.enabled = true + } + mamba { + conda.enabled = true + conda.useMamba = true + } + podman { + podman.enabled = true + podman.userEmulation = true + podman.runOptions = "--runtime crun --platform linux/x86_64 --systemd=always" + } + docker { + docker.enabled = true + docker.userEmulation = false + docker.runOptions = '-u $(id -u):$(id -g) --platform=linux/amd64' + } +} + +docker.registry = 'quay.io' +podman.registry = 'quay.io' +singularity.registry = 'quay.io' + +// Increase time available to build Conda environment +conda { createTimeout = "120 min" } + +// Load test_data.config containing paths to test data +includeConfig 'test_data.config' + +manifest { + nextflowVersion = '!>=23.04.0' +} From 867716d0cda543b9bba06bb22750086a6e5fd222 Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 12 Feb 2024 13:49:32 -0600 Subject: [PATCH 11/12] style: Add a tag to see what module is running --- tests/meta/main.nf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/meta/main.nf b/tests/meta/main.nf index 52701fe0d0a..2f1af4ca0df 100644 --- a/tests/meta/main.nf +++ b/tests/meta/main.nf @@ -17,6 +17,8 @@ workflow { } process NFTEST_MODULE { + tag "$module_file" + input: path module_file path test_file From 043546e6160e571a1d1721e1a3d217022fa2a2bb Mon Sep 17 00:00:00 2001 From: Edmund Miller Date: Mon, 12 Feb 2024 13:53:58 -0600 Subject: [PATCH 12/12] hack: Hard code the test_data.config --- tests/meta/nf.config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/meta/nf.config b/tests/meta/nf.config index bd228704a07..033ba253076 100644 --- a/tests/meta/nf.config +++ b/tests/meta/nf.config @@ -43,7 +43,7 @@ singularity.registry = 'quay.io' conda { createTimeout = "120 min" } // Load test_data.config containing paths to test data -includeConfig 'test_data.config' +includeConfig 'https://raw.githubusercontent.com/nf-core/modules/master/tests/config/test_data.config' manifest { nextflowVersion = '!>=23.04.0'