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

36 add nf test #39

Merged
merged 10 commits into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
77 changes: 77 additions & 0 deletions .github/workflows/nftest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This workflow runs the pipeline with the minimal test dataset to check that it completes without any syntax errors
name: nf-test CI
on:
push:
branches:
- dev
pull_request:
release:
types: [published]
merge_group:
types:
- checks_requested
branches:
- master
- dev

env:
NXF_ANSI_LOG: false
NFTEST_VER: "0.8.1"

concurrency:
group: "${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}"
cancel-in-progress: true

jobs:
test:
name: "NF: ${{ matrix.NXF_VER }}"
if: "${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'fmalmeida/ngs-preprocess') }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
NXF_VER:
- "23.04.0"

steps:
- name: Disk space cleanup
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1

- name: Check out pipeline code
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4

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

- name: Cache nf-test installation
id: cache-software
uses: actions/cache@v3
with:
path: |
/usr/local/bin/nf-test
/home/runner/.nf-test/nf-test.jar
key: ${{ runner.os }}-${{ env.NFTEST_VER }}-nftest

- name: Install nf-test
if: steps.cache-software.outputs.cache-hit != 'true'
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- name: Run nf-test
run: |
nf-test test tests/main.nf.test --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/*/meta/nextflow.log

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: test.xml
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ teste
testing
.vscode/settings.json
docs/_build
*.log
.nf-test/
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

The tracking for changes started in v2.2

## v2.7.1

* [[#36]](https://github.com/fmalmeida/ngs-preprocess/issues/36) - Include nf-tests to the pipeline.
* [[#40]](https://github.com/fmalmeida/ngs-preprocess/issues/40) - Fix a problem when downloading PACBIO data.

## v2.7.0 -- [2024-Apr-30]

* [[#34]](https://github.com/fmalmeida/ngs-preprocess/issues/34) - Included a new tool in the pipeline (`porechop ABI`). Removed `tracedir` parameter. Build new docker image.
Expand Down
2 changes: 1 addition & 1 deletion conf/defaults.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
params {

// Sets output directory
output = "output"
output = null

// inputs from SRA. A file containing on SRA ID per line.
sra_ids = null
Expand Down
34 changes: 17 additions & 17 deletions nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ try {
System.err.println("WARNING: Could not load nf-core/config profiles: ${params.custom_config_base}/nfcore_custom.config")
}

/*
Setting up NF profiles
To use different profiles and executors
please read more at: https://www.nextflow.io/docs/latest/config.html#config-profiles
*/
profiles {

// load profiles
standard { includeConfig 'conf/standard.config' }
conda { includeConfig 'conf/conda.config' }
docker { includeConfig 'conf/docker.config' }
singularity { includeConfig 'conf/singularity.config' }
test { includeConfig 'conf/test.config' }

}

/*


Expand Down Expand Up @@ -66,22 +82,6 @@ report {
file = "${params.output}/pipeline_info/ngs_preprocess_report_${trace_timestamp}.html"
}

/*
Setting up NF profiles
To use different profiles and executors
please read more at: https://www.nextflow.io/docs/latest/config.html#config-profiles
*/
profiles {

// load profiles
standard { includeConfig 'conf/standard.config' }
conda { includeConfig 'conf/conda.config' }
docker { includeConfig 'conf/docker.config' }
singularity { includeConfig 'conf/singularity.config' }
test { includeConfig 'conf/test.config' }

}

/*
Adding manifest
*/
Expand All @@ -92,5 +92,5 @@ manifest {
homePage = "https://github.com/fmalmeida/ngs-preprocess"
mainScript = "main.nf"
nextflowVersion = ">=21.10.0"
version = "2.7.0"
version = "2.7.1"
}
1 change: 0 additions & 1 deletion nextflow_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"properties": {
"output": {
"type": "string",
"default": "output",
"help_text": "Where to place results?",
"fa_icon": "fas fa-folder"
},
Expand Down
8 changes: 8 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
config {

testsDir "tests"
workDir ".nf-test"
configFile "tests/nextflow.config"
profile "docker"

}
39 changes: 39 additions & 0 deletions tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
nextflow_pipeline {

name "Test Workflow main.nf"
script "main.nf"

test("Testing workflow - Should run without fails") {

when {
params {
sra_ids = 'https://github.com/fmalmeida/test_datasets/raw/main/sra_ids.txt'
output = "${outputDir}/test_output"
max_cpus = 2
max_memory = '6.GB'
max_time = '6.h'
}
}

then {

assertAll(
// All good?
{assert workflow.success},

// All there?
{assert path("${outputDir}/test_output").list().size() == 5},
{assert path("${outputDir}/test_output/preprocessing_outputs").list().size() == 3},

// Check if files are the same
{assert snapshot(
workflow.trace,
path( "${outputDir}/test_output/final_output" )
).match()}
)

}

}

}
29 changes: 29 additions & 0 deletions tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"Testing workflow - Should run without fails": {
"content": [
{
"tasksFailed": 0,
"tasksCount": 16,
"tasksSucceeded": 16
},
[
[
"SRR19901041.filtered.fq.gz:md5,1d7a8e18db3b1f7ac0bfc1f5cf1daddf"
],
[
"ERR7339227.filtered.fq.gz:md5,d41d8cd98f00b204e9800998ecf8427e",
"SRR9641620.filtered.fq.gz:md5,f6658663be49766459b123efa690cc42"
],
[
"ERR9850226_R1.preprocessed.fq.gz:md5,69f8bd550fbf99d81f4a110734f4803a",
"ERR9850226_R2.preprocessed.fq.gz:md5,7543436f1614ae814337a9b123d26376"
]
]
],
"meta": {
"nf-test": "0.8.4",
"nextflow": "23.10.1"
},
"timestamp": "2024-05-10T15:44:14.430345179"
}
}
5 changes: 5 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
========================================================================================
Nextflow config file for running tests
========================================================================================
*/
Loading