From 1d5adfe66db32dd95bb7dfe32c179cd61bcf2abd Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 09:59:38 -0400 Subject: [PATCH 01/23] Add test config from Sarek with @maxulysse's help --- .github/actions/get-shards/action.yml | 66 ++++++++++++ .github/actions/nf-test/action.yml | 118 ++++++++++++++++++++ .github/workflows/nf-test.yml | 149 ++++++++++++++++++++++++++ .gitignore | 2 + nf-test.config | 24 +++++ 5 files changed, 359 insertions(+) create mode 100644 .github/actions/get-shards/action.yml create mode 100644 .github/actions/nf-test/action.yml create mode 100644 .github/workflows/nf-test.yml create mode 100644 nf-test.config diff --git a/.github/actions/get-shards/action.yml b/.github/actions/get-shards/action.yml new file mode 100644 index 0000000..6d388be --- /dev/null +++ b/.github/actions/get-shards/action.yml @@ -0,0 +1,66 @@ +name: "Get number of shards" +description: "Get the number of nf-test shards for the current CI job" +inputs: + max_shards: + description: "Maximum number of shards allowed" + required: true + paths: + description: "Component paths to test" + required: false +outputs: + shard: + description: "Array of shard numbers" + value: ${{ steps.shards.outputs.shard }} + total_shards: + description: "Total number of shards" + value: ${{ steps.shards.outputs.total_shards }} +runs: + using: "composite" + steps: + - name: Install nf-test + uses: nf-core/setup-nf-test@v1 + with: + version: ${{ env.NFT_VER }} + - name: Get number of shards + id: shards + shell: bash + run: | + # Run nf-test with dynamic parameter + nftest_output=$(nf-test test \ + --dry-run \ + --profile +docker \ + --filter function,workflow,pipeline \ + --ci \ + --changed-since HEAD^) || { + echo "nf-test command failed with exit code $?" + echo "Full output: $nftest_output" + exit 1 + } + echo "nf-test dry-run output: $nftest_output" + + # Default values for shard and total_shards + shard="[]" + total_shards=0 + + # Check if there are related tests + if echo "$nftest_output" | grep -q 'No tests to execute'; then + echo "No related tests found." + else + # Extract the number of related tests + number_of_shards=$(echo "$nftest_output" | sed -n 's|.*Executed \([0-9]*\) tests.*|\1|p') + if [[ -n "$number_of_shards" && "$number_of_shards" -gt 0 ]]; then + shards_to_run=$(( $number_of_shards < ${{ inputs.max_shards }} ? $number_of_shards : ${{ inputs.max_shards }} )) + shard=$(seq 1 "$shards_to_run" | jq -R . | jq -c -s .) + total_shards="$shards_to_run" + else + echo "Unexpected output format. Falling back to default values." + fi + fi + + # Write to GitHub Actions outputs + echo "shard=$shard" >> $GITHUB_OUTPUT + echo "total_shards=$total_shards" >> $GITHUB_OUTPUT + + # Debugging output + echo "Final shard array: $shard" + echo "Total number of shards: $total_shards" diff --git a/.github/actions/nf-test/action.yml b/.github/actions/nf-test/action.yml new file mode 100644 index 0000000..e4fd9c3 --- /dev/null +++ b/.github/actions/nf-test/action.yml @@ -0,0 +1,118 @@ +name: "nf-test Action" +description: "Runs nf-test with common setup steps" +inputs: + profile: + description: "Profile to use" + required: true + shard: + description: "Shard number for this CI job" + required: true + total_shards: + description: "Total number of test shards(NOT the total number of matrix jobs)" + required: true + paths: + description: "Test paths" + required: true + +runs: + using: "composite" + steps: + - name: Setup Nextflow + uses: nf-core/setup-nextflow@v2 + with: + version: "${{ env.NXF_VERSION }}" + + - name: Set up Python + uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 + with: + python-version: "3.11" + + - name: Install nf-test + uses: nf-core/setup-nf-test@v1 + with: + version: "${{ env.NFT_VER }}" + + - name: Setup apptainer + if: contains(inputs.profile, 'singularity') + uses: eWaterCycle/setup-apptainer@main + + - name: Set up Singularity + if: contains(inputs.profile, 'singularity') + shell: bash + run: | + mkdir -p $NXF_SINGULARITY_CACHEDIR + mkdir -p $NXF_SINGULARITY_LIBRARYDIR + + - name: Conda setup + if: ${{inputs.profile == 'conda'}} + uses: conda-incubator/setup-miniconda@505e6394dae86d6a5c7fbb6e3fb8938e3e863830 # v3 + with: + auto-update-conda: true + conda-solver: libmamba + conda-remove-defaults: true + + - name: Install pdiff + shell: bash + run: | + python -m pip install pdiff + + - name: Clean up Disk space + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + + # TODO Skip failing conda tests and document their failures + # https://github.com/nf-core/modules/issues/7017 + - name: Run nf-test + shell: bash + env: + NFT_DIFF: ${{ env.NFT_DIFF }} + NFT_DIFF_ARGS: ${{ env.NFT_DIFF_ARGS }} + NFT_WORKDIR: ${{ env.NFT_WORKDIR }} + run: | + nf-test test \ + --profile=+${{ inputs.profile }} \ + --tap=test.tap \ + --verbose \ + --ci \ + --changed-since HEAD^ \ + --shard ${{ inputs.shard }}/${{ inputs.total_shards }} \ + --filter function,workflow,pipeline + + # Save the absolute path of the test.tap file to the output + echo "tap_file_path=$(realpath test.tap)" >> $GITHUB_OUTPUT + + - name: Generate test summary + if: always() + shell: bash + run: | + # Add header if it doesn't exist (using a token file to track this) + if [ ! -f ".summary_header" ]; then + echo "# 🚀 nf-test results" >> $GITHUB_STEP_SUMMARY + echo "" >> $GITHUB_STEP_SUMMARY + echo "| Status | Test Name | Profile | Shard |" >> $GITHUB_STEP_SUMMARY + echo "|:------:|-----------|---------|-------|" >> $GITHUB_STEP_SUMMARY + touch .summary_header + fi + + if [ -f test.tap ]; then + while IFS= read -r line; do + if [[ $line =~ ^ok ]]; then + test_name="${line#ok }" + # Remove the test number from the beginning + test_name="${test_name#* }" + echo "| ✅ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY + elif [[ $line =~ ^not\ ok ]]; then + test_name="${line#not ok }" + # Remove the test number from the beginning + test_name="${test_name#* }" + echo "| ❌ | ${test_name} | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY + fi + done < test.tap + else + echo "| ⚠️ | No test results found | ${{ inputs.profile }} | ${{ inputs.shard }}/${{ inputs.total_shards }} |" >> $GITHUB_STEP_SUMMARY + fi + + - name: Clean up + if: always() + shell: bash + run: | + sudo rm -rf /home/ubuntu/tests/ diff --git a/.github/workflows/nf-test.yml b/.github/workflows/nf-test.yml new file mode 100644 index 0000000..c951f6d --- /dev/null +++ b/.github/workflows/nf-test.yml @@ -0,0 +1,149 @@ +name: Run nf-test +on: + push: + paths-ignore: + - "docs/**" + - "**/meta.yml" + - "**/*.md" + - "**/*.png" + - "**/*.svg" + pull_request: + paths-ignore: + - "docs/**" + - "**/meta.yml" + - "**/*.md" + - "**/*.png" + - "**/*.svg" + release: + types: [published] + workflow_dispatch: + inputs: + runners: + description: "Runners to test on" + type: choice + options: + - "ubuntu-latest" + - "self-hosted" + default: "ubuntu-latest" + +# Cancel if a newer run is started +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NFT_DIFF: "pdiff" + NFT_DIFF_ARGS: "--line-numbers --width 120 --expand-tabs=2" + # renovate: datasource=github-releases depName=askimed/nf-test versioning=semver + NFT_VER: "0.9.2" + NFT_WORKDIR: "~" + NXF_ANSI_LOG: false + NXF_SINGULARITY_CACHEDIR: ${{ github.workspace }}/.singularity + NXF_SINGULARITY_LIBRARYDIR: ${{ github.workspace }}/.singularity + +jobs: + nf-test-changes: + name: nf-test-changes + runs-on: ${{ github.event.inputs.runners || github.run_number > 1 && 'ubuntu-latest' || 'self-hosted' }} + outputs: + shard: ${{ steps.set-shards.outputs.shard }} + total_shards: ${{ steps.set-shards.outputs.total_shards }} + steps: + - name: Clean Workspace # Purge the workspace in case it's running on a self-hosted runner + run: | + ls -la ./ + rm -rf ./* || true + rm -rf ./.??* || true + ls -la ./ + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + fetch-depth: 0 + + - name: get number of shards + id: set-shards + uses: ./.github/actions/get-shards + env: + NFT_VER: ${{ env.NFT_VER }} + with: + max_shards: 7 + + - name: debug + run: | + echo ${{ steps.set-shards.outputs.shard }} + echo ${{ steps.set-shards.outputs.total_shards }} + + nf-test: + runs-on: ${{ github.event.inputs.runners || github.run_number > 1 && 'ubuntu-latest' || 'self-hosted' }} + name: "${{ matrix.profile }} | ${{ matrix.NXF_VER }} | ${{ matrix.shard }}/${{ needs.nf-test-changes.outputs.total_shards }}" + needs: [nf-test-changes] + if: ${{ needs.nf-test-changes.outputs.total_shards != '0' }} + strategy: + fail-fast: false + matrix: + shard: ${{ fromJson(needs.nf-test-changes.outputs.shard) }} + profile: [conda, docker, singularity] + isMaster: + - ${{ github.base_ref == 'master' }} + # Exclude conda and singularity on dev + exclude: + - isMaster: false + profile: "conda" + - isMaster: false + profile: "singularity" + NXF_VER: + # renovate: datasource=github-releases depName=nextflow/nextflow versioning=semver + - "24.10.2" + - "latest-everything" + env: + NXF_ANSI_LOG: false + TOTAL_SHARDS: ${{ needs.nf-test-changes.outputs.total_shards }} + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 + with: + fetch-depth: 0 + + - name: Run nf-test + uses: ./.github/actions/nf-test + env: + NFT_DIFF: ${{ env.NFT_DIFF }} + NFT_DIFF_ARGS: ${{ env.NFT_DIFF_ARGS }} + NFT_WORKDIR: ${{ env.NFT_WORKDIR }} + with: + profile: ${{ matrix.profile }} + shard: ${{ matrix.shard }} + total_shards: ${{ env.TOTAL_SHARDS }} + + confirm-pass: + runs-on: ${{ github.event.inputs.runners || github.run_number > 1 && 'ubuntu-latest' || 'self-hosted' }} + needs: [nf-test] + if: always() + steps: + - name: One or more tests failed + if: ${{ contains(needs.*.result, 'failure') }} + run: exit 1 + + - name: One or more tests cancelled + if: ${{ contains(needs.*.result, 'cancelled') }} + run: exit 1 + + - name: All tests ok + if: ${{ contains(needs.*.result, 'success') }} + run: exit 0 + + - name: debug-print + if: always() + run: | + echo "::group::DEBUG: `needs` Contents" + echo "DEBUG: toJSON(needs) = ${{ toJSON(needs) }}" + echo "DEBUG: toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}" + echo "::endgroup::" + + - name: Clean Workspace # Purge the workspace in case it's running on a self-hosted runner + if: always() + run: | + ls -la ./ + rm -rf ./* || true + rm -rf ./.??* || true + ls -la ./ diff --git a/.gitignore b/.gitignore index a42ce01..d2998c7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,5 @@ testing/ testing* *.pyc null/ + +nf-test/* diff --git a/nf-test.config b/nf-test.config new file mode 100644 index 0000000..a020e65 --- /dev/null +++ b/nf-test.config @@ -0,0 +1,24 @@ +config { + // location for all nf-test 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 "tests/nextflow.config" + + // ignore tests coming from the nf-core/modules repo + ignore 'modules/nf-core/**/*', 'subworkflows/nf-core/**/*' + + // run all test with defined profile(s) from the main nextflow.config + profile "test" + + // list of filenames or patterns that should be trigger a full test run + triggers 'nextflow.config', 'nf-test.config', 'conf/test.config', 'tests/nextflow.config' + + // load the necessary plugins + plugins { + load "nft-utils@0.0.3" + } +} From 346f5814cf834e57a27fa373f1ba71131cdb58a6 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:11:29 -0400 Subject: [PATCH 02/23] Ignore hidden .nf-test.log and .nf-test/ directory --- .gitignore | 3 ++- tests/nextflow.config | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/nextflow.config diff --git a/.gitignore b/.gitignore index d2998c7..9ed09a2 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ testing* *.pyc null/ -nf-test/* +.nf-test/* +.nf-test.log diff --git a/tests/nextflow.config b/tests/nextflow.config new file mode 100644 index 0000000..393cbed --- /dev/null +++ b/tests/nextflow.config @@ -0,0 +1,15 @@ +/* +======================================================================================== + Nextflow config file for running nf-test tests +======================================================================================== +*/ + +// Specify any additional parameters here +// Or any resources requirements + +// Should resolve issue with accessing s3 from the runners +aws.client.anonymous = true + +// Should take care of all basepath +params.modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/' +params.igenomes_base = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data' From f13032c4ddb4aae12c3392ff7b4e9b5776e779d8 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:18:06 -0400 Subject: [PATCH 03/23] Update PR template with nf-test commands --- .github/PULL_REQUEST_TEMPLATE.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 49b1cc5..5d0e8d4 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -18,8 +18,8 @@ Learn more about contributing: [CONTRIBUTING.md](https://github.com/nf-core/prot - [ ] If you've added a new tool - have you followed the pipeline conventions in the [contribution docs](https://github.com/nf-core/proteinannotator/tree/master/.github/CONTRIBUTING.md) - [ ] If necessary, also make a PR on the nf-core/proteinannotator _branch_ on the [nf-core/test-datasets](https://github.com/nf-core/test-datasets) repository. - [ ] Make sure your code lints (`nf-core pipelines lint`). -- [ ] Ensure the test suite passes (`nextflow run . -profile test,docker --outdir `). -- [ ] Check for unexpected warnings in debug mode (`nextflow run . -profile debug,test,docker --outdir `). +- [ ] Ensure the test suite passes (e.g. `nf-test test */local --profile=~test,docker` for all new local tests). +- [ ] Check for unexpected warnings in debug mode (`nf-test test */local --profile=~test,docker,debug`). - [ ] Usage Documentation in `docs/usage.md` is updated. - [ ] Output Documentation in `docs/output.md` is updated. - [ ] `CHANGELOG.md` is updated. From d8b2096f95ff2b2d3bfa9fc4ca63ba7c762744f1 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:34:38 -0400 Subject: [PATCH 04/23] Ignore pull request template in linting because of nf-test commands --- .nf-core.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.nf-core.yml b/.nf-core.yml index 485ee2a..0ca53dc 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -4,6 +4,9 @@ nf_core_version: 3.2.0 lint: {} +files_unchanged: + - .github/PULL_REQUEST_TEMPLATE.md + template: org: nf-core name: proteinannotator From d2c476b837bb8848630cb2868d2224fabe040c15 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:35:49 -0400 Subject: [PATCH 05/23] Update changelog about nf-tests --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d497b4c..a43868e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ Initial release of nf-core/proteinannotator, created with the [nf-core](https:// ### `Added` +- Updated to `nf-test` on GitHub Actions and in the `PULL_REQUEST_TEMPLATE.md` + ### `Fixed` ### `Dependencies` From 21d4ebd335c779ba57b961f0fb2b874efb24acbd Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:38:52 -0400 Subject: [PATCH 06/23] Move files_unchanged section to be under lint --- .nf-core.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.nf-core.yml b/.nf-core.yml index 0ca53dc..9b7ca73 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -2,10 +2,9 @@ repository_type: pipeline nf_core_version: 3.2.0 -lint: {} - -files_unchanged: - - .github/PULL_REQUEST_TEMPLATE.md +lint: + files_unchanged: + - .github/PULL_REQUEST_TEMPLATE.md template: org: nf-core From 2ce37f9e2180c723e612b73ab9fd18228b1c8a3f Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 10:47:58 -0400 Subject: [PATCH 07/23] Resolve conflicting lint.files_unchanged keys in .nf-core.yml --- .nf-core.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.nf-core.yml b/.nf-core.yml index f793add..038daab 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -3,13 +3,10 @@ lint: - assets/nf-core-proteinannotator_logo_light.png - docs/images/nf-core-proteinannotator_logo_light.png - docs/images/nf-core-proteinannotator_logo_dark.png + - .github/PULL_REQUEST_TEMPLATE.md nf_core_version: 3.2.1 repository_type: pipeline -lint: - files_unchanged: - - .github/PULL_REQUEST_TEMPLATE.md - template: author: Olga Botvinnik description: The best protein annotation pipeline in the world. Protein fasta -> From 35203d5d7911e8ff2449847a90ae2c7d9dacf39e Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 11:33:33 -0400 Subject: [PATCH 08/23] Get linting to pass --- .github/workflows/awsfulltest.yml | 44 ++++++++++++++++++++++--------- .nf-core.yml | 3 ++- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/.github/workflows/awsfulltest.yml b/.github/workflows/awsfulltest.yml index fe65e19..7107eb7 100644 --- a/.github/workflows/awsfulltest.yml +++ b/.github/workflows/awsfulltest.yml @@ -4,39 +4,57 @@ name: nf-core AWS full size tests # It runs the -profile 'test_full' on AWS batch on: + pull_request: + branches: + - main + - master workflow_dispatch: pull_request_review: types: [submitted] - release: - types: [published] jobs: run-platform: name: Run AWS full tests - # run only if the PR is approved by at least 2 reviewers and against the master/main branch or manually triggered - if: github.repository == 'nf-core/proteinannotator' && github.event.review.state == 'approved' && (github.event.pull_request.base.ref == 'master' || github.event.pull_request.base.ref == 'main') || github.event_name == 'workflow_dispatch' + # run only if the PR is approved by at least 2 reviewers and against the master branch or manually triggered + if: github.repository == 'nf-core/rnavar' && github.event.review.state == 'approved' && github.event.pull_request.base.ref == 'master' || github.event_name == 'workflow_dispatch' runs-on: ubuntu-latest steps: - - name: Set revision variable - id: revision + - name: Get PR reviews + uses: octokit/request-action@v2.x + if: github.event_name != 'workflow_dispatch' + id: check_approvals + continue-on-error: true + with: + route: GET /repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews?per_page=100 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check for approvals + if: ${{ failure() && github.event_name != 'workflow_dispatch' }} + run: | + echo "No review approvals found. At least 2 approvals are required to run this action automatically." + exit 1 + + - name: Check for enough approvals (>=2) + id: test_variables + if: github.event_name != 'workflow_dispatch' run: | - echo "revision=${{ (github.event_name == 'workflow_dispatch' || github.event_name == 'release') && github.sha || 'dev' }}" >> "$GITHUB_OUTPUT" + JSON_RESPONSE='${{ steps.check_approvals.outputs.data }}' + CURRENT_APPROVALS_COUNT=$(echo $JSON_RESPONSE | jq -c '[.[] | select(.state | contains("APPROVED")) ] | length') + test $CURRENT_APPROVALS_COUNT -ge 2 || exit 1 # At least 2 approvals are required - name: Launch workflow via Seqera Platform uses: seqeralabs/action-tower-launch@v2 - # TODO nf-core: You can customise AWS full pipeline tests as required - # Add full size test data (but still relatively small datasets for few samples) - # on the `test_full.config` test runs with only one set of parameters with: workspace_id: ${{ secrets.TOWER_WORKSPACE_ID }} access_token: ${{ secrets.TOWER_ACCESS_TOKEN }} compute_env: ${{ secrets.TOWER_COMPUTE_ENV }} - revision: ${{ steps.revision.outputs.revision }} - workdir: s3://${{ secrets.AWS_S3_BUCKET }}/work/proteinannotator/work-${{ steps.revision.outputs.revision }} + revision: ${{ github.sha }} + workdir: s3://${{ secrets.AWS_S3_BUCKET }}/work/rnavar/work-${{ github.sha }} parameters: | { "hook_url": "${{ secrets.MEGATESTS_ALERTS_SLACK_HOOK_URL }}", - "outdir": "s3://${{ secrets.AWS_S3_BUCKET }}/proteinannotator/results-${{ steps.revision.outputs.revision }}" + "outdir": "s3://${{ secrets.AWS_S3_BUCKET }}/rnavar/results-${{ github.sha }}" } profiles: test_full diff --git a/.nf-core.yml b/.nf-core.yml index 038daab..6f474c4 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1,10 +1,11 @@ lint: + actions_ci: false files_unchanged: - assets/nf-core-proteinannotator_logo_light.png - docs/images/nf-core-proteinannotator_logo_light.png - docs/images/nf-core-proteinannotator_logo_dark.png - .github/PULL_REQUEST_TEMPLATE.md -nf_core_version: 3.2.1 +nf_core_version: 3.2.0 repository_type: pipeline template: From ecd74ccfdcf517b6de1be047bbdfa86d589910db Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 11:50:45 -0400 Subject: [PATCH 09/23] Add nf-test for the whole pipeline --- tests/.nftignore | 4 ++++ tests/default.nf.test | 38 ++++++++++++++++++++++++++++++++ tests/default.nf.test.snap | 44 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 tests/.nftignore create mode 100644 tests/default.nf.test create mode 100644 tests/default.nf.test.snap diff --git a/tests/.nftignore b/tests/.nftignore new file mode 100644 index 0000000..064c13d --- /dev/null +++ b/tests/.nftignore @@ -0,0 +1,4 @@ +.DS_Store +multiqc/multiqc_plots/{svg,pdf,png}/*.{svg,pdf,png} +multiqc/multiqc_report.html +pipeline_info/*.{html,json,txt,yml} diff --git a/tests/default.nf.test b/tests/default.nf.test new file mode 100644 index 0000000..ed53119 --- /dev/null +++ b/tests/default.nf.test @@ -0,0 +1,38 @@ +nextflow_pipeline { + + name "Test pipeline" + script "../main.nf" + tag "pipeline" + tag "pipeline_proteinannotator" + tag "cpu" + + test("-profile test") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + // stable_name: All files + folders in ${params.outdir}/ with a stable name + def stable_name = getAllFilesFromDir(params.outdir, relative: true, includeDir: true, ignore: ['pipeline_info/*.{html,json,txt}']) + // stable_path: All files in ${params.outdir}/ with stable content + def stable_path = getAllFilesFromDir(params.outdir, ignoreFile: 'tests/.nftignore') + assert workflow.success + assertAll( + { assert snapshot( + // Number of successful tasks + workflow.trace.succeeded().size(), + // pipeline versions.yml file for multiqc from which Nextflow version is removed because we tests pipelines on multiple Nextflow versions + removeNextflowVersion("$outputDir/pipeline_info/nf_core_proteinannotator_software_mqc_versions.yml"), + // All stable path name, with a relative path + stable_name, + // All files with stable contents + stable_path.isEmpty() ? 'No stable content' : stable_path, + // All cram files + ).match() } + ) + } + } +} diff --git a/tests/default.nf.test.snap b/tests/default.nf.test.snap new file mode 100644 index 0000000..f7cec2e --- /dev/null +++ b/tests/default.nf.test.snap @@ -0,0 +1,44 @@ +{ + "-profile test": { + "content": [ + 3, + { + "SEQKIT_STATS": { + "seqkit": "2.9.0" + }, + "Workflow": { + "nf-core/proteinannotator": "v1.0.0dev" + } + }, + [ + "multiqc", + "multiqc/multiqc_data", + "multiqc/multiqc_data/multiqc.log", + "multiqc/multiqc_data/multiqc_citations.txt", + "multiqc/multiqc_data/multiqc_data.json", + "multiqc/multiqc_data/multiqc_software_versions.txt", + "multiqc/multiqc_data/multiqc_sources.txt", + "multiqc/multiqc_report.html", + "pipeline_info", + "pipeline_info/nf_core_proteinannotator_software_mqc_versions.yml", + "seqkit", + "seqkit/T1024.tsv", + "seqkit/T1026.tsv" + ], + [ + "multiqc.log:md5,f9afd4d93d7620d65ce5d6360339ff6e", + "multiqc_citations.txt:md5,4c806e63a283ec1b7e78cdae3a923d4f", + "multiqc_data.json:md5,eba015690f3d2ddf54967a237db11b0e", + "multiqc_software_versions.txt:md5,c5b754560c24cc8da0c1e92febf6f37f", + "multiqc_sources.txt:md5,d2a044df39ce3c6abe5cdc2d67473490", + "T1024.tsv:md5,c8a3fd71b27b9455aa837e1d50026971", + "T1026.tsv:md5,b028126e117cf0979b6f907cb20c6958" + ] + ], + "meta": { + "nf-test": "0.9.2", + "nextflow": "25.04.1" + }, + "timestamp": "2025-05-14T11:49:14.001221" + } +} From 9fa583ac887efc0323e6b36875be01247656501d Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 11:50:52 -0400 Subject: [PATCH 10/23] Remove old "nextflow run" test --- .github/workflows/ci.yml | 88 ---------------------------------------- 1 file changed, 88 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 14b7802..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,88 +0,0 @@ -name: nf-core CI -# This workflow runs the pipeline with the minimal test dataset to check that it completes without any syntax errors -on: - push: - branches: - - dev - pull_request: - release: - types: [published] - workflow_dispatch: - -env: - NXF_ANSI_LOG: false - NXF_SINGULARITY_CACHEDIR: ${{ github.workspace }}/.singularity - NXF_SINGULARITY_LIBRARYDIR: ${{ github.workspace }}/.singularity - -concurrency: - group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}" - cancel-in-progress: true - -jobs: - test: - name: "Run pipeline with test data (${{ matrix.NXF_VER }} | ${{ matrix.test_name }} | ${{ matrix.profile }})" - # Only run on push if this is the nf-core dev branch (merged PRs) - if: "${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/proteinannotator') }}" - runs-on: ubuntu-latest - strategy: - matrix: - NXF_VER: - - "24.04.2" - - "latest-everything" - profile: - - "conda" - - "docker" - - "singularity" - test_name: - - "test" - isMaster: - - ${{ github.base_ref == 'master' }} - # Exclude conda and singularity on dev - exclude: - - isMaster: false - profile: "conda" - - isMaster: false - profile: "singularity" - steps: - - name: Check out pipeline code - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 - with: - fetch-depth: 0 - - - name: Set up Nextflow - uses: nf-core/setup-nextflow@v2 - with: - version: "${{ matrix.NXF_VER }}" - - - name: Set up Apptainer - if: matrix.profile == 'singularity' - uses: eWaterCycle/setup-apptainer@main - - - name: Set up Singularity - if: matrix.profile == 'singularity' - run: | - mkdir -p $NXF_SINGULARITY_CACHEDIR - mkdir -p $NXF_SINGULARITY_LIBRARYDIR - - - name: Set up Miniconda - if: matrix.profile == 'conda' - uses: conda-incubator/setup-miniconda@a4260408e20b96e80095f42ff7f1a15b27dd94ca # v3 - with: - miniconda-version: "latest" - auto-update-conda: true - conda-solver: libmamba - channels: conda-forge,bioconda - - - name: Set up Conda - if: matrix.profile == 'conda' - run: | - echo $(realpath $CONDA)/condabin >> $GITHUB_PATH - echo $(realpath python) >> $GITHUB_PATH - - - name: Clean up Disk space - uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 - - - name: "Run pipeline with test data ${{ matrix.NXF_VER }} | ${{ matrix.test_name }} | ${{ matrix.profile }}" - continue-on-error: ${{ matrix.NXF_VER == 'latest-everything' }} - run: | - nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.test_name }},${{ matrix.profile }} --outdir ./results From 67a5279e9589ac089e86ffc7d2c5ffe2591ed659 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 11:54:57 -0400 Subject: [PATCH 11/23] Ignore missing .github/workflows/ci.yml in nf-core.yml --- .nf-core.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.nf-core.yml b/.nf-core.yml index 6f474c4..2da5817 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1,4 +1,5 @@ lint: + files_exist: .github/workflows/ci.yml actions_ci: false files_unchanged: - assets/nf-core-proteinannotator_logo_light.png From f4e4b91b30f2d4e3c1beb1083ac5554dc2de9fee Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 11:57:03 -0400 Subject: [PATCH 12/23] Fix .nf-core.yml validation --- .nf-core.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.nf-core.yml b/.nf-core.yml index 2da5817..730ed93 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1,5 +1,6 @@ lint: - files_exist: .github/workflows/ci.yml + files_exist: + - .github/workflows/ci.yml actions_ci: false files_unchanged: - assets/nf-core-proteinannotator_logo_light.png From 39fd02f72aeed7d331bc0403c161c58662fd704f Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 14:49:58 -0400 Subject: [PATCH 13/23] Don't check for workflow output for now --- .../functional_annotation/tests/main.nf.test | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/subworkflows/local/functional_annotation/tests/main.nf.test b/subworkflows/local/functional_annotation/tests/main.nf.test index 06cba21..c30bb13 100644 --- a/subworkflows/local/functional_annotation/tests/main.nf.test +++ b/subworkflows/local/functional_annotation/tests/main.nf.test @@ -10,25 +10,24 @@ nextflow_workflow { tag "subworkflows_" tag "subworkflows/functional_annotation" // TODO nf-core: Add tags for all modules used within this subworkflow. Example: - tag "samtools" - tag "samtools/sort" - tag "samtools/index" + // tag "samtools" + // tag "samtools/sort" + // tag "samtools/index" // TODO nf-core: Change the test name preferably indicating the test-data and file-format used - test("sarscov2 - bam - single_end") { + test("snap25 isoforms - bcl2 - ced9") { when { + params { + pipelines_testdata_base_path = "https://github.com/nf-core/test-datasets/blob/" + } workflow { """ // TODO nf-core: define inputs of the workflow here. Example: input[0] = [ [ id:'test', single_end:false ], // meta map - file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), - ] - input[1] = [ - [ id:'genome' ], - file(params.modules_testdata_base_path + 'genomics/sarscov2/illumina/bam/test.paired_end.sorted.bam', checkIfExists: true), + file(params.pipelines_testdata_base_path + 'proteinannotator/reference/snap25_isoforms_bcl2_ced9.fasta', checkIfExists: true), ] """ } @@ -36,8 +35,8 @@ nextflow_workflow { then { assertAll( + // { assert snapshot(workflow.out).match()}, { assert workflow.success}, - { assert snapshot(workflow.out).match()} //TODO nf-core: Add all required assertions to verify the test output. ) } From 820a23e158128cf6dcbf0630f8e2a61677b0eca1 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 14:50:07 -0400 Subject: [PATCH 14/23] Playing around with meta mapping --- subworkflows/local/functional_annotation/main.nf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subworkflows/local/functional_annotation/main.nf b/subworkflows/local/functional_annotation/main.nf index abde53c..99692f6 100644 --- a/subworkflows/local/functional_annotation/main.nf +++ b/subworkflows/local/functional_annotation/main.nf @@ -16,8 +16,10 @@ workflow FUNCTIONAL_ANNOTATION { .map { meta, fasta -> [ + // meta, [id:"${meta.id}_${fasta[0].splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , - fasta[0].splitFasta(file:true) + fasta + // fasta[0].splitFasta(file:true) ] } .transpose() From ef89ee9b1165232452ff3072f2d5011f9d9a1be7 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 14:56:52 -0400 Subject: [PATCH 15/23] Trying to get nf tests to work --- subworkflows/local/functional_annotation/main.nf | 4 +--- subworkflows/local/functional_annotation/tests/main.nf.test | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/subworkflows/local/functional_annotation/main.nf b/subworkflows/local/functional_annotation/main.nf index 99692f6..abde53c 100644 --- a/subworkflows/local/functional_annotation/main.nf +++ b/subworkflows/local/functional_annotation/main.nf @@ -16,10 +16,8 @@ workflow FUNCTIONAL_ANNOTATION { .map { meta, fasta -> [ - // meta, [id:"${meta.id}_${fasta[0].splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , - fasta - // fasta[0].splitFasta(file:true) + fasta[0].splitFasta(file:true) ] } .transpose() diff --git a/subworkflows/local/functional_annotation/tests/main.nf.test b/subworkflows/local/functional_annotation/tests/main.nf.test index c30bb13..ef4c8b4 100644 --- a/subworkflows/local/functional_annotation/tests/main.nf.test +++ b/subworkflows/local/functional_annotation/tests/main.nf.test @@ -26,9 +26,9 @@ nextflow_workflow { """ // TODO nf-core: define inputs of the workflow here. Example: input[0] = [ - [ id:'test', single_end:false ], // meta map - file(params.pipelines_testdata_base_path + 'proteinannotator/reference/snap25_isoforms_bcl2_ced9.fasta', checkIfExists: true), - ] + [ id:'test', single_end:false ], // meta map + file(params.pipelines_testdata_base_path + 'proteinannotator/reference/snap25_isoforms_bcl2_ced9.fasta', checkIfExists: true) + ] """ } } From b1e11b3bf47457946138ef7834cb4570887730c2 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 15:35:29 -0400 Subject: [PATCH 16/23] Redo splitfasta for functional annotation --- subworkflows/local/functional_annotation/main.nf | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/subworkflows/local/functional_annotation/main.nf b/subworkflows/local/functional_annotation/main.nf index abde53c..bf85b16 100644 --- a/subworkflows/local/functional_annotation/main.nf +++ b/subworkflows/local/functional_annotation/main.nf @@ -13,14 +13,15 @@ workflow FUNCTIONAL_ANNOTATION { // Create a multifasta, with one fasta per entry, add the sequence ID to the meta id ch_fasta + .splitFasta(file: true) + .view() .map { meta, fasta -> - [ - [id:"${meta.id}_${fasta[0].splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , - fasta[0].splitFasta(file:true) - ] + [ + [id: "${meta.id}_${fasta.splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"], + fasta + ] } - .transpose() .view() .set { ch_multifasta } @@ -31,5 +32,6 @@ workflow FUNCTIONAL_ANNOTATION { emit: // TODO nf-core: edit emitted channels - versions = ch_versions // channel: [ versions.yml ] + multifasta = ch_multifasta + versions = ch_versions // channel: [ versions.yml ] } From 2b55966b818f382e5fe662667bd97676c027f056 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 15:35:43 -0400 Subject: [PATCH 17/23] Fix nf-test for whole workflow --- nextflow.config | 1 + tests/nextflow.config | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/nextflow.config b/nextflow.config index 9b72f6d..ae9f3cb 100644 --- a/nextflow.config +++ b/nextflow.config @@ -33,6 +33,7 @@ params { show_hidden = false version = false pipelines_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/' + modules_testdata_base_path = null trace_report_suffix = new java.util.Date().format( 'yyyy-MM-dd_HH-mm-ss')// Config options config_profile_name = null config_profile_description = null diff --git a/tests/nextflow.config b/tests/nextflow.config index 393cbed..eb1d158 100644 --- a/tests/nextflow.config +++ b/tests/nextflow.config @@ -12,4 +12,3 @@ aws.client.anonymous = true // Should take care of all basepath params.modules_testdata_base_path = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data/' -params.igenomes_base = 'https://raw.githubusercontent.com/nf-core/test-datasets/modules/data' From 34453012b5cd8c589c842e42618a194a1162b01c Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 15:36:26 -0400 Subject: [PATCH 18/23] Channel.of fixes everything, thanks @edmundmiller --- subworkflows/local/functional_annotation/tests/main.nf.test | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subworkflows/local/functional_annotation/tests/main.nf.test b/subworkflows/local/functional_annotation/tests/main.nf.test index ef4c8b4..5d5cea7 100644 --- a/subworkflows/local/functional_annotation/tests/main.nf.test +++ b/subworkflows/local/functional_annotation/tests/main.nf.test @@ -20,15 +20,15 @@ nextflow_workflow { when { params { - pipelines_testdata_base_path = "https://github.com/nf-core/test-datasets/blob/" + pipelines_testdata_base_path = "https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/" } workflow { """ // TODO nf-core: define inputs of the workflow here. Example: - input[0] = [ + input[0] = Channel.of([ [ id:'test', single_end:false ], // meta map file(params.pipelines_testdata_base_path + 'proteinannotator/reference/snap25_isoforms_bcl2_ced9.fasta', checkIfExists: true) - ] + ]) """ } } From 2e684a8c452aa43439112fb2cb50163d108df120 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 15:39:42 -0400 Subject: [PATCH 19/23] Update description for --- nextflow_schema.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nextflow_schema.json b/nextflow_schema.json index 9185010..064e2a3 100644 --- a/nextflow_schema.json +++ b/nextflow_schema.json @@ -180,6 +180,10 @@ "default": "https://raw.githubusercontent.com/nf-core/test-datasets/", "hidden": true }, + "modules_testdata_base_path": { + "type": "string", + "description": "Base URL or local path to location of modules test dataset files" + }, "trace_report_suffix": { "type": "string", "fa_icon": "far calendar", From ddef5bd25303f740e766deb97676fa5418aa154b Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 16:14:42 -0400 Subject: [PATCH 20/23] Get tests for all of proteinannotator to run --- subworkflows/local/functional_annotation/main.nf | 11 +++++------ tests/.nftignore | 5 +++++ tests/default.nf.test.snap | 8 ++------ workflows/proteinannotator.nf | 2 ++ 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/subworkflows/local/functional_annotation/main.nf b/subworkflows/local/functional_annotation/main.nf index bf85b16..0285473 100644 --- a/subworkflows/local/functional_annotation/main.nf +++ b/subworkflows/local/functional_annotation/main.nf @@ -13,15 +13,14 @@ workflow FUNCTIONAL_ANNOTATION { // Create a multifasta, with one fasta per entry, add the sequence ID to the meta id ch_fasta - .splitFasta(file: true) - .view() .map { meta, fasta -> - [ - [id: "${meta.id}_${fasta.splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"], - fasta - ] + [ + [id:"${meta.id}_${fasta[0].splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , + fasta[0].splitFasta(file:true) + ] } + .transpose() .view() .set { ch_multifasta } diff --git a/tests/.nftignore b/tests/.nftignore index 064c13d..8ff43aa 100644 --- a/tests/.nftignore +++ b/tests/.nftignore @@ -1,4 +1,9 @@ .DS_Store multiqc/multiqc_plots/{svg,pdf,png}/*.{svg,pdf,png} multiqc/multiqc_report.html +multiqc/multiqc_data/multiqc.log +multiqc/multiqc_data/multiqc_data.json +multiqc/multiqc_data/multiqc_general_stats.txt +multiqc/multiqc_data/multiqc_software_versions.txt +multiqc/multiqc_data/multiqc_sources.txt pipeline_info/*.{html,json,txt,yml} diff --git a/tests/default.nf.test.snap b/tests/default.nf.test.snap index f7cec2e..606d675 100644 --- a/tests/default.nf.test.snap +++ b/tests/default.nf.test.snap @@ -26,11 +26,7 @@ "seqkit/T1026.tsv" ], [ - "multiqc.log:md5,f9afd4d93d7620d65ce5d6360339ff6e", "multiqc_citations.txt:md5,4c806e63a283ec1b7e78cdae3a923d4f", - "multiqc_data.json:md5,eba015690f3d2ddf54967a237db11b0e", - "multiqc_software_versions.txt:md5,c5b754560c24cc8da0c1e92febf6f37f", - "multiqc_sources.txt:md5,d2a044df39ce3c6abe5cdc2d67473490", "T1024.tsv:md5,c8a3fd71b27b9455aa837e1d50026971", "T1026.tsv:md5,b028126e117cf0979b6f907cb20c6958" ] @@ -39,6 +35,6 @@ "nf-test": "0.9.2", "nextflow": "25.04.1" }, - "timestamp": "2025-05-14T11:49:14.001221" + "timestamp": "2025-05-14T16:07:27.013727" } -} +} \ No newline at end of file diff --git a/workflows/proteinannotator.nf b/workflows/proteinannotator.nf index f7e4b65..429afc4 100644 --- a/workflows/proteinannotator.nf +++ b/workflows/proteinannotator.nf @@ -26,6 +26,8 @@ workflow PROTEINANNOTATOR { ch_versions = Channel.empty() ch_multiqc_files = Channel.empty() + ch_samplesheet.view() + FUNCTIONAL_ANNOTATION ( ch_samplesheet ) From d5613abd3ecfb367785b4718f732b0f98bb54cf4 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 16:47:15 -0400 Subject: [PATCH 21/23] Fix the input types to use a flat fasta and not an array --- .../local/functional_annotation/main.nf | 5 +-- .../functional_annotation/tests/main.nf.test | 43 +++++++++++++++++-- .../main.nf | 7 +-- 3 files changed, 42 insertions(+), 13 deletions(-) diff --git a/subworkflows/local/functional_annotation/main.nf b/subworkflows/local/functional_annotation/main.nf index 0285473..5cec62a 100644 --- a/subworkflows/local/functional_annotation/main.nf +++ b/subworkflows/local/functional_annotation/main.nf @@ -16,12 +16,11 @@ workflow FUNCTIONAL_ANNOTATION { .map { meta, fasta -> [ - [id:"${meta.id}_${fasta[0].splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , - fasta[0].splitFasta(file:true) + [id:"${meta.id}_${fasta.splitFasta(record: [id: true]).id[0].replaceAll(/\|/, '-')}"] , + fasta.splitFasta(file:true) ] } .transpose() - .view() .set { ch_multifasta } // diff --git a/subworkflows/local/functional_annotation/tests/main.nf.test b/subworkflows/local/functional_annotation/tests/main.nf.test index 5d5cea7..6e7705f 100644 --- a/subworkflows/local/functional_annotation/tests/main.nf.test +++ b/subworkflows/local/functional_annotation/tests/main.nf.test @@ -16,7 +16,7 @@ nextflow_workflow { // TODO nf-core: Change the test name preferably indicating the test-data and file-format used - test("snap25 isoforms - bcl2 - ced9") { + test("Test two input channels, one fasta record each") { when { params { @@ -25,10 +25,45 @@ nextflow_workflow { workflow { """ // TODO nf-core: define inputs of the workflow here. Example: - input[0] = Channel.of([ - [ id:'test', single_end:false ], // meta map + input[0] = Channel.fromList([ + [ + [ id:'T1024' ], // meta map + file(params.pipelines_testdata_base_path + 'proteinfold/testdata/sequences/T1024.fasta', checkIfExists: true) + ], + [ + [ id:'T1026' ], // meta map + file(params.pipelines_testdata_base_path + 'proteinfold/testdata/sequences/T1026.fasta', checkIfExists: true) + ] + ]) + """ + } + } + + then { + assertAll( + // { assert snapshot(workflow.out).match()}, + { assert workflow.success}, + //TODO nf-core: Add all required assertions to verify the test output. + ) + } + } + + // TODO nf-core: Change the test name preferably indicating the test-data and file-format used + test("Test single input fasta with 4 fasta records: snap25 isoforms - bcl2 - ced9") { + + when { + params { + pipelines_testdata_base_path = "https://raw.githubusercontent.com/nf-core/test-datasets/refs/heads/" + } + workflow { + """ + // TODO nf-core: define inputs of the workflow here. Example: + input[0] = Channel.fromList([ + [ + [ id:'test' ], // meta map file(params.pipelines_testdata_base_path + 'proteinannotator/reference/snap25_isoforms_bcl2_ced9.fasta', checkIfExists: true) - ]) + ] + ]) """ } } diff --git a/subworkflows/local/utils_nfcore_proteinannotator_pipeline/main.nf b/subworkflows/local/utils_nfcore_proteinannotator_pipeline/main.nf index 8f9b632..3ef64e2 100644 --- a/subworkflows/local/utils_nfcore_proteinannotator_pipeline/main.nf +++ b/subworkflows/local/utils_nfcore_proteinannotator_pipeline/main.nf @@ -71,16 +71,11 @@ workflow PIPELINE_INITIALISATION { .fromList(samplesheetToList(params.input, "${projectDir}/assets/schema_input.json")) .map { meta, fasta -> - return [ meta, [ fasta ] ] + return [ meta, fasta ] } - .groupTuple() .map { samplesheet -> validateInputSamplesheet(samplesheet) } - .map { - meta, fastas -> - return [ meta, fastas.flatten() ] - } .set { ch_samplesheet } emit: From 5f18558e33a65d5b684ddda7e48c9f9381970f53 Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 16:47:56 -0400 Subject: [PATCH 22/23] Add .nf-test-* to .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9ed09a2..65d2d0c 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ null/ .nf-test/* .nf-test.log +.nf-test-* From a3e8064330a31da328a8c6ee2679f4e86b54bbfe Mon Sep 17 00:00:00 2001 From: Olga Botvinnik Date: Wed, 14 May 2025 17:00:08 -0400 Subject: [PATCH 23/23] Add PR link for nf test --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d89ab0..4353e0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ Initial release of nf-core/proteinannotator, created with the [nf-core](https:// ### `Added` -- Updated to `nf-test` on GitHub Actions and in the `PULL_REQUEST_TEMPLATE.md` +- [[PR #42](https://github.com/nf-core/proteinannotator/pull/42)] Updated to `nf-test` on GitHub Actions and in the `PULL_REQUEST_TEMPLATE.md` - [[PR #13](https://github.com/nf-core/proteinannotator/pull/13)] Add nf-core seqkit/stats module ### `Fixed`