Skip to content

Commit

Permalink
Merge branch 'nf-test_implementation' into ci_test_branch_nf-core
Browse files Browse the repository at this point in the history
  • Loading branch information
tillenglert committed Apr 25, 2024
2 parents 34aa983 + 618a28b commit 2b1eedc
Show file tree
Hide file tree
Showing 18 changed files with 449 additions and 51 deletions.
177 changes: 126 additions & 51 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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"
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/
results_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_exist:
- conf/igenomes.config
actions_ci: False
18 changes: 18 additions & 0 deletions nf-test.config
Original file line number Diff line number Diff line change
@@ -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 ""

}

4 changes: 4 additions & 0 deletions tests/nextflow.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
env {
NCBI_EMAIL = "$NCBI_EMAIL"
NCBI_KEY = "$NCBI_KEY"
}
22 changes: 22 additions & 0 deletions tests/pipeline/test.nf.test
Original file line number Diff line number Diff line change
@@ -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
}

}

}
24 changes: 24 additions & 0 deletions tests/pipeline/test_all.nf.test
Original file line number Diff line number Diff line change
@@ -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
}

}

}
22 changes: 22 additions & 0 deletions tests/pipeline/test_assembly_only.nf.test
Original file line number Diff line number Diff line change
@@ -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
}

}

}
22 changes: 22 additions & 0 deletions tests/pipeline/test_bins_only.nf.test
Original file line number Diff line number Diff line change
@@ -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
}

}

}
22 changes: 22 additions & 0 deletions tests/pipeline/test_coassembly.nf.test
Original file line number Diff line number Diff line change
@@ -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
}

}

}
Loading

0 comments on commit 2b1eedc

Please sign in to comment.