diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 733fd2db..77e3398d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,36 +1,82 @@ -name: nf-core CI # This workflow runs the pipeline with the minimal test dataset to check that it completes without any syntax errors +name: nf-core CI on: push: branches: - - dev + - "dev" pull_request: + branches: + - "dev" + - "master" release: - types: [published] + types: + - "published" env: NXF_ANSI_LOG: false + NFTEST_VER: "0.7.3" concurrency: - group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}" + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: - test: - name: Run pipeline with assembly test data - # 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/metapep') }}" + define_nxf_versions: + name: Choose nextflow versions to test against depending on target branch + runs-on: ubuntu-latest + outputs: + matrix: ${{ steps.nxf_versions.outputs.matrix }} + steps: + - id: nxf_versions + run: | + if [[ "${{ github.event_name }}" == "pull_request" && "${{ github.base_ref }}" == "dev" && "${{ matrix.NXF_VER }}" != "latest-everything" ]]; then + echo matrix='["latest-everything"]' | tee -a $GITHUB_OUTPUT + else + echo matrix='["latest-everything", "23.04.0"]' | tee -a $GITHUB_OUTPUT + fi + + test_profile_standard: + name: nf-test with standard profiles + needs: define_nxf_versions runs-on: ubuntu-latest strategy: fail-fast: false matrix: - NXF_VER: - - "23.04.0" - - "latest-everything" + NXF_VER: ${{ fromJson(needs.define_nxf_versions.outputs.matrix) }} + tags: + - "test" + - "test_model_information" + - "test_mouse_all_pep_lengths" + - "test_assembly_only" + - "test_bins_only" + - "test_coassembly" + - "test_mhcflurry" + - "test_mhcnuggets_1" + - "test_mhcnuggets_2" + profile: + - "docker" + steps: - name: Check out pipeline code uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + - name: Check out test data + uses: actions/checkout@v3 + with: + repository: nf-core/test-datasets + ref: metapep + path: test-datasets/ + fetch-depth: 1 + + - name: Replace remote paths in samplesheets + run: | + for f in ${{ github.workspace }}/test-datasets/samplesheets/v1.0/*.csv; do + sed -i "s=https://github.com/nf-core/test-datasets/tree/metapep/testdata/=${{ github.workspace }}/test-datasets/=g" $f + echo "========== $f ============" + cat $f + echo "========================================" + done; + - name: Install Nextflow uses: nf-core/setup-nextflow@v1 with: @@ -39,63 +85,92 @@ jobs: - name: Disk space cleanup uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 - - name: Run pipeline with test data + - name: Install nf-test run: | - nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results - - profile: - name: Run additional profile tests - # 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/metapep') }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - tests: [ - "test_model_information", - "test_mouse_all_pep_lengths", - "test_assembly_only", - "test_bins_only", - "test_coassembly", - "test_mhcflurry", - "test_mhcnuggets_1", - "test_mhcnuggets_2", - ] # add further test profiles here, will be run in parallel (but only with one nextflow version) - steps: - - name: Check out pipeline code - uses: actions/checkout@v2 + wget -qO- https://code.askimed.com/install/nf-test | bash -s $NFTEST_VER + sudo mv nf-test /usr/local/bin/ - - name: Install Nextflow + - name: Run nf-test run: | - wget -qO- get.nextflow.io | bash - sudo mv nextflow /usr/local/bin/ + nf-test test --tag ${{ matrix.tags }} --profile ${{ matrix.tags }},${{ matrix.profile }} --junitxml=test.xml - - name: Run pipeline with profile ${{ matrix.tests }} + - name: Output log on failure + if: failure() run: | - nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.tests }},docker --outdir ./results + sudo apt install bat > /dev/null + batcat --decorations=always --color=always ${{ github.workspace }}/.nf-test/tests/*/output/pipeline_info/software_versions.yml - all_profiles: - name: Run all additional profile tests that require ncbi credentials - # Only run on PRs from branches of nf-core/metapep repository or on push if this is the nf-core dev branch (merged PRs) - # (GitHub secrets are not accessible for workflows from forks) - if: ${{ github.event.pull_request.head.repo.full_name == 'nf-core/metapep' || (github.event_name == 'push' && github.repository == 'nf-core/metapep') }} + - name: Publish Test Report + uses: mikepenz/action-junit-report@v3 + if: always() # always run even if the previous step fails + with: + report_paths: "*.xml" + + profile_download: + name: nf-test with profiles needing entrez downloads + needs: define_nxf_versions runs-on: ubuntu-latest strategy: fail-fast: false matrix: - tests: ["test_all", "test_mouse", "test_taxa_only", "test_taxa_specific_assembly"] # add further test profiles here, will be run in parallel (but only with one nextflow version) + NXF_VER: ${{ fromJson(needs.define_nxf_versions.outputs.matrix) }} + tags: + - "test_all" + - "test_mouse" + - "test_taxa_only" + - "test_taxa_specific_assembly" + profile: + - "docker" + steps: - name: Check out pipeline code - uses: actions/checkout@v2 + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4 + + - name: Check out test data + uses: actions/checkout@v3 + with: + repository: nf-core/test-datasets + ref: metapep + path: test-datasets/ + fetch-depth: 1 + + - name: Replace remote paths in samplesheets + run: | + for f in ${{ github.workspace }}/test-datasets/samplesheets/v1.0/*.csv; do + sed -i "s=https://github.com/nf-core/test-datasets/tree/metapep/testdata/=${{ github.workspace }}/test-datasets/=g" $f + echo "========== $f ============" + cat $f + echo "========================================" + done; - name: Install Nextflow + uses: nf-core/setup-nextflow@v1 + with: + version: "${{ matrix.NXF_VER }}" + + - name: Disk space cleanup + uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1 + + - name: Install nf-test run: | - wget -qO- get.nextflow.io | bash - sudo mv nextflow /usr/local/bin/ + wget -qO- https://code.askimed.com/install/nf-test | bash -s $NFTEST_VER + sudo mv nf-test /usr/local/bin/ - - name: Run pipeline with profile ${{ matrix.tests }} + - name: Run nf-test env: NCBI_EMAIL: ${{ secrets.NCBI_EMAIL }} NCBI_KEY: ${{ secrets.NCBI_KEY }} run: | - nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.tests }},docker --ncbi_email "$NCBI_EMAIL" --ncbi_key "$NCBI_KEY" --outdir ./results + nf-test test --tag ${{ matrix.tags }} --profile ${{ matrix.tags }},${{ matrix.profile }} --junitxml=test.xml + + - name: Output log on failure + if: failure() + run: | + sudo apt install bat > /dev/null + batcat --decorations=always --color=always ${{ github.workspace }}/.nf-test/tests/*/output/pipeline_info/software_versions.yml + + - name: Publish Test Report + uses: mikepenz/action-junit-report@v3 + if: always() # always run even if the previous step fails + with: + report_paths: "*.xml" diff --git a/.gitignore b/.gitignore index 5124c9ac..16220a4a 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ results/ testing/ testing* *.pyc +.nf-test/ +results_test/* +.nf-test* diff --git a/.nf-core.yml b/.nf-core.yml index 3805dc81..6078dcf6 100644 --- a/.nf-core.yml +++ b/.nf-core.yml @@ -1 +1,5 @@ repository_type: pipeline +lint: + files_exist: + - conf/igenomes.config + actions_ci: False diff --git a/nf-test.config b/nf-test.config new file mode 100644 index 00000000..a1359d77 --- /dev/null +++ b/nf-test.config @@ -0,0 +1,18 @@ +config { + // location for all nf-tests + testsDir "tests" + + // nf-test directory including temporary files for each test + workDir ".nf-test" + + // location of library folder that is added automatically to the classpath + libDir "tests/pipeline/lib/" + + // location of an optional nextflow.config file specific for executing tests + configFile "tests/nextflow.config" + + // run all test with the defined docker profile from the main nextflow.config + profile "" + +} + diff --git a/tests/nextflow.config b/tests/nextflow.config new file mode 100644 index 00000000..54484af3 --- /dev/null +++ b/tests/nextflow.config @@ -0,0 +1,4 @@ +env { + NCBI_EMAIL = "$NCBI_EMAIL" + NCBI_KEY = "$NCBI_KEY" + } diff --git a/tests/pipeline/test.nf.test b/tests/pipeline/test.nf.test new file mode 100644 index 00000000..f2bf41e8 --- /dev/null +++ b/tests/pipeline/test.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test" + tag "pipeline" + + test("test assembly and bin input") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_all.nf.test b/tests/pipeline/test_all.nf.test new file mode 100644 index 00000000..77126cd5 --- /dev/null +++ b/tests/pipeline/test_all.nf.test @@ -0,0 +1,24 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_all" + tag "pipeline" + + test("test all input path including protein downloads") { + + when { + params { + outdir = "$outputDir" + ncbi_email = "\$NCBI_EMAIL" + ncbi_key = "\$NCBI_KEY" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_assembly_only.nf.test b/tests/pipeline/test_assembly_only.nf.test new file mode 100644 index 00000000..fba50a6e --- /dev/null +++ b/tests/pipeline/test_assembly_only.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_assembly_only" + tag "pipeline" + + test("test assembly input") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_bins_only.nf.test b/tests/pipeline/test_bins_only.nf.test new file mode 100644 index 00000000..e9dea00c --- /dev/null +++ b/tests/pipeline/test_bins_only.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_bins_only" + tag "pipeline" + + test("test bin input") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_coassembly.nf.test b/tests/pipeline/test_coassembly.nf.test new file mode 100644 index 00000000..a97f7ea8 --- /dev/null +++ b/tests/pipeline/test_coassembly.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_coassembly" + tag "pipeline" + + test("test coassembly input") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_mhcflurry.nf.test b/tests/pipeline/test_mhcflurry.nf.test new file mode 100644 index 00000000..0385ded0 --- /dev/null +++ b/tests/pipeline/test_mhcflurry.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_mhcflurry" + tag "pipeline" + + test("test mhcflurry prediction") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_mhcnuggets_1.nf.test b/tests/pipeline/test_mhcnuggets_1.nf.test new file mode 100644 index 00000000..c18f67e4 --- /dev/null +++ b/tests/pipeline/test_mhcnuggets_1.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_mhcnuggets_1" + tag "pipeline" + + test("test mhcnuggets hla type 1 prediction") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_mhcnuggets_2.nf.test b/tests/pipeline/test_mhcnuggets_2.nf.test new file mode 100644 index 00000000..2b6186dd --- /dev/null +++ b/tests/pipeline/test_mhcnuggets_2.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_mhcnuggets_2" + tag "pipeline" + + test("test mhcnuggets hla type 2 prediction") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_model_information.nf.test b/tests/pipeline/test_model_information.nf.test new file mode 100644 index 00000000..d8e7961e --- /dev/null +++ b/tests/pipeline/test_model_information.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_model_information" + tag "pipeline" + + test("test model information subbranch") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_mouse.nf.test b/tests/pipeline/test_mouse.nf.test new file mode 100644 index 00000000..071201ac --- /dev/null +++ b/tests/pipeline/test_mouse.nf.test @@ -0,0 +1,24 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_mouse" + tag "pipeline" + + test("test mouse alleles within download path (allele prediction reduction)") { + + when { + params { + outdir = "$outputDir" + ncbi_email = "\$NCBI_EMAIL" + ncbi_key = "\$NCBI_KEY" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_mouse_all_pep_lengths.nf.test b/tests/pipeline/test_mouse_all_pep_lengths.nf.test new file mode 100644 index 00000000..5e377c41 --- /dev/null +++ b/tests/pipeline/test_mouse_all_pep_lengths.nf.test @@ -0,0 +1,22 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_mouse_all_pep_lengths" + tag "pipeline" + + test("test mouse assembly allowing all peptide lengths") { + + when { + params { + outdir = "$outputDir" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_taxa_only.nf.test b/tests/pipeline/test_taxa_only.nf.test new file mode 100644 index 00000000..d14f3c16 --- /dev/null +++ b/tests/pipeline/test_taxa_only.nf.test @@ -0,0 +1,24 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_taxa_only" + tag "pipeline" + + test("test taxa input") { + + when { + params { + outdir = "$outputDir" + ncbi_email = "\$NCBI_EMAIL" + ncbi_key = "\$NCBI_KEY" + } + } + + then { + assert workflow.success + } + + } + +} diff --git a/tests/pipeline/test_taxa_specific_assembly.nf.test b/tests/pipeline/test_taxa_specific_assembly.nf.test new file mode 100644 index 00000000..dd39e463 --- /dev/null +++ b/tests/pipeline/test_taxa_specific_assembly.nf.test @@ -0,0 +1,24 @@ +nextflow_pipeline { + + name "Test Workflow main.nf" + script "main.nf" + tag "test_taxa_specific_assembly" + tag "pipeline" + + test("test taxa input with assembly id") { + + when { + params { + outdir = "$outputDir" + ncbi_email = "\$NCBI_EMAIL" + ncbi_key = "\$NCBI_KEY" + } + } + + then { + assert workflow.success + } + + } + +}