Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/nf tests #309

Open
wants to merge 17 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.config linguist-language=nextflow
*.nf.test linguist-language=nextflow
tests/**/*nf.test.snap linguist-generated
modules/nf-core/** linguist-generated
subworkflows/nf-core/** linguist-generated
170 changes: 66 additions & 104 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,38 +1,58 @@
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
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 }}"
cancel-in-progress: true

jobs:
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", "22.10.1"]' | tee -a $GITHUB_OUTPUT
fi

test:
name: Run pipeline with 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/taxprofiler') }}"
name: nf-test
needs: define_nxf_versions
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
NXF_VER:
- "22.10.1"
- "latest-everything"
parameters:
- "--preprocessing_qc_tool falco"
- "--shortread_qc_tool fastp"
- "--shortread_qc_tool adapterremoval"
- "--shortread_complexityfilter_tool bbduk"
- "--shortread_complexityfilter_tool prinseqplusplus"
NXF_VER: ${{ fromJson(needs.define_nxf_versions.outputs.matrix) }}
components:
- "tests/pipeline/test.nf.test --profile test"
- "tests/pipeline/test_with_complexityfilter_fastp.nf.test --profile test"
- "tests/pipeline/test_with_complexityfilter_prinseqpluslplus.nf.test --profile test"
- "tests/pipeline/test_with_preprocessingqc_falco.nf.test --profile test"
- "tests/pipeline/test_with_shortreadqc_adapterremoval.nf.test --profile test"
- "tests/pipeline/krakenuniq.nf.test --profile test_krakenuniq"
- "tests/pipeline/malt.nf.test --profile test_nothing"
profile:
- "docker"

steps:
- name: Check out pipeline code
Expand All @@ -43,46 +63,50 @@ jobs:
with:
version: "${{ matrix.NXF_VER }}"

- name: Show current locale
run: locale
- name: Install nf-test
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash -s $NFTEST_VER
sudo mv nf-test /usr/local/bin/

- name: Run nf-test default
run: |
nf-test test ${{ matrix.components }},${{ matrix.profile }} --junitxml=test.xml

- name: Set UTF-8 enabled locale
- name: Output log on failure
if: failure()
run: |
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
sudo apt install bat > /dev/null
batcat --decorations=always --color=always ${{ github.workspace }}/.nf-test/tests/*/output/pipeline_info/software_versions.yml

- name: Run pipeline with test data
uses: Wandalen/[email protected]
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
command: nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }}
attempt_limit: 3
report_paths: "*.xml"

motus:
name: Test mOTUs with workflow parameters
if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/taxprofiler') }}
test_motus:
name: nf-test motus
needs: define_nxf_versions
runs-on: ubuntu-latest
strategy:
matrix:
NXF_VER:
- "22.10.1"
- "latest-everything"
NXF_VER: ${{ fromJson(needs.define_nxf_versions.outputs.matrix) }}
profile:
- "docker"

steps:
- name: Check out pipeline code
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: "${{ matrix.NXF_VER }}"

- name: Show current locale
run: locale

- name: Set UTF-8 enabled locale
- name: Install nf-test
run: |
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
wget -qO- https://code.askimed.com/install/nf-test | bash -s $NFTEST_VER
sudo mv nf-test /usr/local/bin/

- name: Prepare the database
run: |
Expand All @@ -91,74 +115,12 @@ jobs:
echo 'tool,db_name,db_params,db_path' > 'database_motus.csv'
echo 'motus,db_mOTU,,db_mOTU' >> 'database_motus.csv'

- name: Run pipeline with test data
uses: Wandalen/[email protected]
with:
command: nextflow run ${GITHUB_WORKSPACE} -profile test_motus,docker --outdir ./results --databases ./database_motus.csv
attempt_limit: 3

krakenuniq:
name: Test KrakenUniq with workflow parameters
if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/taxprofiler') }}
runs-on: ubuntu-latest
strategy:
matrix:
NXF_VER:
- "22.10.1"
- "latest-everything"

steps:
- name: Check out pipeline code
uses: actions/checkout@v2

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: "${{ matrix.NXF_VER }}"

- name: Show current locale
run: locale

- name: Set UTF-8 enabled locale
run: |
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8

- name: Run pipeline with test data
uses: Wandalen/[email protected]
with:
command: nextflow run ${GITHUB_WORKSPACE} -profile test_krakenuniq,docker --outdir ./results
attempt_limit: 3

malt:
name: Test MALT with workflow parameters
if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/taxprofiler') }}
runs-on: ubuntu-latest
strategy:
matrix:
NXF_VER:
- "22.10.1"
- "latest-everything"

steps:
- name: Check out pipeline code
uses: actions/checkout@v2

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
with:
version: "${{ matrix.NXF_VER }}"

- name: Show current locale
run: locale

- name: Set UTF-8 enabled locale
- name: Run nf-test motus
run: |
sudo locale-gen en_US.UTF-8
sudo update-locale LANG=en_US.UTF-8
nf-test test ${{ matrix.profile }} --profile test_motus,${{ matrix.profile }} --junitxml=test.xml
sateeshperi marked this conversation as resolved.
Show resolved Hide resolved

- name: Run pipeline with test data
uses: Wandalen/[email protected]
- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
command: nextflow run ${GITHUB_WORKSPACE} -profile test_nothing,docker --run_malt --input 'https://github.com/nf-core/test-datasets/raw/taxprofiler/samplesheet_shortreadsonly.csv' --outdir ./results
attempt_limit: 3
report_paths: "*.xml"
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ results/
testing/
testing*
*.pyc
.nf-test/
nf-test
4 changes: 4 additions & 0 deletions .nf-core.yml
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
repository_type: pipeline
lint:
files_unchanged:
- .gitattributes
actions_ci: False
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### `Added`

- [#309](https://github.com/nf-core/taxprofiler/pull/309) Implemented nf-tests for existing CI tests (added by @sateeshperi)
- [#276](https://github.com/nf-core/taxprofiler/pull/276) Implemented batching in the KrakenUniq samples processing. (added by @Midnighter)
- [#272](https://github.com/nf-core/taxprofiler/pull/272) Add saving of final 'analysis-ready-reads' to dedicated directory. (❤️ to @alexhbnr for reporting, added by @jfy133)
- [#303](https://github.com/nf-core/taxprofiler/pull/303) Add support for taxpasta profile standardisation in single sample pipeline runs (❤️ to @artur-matysik for reporting, added by @jfy133)
Expand Down
16 changes: 16 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 "nextflow.config"

// run all test with the defined docker profile from the main nextflow.config
profile ""
}
50 changes: 50 additions & 0 deletions tests/pipeline/krakenuniq.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
nextflow_pipeline {

name "Test Workflow main.nf"
script "main.nf"
tag "test_krakenuniq"
tag "krakenuniq"
tag "pipeline"

test("Kraken Uniq") {

when {
params {
outdir = "$outputDir"
}
}

then {
assertAll(
{ assert workflow.success },
{ assert snapshot(UTILS.removeNextflowVersion("$outputDir")).match("software_versions") },
{ assert new File("$outputDir/bbduk/2612_ERR5766176_B.bbduk.log").exists() },
{ assert new File("$outputDir/bbduk/2612_ERR5766176.bbduk.log").exists() },
{ assert new File("$outputDir/bbduk/2612_ERR5766180.bbduk.log").exists() },
{ assert new File("$outputDir/bbduk/2613_ERR5766181.bbduk.log").exists() },
{ assert snapshot(path("$outputDir/bowtie2/align/").list()).match("bowtie2/align/") },
{ assert snapshot(path("$outputDir/fastp/2612_ERR5766176_B.fastp.json"),
path("$outputDir/fastp/2612_ERR5766176.fastp.json"),
path("$outputDir/fastp/2612_ERR5766180.fastp.json"),
path("$outputDir/fastp/2613_ERR5766181.fastp.json")).match("fastp") },
{ assert snapshot(path("$outputDir/filtlong/").list()).match("filtlong") },
{ assert snapshot(UTILS.filterLines("$outputDir/krakenuniq/db6/2612.krakenuniq.report.txt", 1),
UTILS.filterLines("$outputDir/krakenuniq/db6/2613_ERR5766181.krakenuniq.report.txt", 1),
UTILS.filterLines("$outputDir/krakenuniq/db6/ERR3201952.krakenuniq.report.txt", 1),
UTILS.filterLines("$outputDir/krakenuniq/db6/ERX5474930_ERR5766174_1.krakenuniq.report.txt", 1)).match("krakenuniq") },
{ assert snapshot(path("$outputDir/multiqc/multiqc_data/bbduk.txt"),
path("$outputDir/multiqc/multiqc_data/filtlong.txt"),
path("$outputDir/multiqc/multiqc_data/multiqc_bowtie2.txt"),
path("$outputDir/multiqc/multiqc_data/multiqc_fastp.txt"),
path("$outputDir/multiqc/multiqc_data/multiqc_fastqc_1.txt"),
path("$outputDir/multiqc/multiqc_data/multiqc_samtools_stats.txt"),
path("$outputDir/multiqc/multiqc_data/porechop.txt")).match("multiqc") },
{ assert snapshot(UTILS.filterLines("$outputDir/porechop/ERR3201952_ERR3201952.log", -3)).match("porechop") },
{ assert snapshot(path("$outputDir/samtools/stats/").list()).match("samtools/stats/") },
{ assert new File("$outputDir/taxpasta/krakenuniq_db6.tsv").exists() }
)
}

}

}
75 changes: 75 additions & 0 deletions tests/pipeline/krakenuniq.nf.test.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading