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

nf-test init #73

Merged
merged 8 commits into from
Nov 24, 2022
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
88 changes: 73 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,98 @@
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:
pull_request:
branches:
- dev
pull_request:
release:
types: [published]

env:
NXF_ANSI_LOG: false

# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
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/demultiplex') }}"
changes:
name: Check for changes
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'modules' output variable
tags: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v2

- uses: dorny/paths-filter@v2
id: filter
with:
filters: "tests/config/tags.yml"

test_changes:
name: ${{ matrix.tags }} ${{ matrix.component }} ${{ matrix.profile }} ${{ matrix.NXF_VER }}
runs-on: ubuntu-20.04
needs: changes
if: needs.changes.outputs.tags != '[]'
strategy:
fail-fast: false
matrix:
NXF_VER:
- "21.10.3"
- "latest-everything"
test:
- "test_bclconvert"
- "test_bcl2fastq"
- "test_bases2fastq"
tags: ["${{ fromJson(needs.changes.outputs.tags) }}"]
profile: ["docker"] # TODO Add singularity/conda
component: ["pipeline"] # TODO There aren't any subworkflows or modules tests YET
exclude:
- NXF_VER: "latest-everything"
profile: "conda"
steps:
- name: Check out pipeline code
uses: actions/checkout@v2

- name: Install Nextflow
uses: nf-core/setup-nextflow@v1
- uses: actions/cache@v2
with:
version: "${{ matrix.NXF_VER }}"
path: /usr/local/bin/
key: ${{ runner.os }}
restore-keys: |
${{ runner.os }}-nextflow-

- name: Run pipeline with test data
- name: Install Nextflow
env:
CAPSULE_LOG: none
run: |
nextflow run ${GITHUB_WORKSPACE} -profile ${{ matrix.test }},docker --outdir ./results
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/

- name: Install nf-test
run: |
wget -qO- https://code.askimed.com/install/nf-test | bash
sudo mv nf-test /usr/local/bin/

- name: Set up Singularity
if: matrix.profile == 'singularity'
uses: eWaterCycle/setup-singularity@v5
with:
singularity-version: 3.7.1

- name: Set up miniconda
if: matrix.profile == 'conda'
uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
channels: conda-forge,bioconda,defaults
python-version: ${{ matrix.python-version }}

- name: Conda clean
if: matrix.profile == 'conda'
run: conda clean -a

- name: Run nf-test
run: nf-test test --profile=test,${{ matrix.profile }} tests/${{ matrix.component }}/${{ matrix.tags }}/*.nf.test --junitxml=${{ matrix.tags }}.xml

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: "${{ matrix.tags }}.xml"
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ results/
testing/
testing*
*.pyc
.nf-test/
2 changes: 2 additions & 0 deletions .nf-core.yml
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
repository_type: pipeline
lint:
actions_ci: False
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- [#63](https://github.com/nf-core/demultiplex/pull/63) Replace fastqc with falco for speedier QC, fixes Replace fastqc with falco #62
- [#64](https://github.com/nf-core/demultiplex/pull/64) Add subway map by @nvnieuwk
- [#70](https://github.com/nf-core/demultiplex/pull/70) Make tools and trimming optional
- [#71](https://github.com/nf-core/demultiplex/pull/71) Add nf-test

### `Fixed`

Expand All @@ -24,9 +25,9 @@ Initial release of nf-core/demultiplex, created with the [nf-core](https://nf-co

### `Added`

- [#38](https://github.com/nf-core/demultiplex/pull/38) - Add FastP
- [#39](https://github.com/nf-core/demultiplex/pull/39) - Add FastQC
- [#51](https://github.com/nf-core/demultiplex/pull/51) - Add bases2fastq
- [#38](https://github.com/nf-core/demultiplex/pull/38) Add FastP
- [#39](https://github.com/nf-core/demultiplex/pull/39) Add FastQC
- [#51](https://github.com/nf-core/demultiplex/pull/51) Add bases2fastq

### `Fixed`

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[![run with docker](https://img.shields.io/badge/run%20with-docker-0db7ed?labelColor=000000&logo=docker)](https://www.docker.com/)
[![run with singularity](https://img.shields.io/badge/run%20with-singularity-1d355c.svg?labelColor=000000)](https://sylabs.io/docs/)
[![Launch on Nextflow Tower](https://img.shields.io/badge/Launch%20%F0%9F%9A%80-Nextflow%20Tower-%234256e7)](https://tower.nf/launch?pipeline=https://github.com/nf-core/demultiplex)
[![nf-test](https://img.shields.io/badge/tested_with-nf--test-337ab7.svg)](https://github.com/askimed/nf-test)

[![Get help on Slack](http://img.shields.io/badge/slack-nf--core%20%23demultiplex-4A154B?labelColor=000000&logo=slack)](https://nfcore.slack.com/channels/demultiplex)[![Follow on Twitter](http://img.shields.io/badge/twitter-%40nf__core-1DA1F2?labelColor=000000&logo=twitter)](https://twitter.com/nf_core)[![Watch on YouTube](http://img.shields.io/badge/youtube-nf--core-FF0000?labelColor=000000&logo=youtube)](https://www.youtube.com/c/nf-core)

Expand Down
62 changes: 34 additions & 28 deletions conf/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,39 @@ process {
"--force",
"--first-tile-only true"
].join(" ").trim()}
}
publishDir = [
[
// Gather and write InterOp files
path: { "${params.outdir}/${meta.id}/InterOp" },
mode: params.publish_dir_mode,
pattern: "**.bin",
saveAs: {filename -> filename.split("/")[-1] }
],
[
// Fetch RunInfo.xml
path: { "${params.outdir}/${meta.id}" },
mode: params.publish_dir_mode,
pattern: "RunInfo.xml",
overwrite: true,
saveAs: {filename -> filename.split("/")[-1] }
],
[
// Gather and write Reports
path: { meta.lane ? "${params.outdir}/${meta.id}/L00${meta.lane}" : "${params.outdir}/${meta.id}" },
mode: params.publish_dir_mode,
pattern: "Reports",
saveAs: {filename -> filename.split("/")[-1] }
],
[
path: { "${params.outdir}/${meta.id}" },
pattern: "**.fastq.gz",
publishDir = [
[
// Gather and write InterOp files
path: { "${params.outdir}/${meta.id}/InterOp" },
mode: params.publish_dir_mode,
pattern: "**.bin",
saveAs: {filename -> filename.split("/")[-1] }
],
[
// Fetch RunInfo.xml
path: { "${params.outdir}/${meta.id}" },
mode: params.publish_dir_mode,
pattern: "RunInfo.xml",
overwrite: true,
saveAs: {filename -> filename.split("/")[-1] }
],
[
// Gather and write Reports
path: { meta.lane ? "${params.outdir}/${meta.id}/L00${meta.lane}" : "${params.outdir}/${meta.id}" },
mode: params.publish_dir_mode,
pattern: "Reports",
saveAs: {filename -> filename.split("/")[-1] }
],
[
path: { "${params.outdir}/${meta.id}" },
pattern: "**.fastq.gz",
]
]
]
}

withName: BCL2FASTQ {
ext.args = {[
"--tiles s_1_1101",
].join(" ").trim()}
}
}
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 "nextflow.config"
profile "test"

}
10 changes: 10 additions & 0 deletions tests/config/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default:
- bin/**
- conf/**
- lib/**
- modules/**
- subworkflows/**
- tests/**
- workflows/**
- nextflow.config
- main.nf
38 changes: 38 additions & 0 deletions tests/pipeline/default/bases2fastq.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
nextflow_pipeline {

name "Test Bases2Fastq"
script "main.nf"

test("Should run without failures") {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we keep the naming conventions from pytest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sateeshperi and I thought it would be good to follow whatever nf-test generate spit out. But I'm guessing beyond the basic tests the naming will be out the window, and I don't want people to get caught up in following a convention when they could have an excellent name for a specific test.

Something we can circle back around to, though!


when {
params {
input = "$baseDir/assets/inputs/b2fq-samplesheet.csv"
demultiplexer = 'bases2fastq'
outdir = "$outputDir"
}
}

then {
assert workflow.success
assert workflow.trace.succeeded().size() == 6

assert snapshot(
path("$outputDir/sim-data/DefaultSample_R1.fastq.gz.md5"),
path("$outputDir/sim-data/DefaultSample_R2.fastq.gz.md5"),
path("$outputDir/sim-data/Metrics.csv"),
path("$outputDir/sim-data/RunManifest.json"),
path("$outputDir/sim-data/UnassignedSequences.csv"),

path("$outputDir/sim-data/Samples/DefaultSample/DefaultSample_R1.fastq.gz"),
path("$outputDir/sim-data/Samples/DefaultSample/DefaultSample_R2.fastq.gz"),
).match()

assert new File("$outputDir/sim-data/Bases2Fastq-Sim_QC.html").exists()
assert new File("$outputDir/sim-data/RunStats.json").exists()
assert new File("$outputDir/sim-data/Samples/DefaultSample/DefaultSample_stats.json").exists()
}

}

}
14 changes: 14 additions & 0 deletions tests/pipeline/default/bases2fastq.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"Should run without failures": {
"content": [
"DefaultSample_R1.fastq.gz.md5:md5,5d8bc31e54f78babafb9a860be2ff52a",
"DefaultSample_R2.fastq.gz.md5:md5,1b71d1475ec7fb7e7ca16b7958990622",
"Metrics.csv:md5,3213ad7bdf66f33476cb589b4d608948",
"RunManifest.json:md5,d4ecdb19e5fbcffab3e6e770c34023fb",
"UnassignedSequences.csv:md5,11c1693830ce941b8cfb8d2431a59097",
"DefaultSample_R1.fastq.gz:md5,77b68ec94323741d1bddc03a7a428fa9",
"DefaultSample_R2.fastq.gz:md5,ecd4ed53e10207582bbbc29383080b57"
],
"timestamp": "2022-11-24T01:47:50+0000"
}
}
30 changes: 30 additions & 0 deletions tests/pipeline/default/bcl2fastq.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
nextflow_pipeline {

name "Test bcl2fastq"
script "main.nf"

test("Should run without failures") {

when {
params {
outdir = "$outputDir"
input = "${baseDir}/assets/inputs/flowcell_input.csv"
demultiplexer = 'bcl2fastq'
}
}

then {
assert workflow.success
assert workflow.trace.succeeded().size() == 5

assert snapshot(
path("$outputDir/220422_M11111_0222_000000000-K9H97/Sample1_S1_L001_R1_001.fastq.gz.md5"),

path("$outputDir/bcl2fastq/Sample1_S1_L001_R1_001.fastq.gz"),
path("$outputDir/bcl2fastq/Stats").list(),
).match()
}

}

}
17 changes: 17 additions & 0 deletions tests/pipeline/default/bcl2fastq.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"Should run without failures": {
"content": [
"Sample1_S1_L001_R1_001.fastq.gz.md5:md5,2ffef70ffda3328c3c6607bf14ca50c3",
"Sample1_S1_L001_R1_001.fastq.gz:md5,e92fce7b86c6447b053d72c5cb4be89c",
[
"AdapterTrimming.txt:md5,48ed2b914b1246c0b5d8667525550946",
"ConversionStats.xml:md5,8fe0f57f3f5d256a0762dba75ac62d05",
"DemultiplexingStats.xml:md5,2047ff18f5b9107c084de06e9ff943ad",
"DemuxSummaryF1L1.txt:md5,03e5fd0c1e3079c5f8c7b4d0501b37ff",
"FastqSummaryF1L1.txt:md5,0c6f2d87ee183b84d1051cde9a5643d1",
"Stats.json:md5,8e5f038b8aa9e465599d3575f930e604"
]
],
"timestamp": "2022-11-24T01:58:20+0000"
}
}
30 changes: 30 additions & 0 deletions tests/pipeline/default/bclconvert.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
nextflow_pipeline {

name "Test bclconvert"
script "main.nf"

test("Should run without failures") {

when {
params {
input = "$baseDir/assets/inputs/flowcell_input.csv"
demultiplexer = 'bclconvert'
outdir = "$outputDir"
}
}

then {
assert workflow.success
assert workflow.trace.succeeded().size() == 5

assert snapshot(
path("$outputDir/220422_M11111_0222_000000000-K9H97/Sample1_S1_L001_R1_001.fastq.gz"),
path("$outputDir/220422_M11111_0222_000000000-K9H97/Sample1_S1_L001_R1_001.fastq.gz.md5"),
path("$outputDir/220422_M11111_0222_000000000-K9H97/Undetermined_S0_L001_R1_001.fastq.gz"),
path("$outputDir/220422_M11111_0222_000000000-K9H97/L001/Reports/").list(),
).match()
}

}

}
Loading