Skip to content

Commit

Permalink
Merge pull request #201 from nf-core/nf-test
Browse files Browse the repository at this point in the history
nf-test POC
  • Loading branch information
drpatelh authored Oct 8, 2023
2 parents 8114abc + 56e5143 commit 9d1052d
Show file tree
Hide file tree
Showing 36 changed files with 1,351 additions and 30 deletions.
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
71 changes: 71 additions & 0 deletions .github/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# local modules
multiqc_mappings_config:
- modules/local/multiqc_mappings_config/**
sra_fastq_ftp:
- modules/local/sra_fastq_ftp/**
sra_ids_to_runinfo:
- modules/local/sra_ids_to_runinfo/**
sra_merge_samplesheet:
- modules/local/sra_merge_samplesheet/**
sra_runinfo_to_ftp:
- modules/local/sra_runinfo_to_ftp/**
sra_to_samplesheet:
- modules/local/sra_to_samplesheet/**

# workflow: sra
sra_custom_ena_metadata_fields:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_default_parameters:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_force_sratools_download:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_nf_core_pipeline_atacseq:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_nf_core_pipeline_rnaseq:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_nf_core_pipeline_taxprofiler:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_nf_core_pipeline_viralrecon:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
sra_skip_fastq_download:
- modules/local/sra_ids_to_runinfo/**
- modules/local/sra_runinfo_to_ftp/**
- modules/local/sra_fastq_ftp/**
- modules/local/sra_to_samplesheet/**
- modules/local/sra_merge_samplesheet/**
- workflows/sra/**
91 changes: 62 additions & 29 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,67 @@
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:
pull_request:
release:
types: [published]
merge_group:
types:
- checks_requested
branches:
- master
- dev
- refactor
- nf-test

env:
NXF_ANSI_LOG: false
NFTEST_VER: "0.8.0"

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

jobs:
changes:
name: Check for changes
runs-on: ubuntu-latest
outputs:
# Expose matched filters as job 'tags' output variable
tags: ${{ steps.filter.outputs.changes }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: filter
with:
filters: ".github/tags.yml"

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:
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/fetchngs') }}"
name: ${{ matrix.tags }} ${{ matrix.profile }} NF ${{ matrix.NXF_VER }}
needs: [changes, define_nxf_versions]
if: needs.changes.outputs.tags != '[]'
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: ["${{ fromJson(needs.changes.outputs.tags) }}"]
profile:
- "docker"

steps:
- name: Check out pipeline code
uses: actions/checkout@v3
Expand All @@ -32,29 +71,23 @@ jobs:
with:
version: "${{ matrix.NXF_VER }}"

- name: Run pipeline with test data
- name: Install nf-test
run: |
nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results
wget -qO- https://code.askimed.com/install/nf-test | bash -s $NFTEST_VER
sudo mv nf-test /usr/local/bin/
parameters:
name: Test workflow parameters
if: ${{ github.event_name != 'push' || (github.event_name == 'push' && github.repository == 'nf-core/fetchngs') }}
runs-on: ubuntu-latest
strategy:
matrix:
parameters:
- "--nf_core_pipeline rnaseq"
- "--ena_metadata_fields run_accession,experiment_accession,library_layout,fastq_ftp,fastq_md5 --sample_mapping_fields run_accession,library_layout"
- "--skip_fastq_download"
- "--force_sratools_download"
steps:
- name: Check out pipeline code
uses: actions/checkout@v2

- name: Install Nextflow
- name: Run nf-test
run: |
wget -qO- get.nextflow.io | bash
sudo mv nextflow /usr/local/bin/
- name: Run pipeline with various parameters
nf-test test --tag ${{ matrix.tags }} --profile "test,${{ matrix.profile }}" --junitxml=test.xml
- name: Output log on failure
if: failure()
run: |
nextflow run ${GITHUB_WORKSPACE} -profile test,docker --outdir ./results ${{ matrix.parameters }}
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ results/
testing/
testing*
*.pyc
.nf-test/
nf-test
.nf-test.log
1 change: 1 addition & 0 deletions .nf-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ lint:
files_unchanged:
- assets/sendmail_template.txt
- lib/NfcoreTemplate.groovy
- .gitattributes
36 changes: 36 additions & 0 deletions conf/test_data.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
params {
// Base directory for test data
test_data_base = "https://raw.githubusercontent.com/nf-core/test-datasets/fetchngs"

merge_samplesheet_ids = [ "DRX024467_DRR026872", "SRX11047067_SRR14709033", "SRX9504942_SRR13055517", "DRX026011_DRR028935", "SRX17709227_SRR21711856", "SRX9504942_SRR13055518", "ERX1188904_ERR1109373", "SRX17709228_SRR21711855", "SRX9504942_SRR13055519", "ERX1234253_ERR1160846", "SRX6725035_SRR9984183", "SRX9504942_SRR13055520", "SRX10940790_SRR14593545", "SRX9315476_SRR12848126", "SRX9626017_SRR13191702" ]

def merge_samplesheet_url = "${params.test_data_base}/modules/local/sra_merge_samplesheet/samplesheets/"
def merge_mappings_url = "${params.test_data_base}/modules/local/sra_merge_samplesheet/mappings/"
def merge_samplesheet_urls = []
def merge_mappings_urls = []

merge_samplesheet_ids.each { id ->
merge_samplesheet_urls += "${merge_samplesheet_url}${id}.samplesheet.csv"
merge_mappings_urls += "${merge_mappings_url}/${id}.mappings.csv"
}

fastq_ftp_ids = ["SRR13191702"]
def fastq_ftp_url = "ftp.sra.ebi.ac.uk/vol1/fastq/SRR131/002/SRR13191702/"
def fastq_ftp_urls = []

fastq_ftp_ids.each { id ->
fastq_ftp_urls += "${fastq_ftp_url}${id}_1.fastq.gz"
fastq_ftp_urls += "${fastq_ftp_url}${id}_2.fastq.gz"
}

test_data {
'modules_local' {
multiqc_mappings_config = "${params.test_data_base}/modules/local/multiqc_mappings_config/SRX9626017_SRR13191702.mappings.csv"
sra_merge_samplesheet_samplesheets = merge_samplesheet_urls
sra_merge_samplesheet_mappings = merge_mappings_urls
sra_to_samplesheet = "${params.test_data_base}/modules/local/sra_to_samplesheet/SRX9626017_SRR13191702.mappings.csv"
sra_fastq_ftp = fastq_ftp_urls
sra_runinfo_to_ftp = "${params.test_data_base}/modules/local/sra_runinfo_to_ftp/SRR13191702.runinfo.tsv"
}
}
}
31 changes: 31 additions & 0 deletions modules/local/multiqc_mappings_config/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
nextflow_process {

name "Test process: MULTIQC_MAPPINGS_CONFIG"
script "modules/local/multiqc_mappings_config/main.nf"
process "MULTIQC_MAPPINGS_CONFIG"
tag "modules"
tag "modules_local"
tag "multiqc_mappings_config"

test("Should run without failures") {

when {
params {
outdir = "$outputDir"
}

process {
"""
input[0] = file(params.test_data['modules_local']['multiqc_mappings_config'], checkIfExists: true)
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
27 changes: 27 additions & 0 deletions modules/local/multiqc_mappings_config/tests/main.nf.test.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"Should run without failures": {
"content": [
{
"0": [
[
"multiqc_config.yml:md5,7f3cb10fff83ba9eb3e8fa6862d1290a",
"versions.yml:md5,dd4c66f0551d15510b36bb2e2b2fdd73"
]
],
"1": [
"versions.yml:md5,dd4c66f0551d15510b36bb2e2b2fdd73"
],
"versions": [
"versions.yml:md5,dd4c66f0551d15510b36bb2e2b2fdd73"
],
"yml": [
[
"multiqc_config.yml:md5,7f3cb10fff83ba9eb3e8fa6862d1290a",
"versions.yml:md5,dd4c66f0551d15510b36bb2e2b2fdd73"
]
]
}
],
"timestamp": "2023-09-22T10:58:18.132284"
}
}
34 changes: 34 additions & 0 deletions modules/local/sra_fastq_ftp/tests/main.nf.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
nextflow_process {

name "Test process: SRA_FASTQ_FTP"
script "modules/local/sra_fastq_ftp/main.nf"
process "SRA_FASTQ_FTP"
tag "modules"
tag "modules_local"
tag "sra_fastq_ftp"

test("Should run without failures") {

when {
params {
outdir = "$outputDir"
}

process {
"""
input[0] = [
[ id:'SRX9626017_SRR13191702', single_end:false, md5_1: '89c5be920021a035084d8aeb74f32df7', md5_2: '56271be38a80db78ef3bdfc5d9909b98' ], // meta map
params.test_data['modules_local']['sra_fastq_ftp']
]
"""
}
}

then {
assertAll(
{ assert process.success },
{ assert snapshot(process.out).match() }
)
}
}
}
Loading

0 comments on commit 9d1052d

Please sign in to comment.