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

Add an nf-test CI #1288

Merged
merged 14 commits into from
Oct 17, 2023
139 changes: 131 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,34 +11,40 @@ on:
- master
- dev

env:
NXF_ANSI_LOG: false
NFTEST_VER: "0.8.1"

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

jobs:
changes:
name: Check for changes
pytest-changes:
name: Check for changes (pytest)
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

- uses: frouioui/paths-filter@main
id: filter
with:
filters: "tests/config/tags.yml"
token: ""

test:
pytest:
name: ${{ matrix.tags }} ${{ matrix.profile }} NF ${{ matrix.NXF_VER }}
runs-on: ubuntu-latest
needs: changes
if: needs.changes.outputs.tags != '[]'
needs: pytest-changes
if: needs.pytest-changes.outputs.tags != '[]'
strategy:
fail-fast: false
matrix:
tags: ["${{ fromJson(needs.changes.outputs.tags) }}"]
tags: ["${{ fromJson(needs.pytest-changes.outputs.tags) }}"]
profile: ["docker"]
# profile: ["docker", "singularity", "conda"]
TEST_DATA_BASE:
Expand All @@ -50,6 +56,7 @@ jobs:
NXF_ANSI_LOG: false
TEST_DATA_BASE: "${{ github.workspace }}/test-datasets"
SENTIEON_LICENSE_BASE64: ${{ secrets.SENTIEON_LICENSE_BASE64 }}

steps:
- name: Check out pipeline code
uses: actions/checkout@v3
Expand Down Expand Up @@ -154,10 +161,126 @@ jobs:
!/home/runner/pytest_workflow_*/*/work/conda
!/home/runner/pytest_workflow_*/*/work/singularity

nftest-changes:
name: Check for changes (nf-test)
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.filter.outputs.changes }}

steps:
- uses: actions/checkout@v3

- name: Combine all tags.yml files
id: get_tags
run: find . -name "tags.yml" -not -path "./.github/*" -exec cat {} + > .github/tags.yml

- name: debug
run: cat .github/tags.yml

- uses: frouioui/paths-filter@main
id: filter
with:
filters: ".github/tags.yml"
token: ""

nftest:
name: ${{ matrix.tags }} ${{ matrix.profile }} NF ${{ matrix.NXF_VER }}
runs-on: ubuntu-latest
needs: nftest-changes
if: needs.nftest-changes.outputs.tags != '[]'
strategy:
fail-fast: false
matrix:
tags: ["${{ fromJson(needs.nftest-changes.outputs.tags) }}"]
profile: ["docker"]
# profile: ["docker", "singularity", "conda"]
TEST_DATA_BASE:
- "test-datasets/data"
NXF_VER:
- "23.04.0"
- "latest-everything"
env:
NXF_ANSI_LOG: false
TEST_DATA_BASE: "${{ github.workspace }}/test-datasets"
SENTIEON_LICENSE_BASE64: ${{ secrets.SENTIEON_LICENSE_BASE64 }}

steps:
- uses: actions/checkout@v3

- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Setup Nextflow
uses: nf-core/setup-nextflow@v1

- 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: Setup apptainer
if: matrix.profile == 'singularity'
uses: eWaterCycle/setup-apptainer@main

- name: Set up Singularity
if: matrix.profile == 'singularity'
run: |
mkdir -p $NXF_SINGULARITY_CACHEDIR
mkdir -p $NXF_SINGULARITY_LIBRARYDIR

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

- name: Conda setup
run: |
conda clean -a
conda install -n base conda-libmamba-solver
conda config --set solver libmamba
echo $(realpath $CONDA)/condabin >> $GITHUB_PATH
echo $(realpath python) >> $GITHUB_PATH

# Set up secrets
- name: Set up nextflow secrets
if: env.SENTIEON_LICENSE_BASE64 != null
run: |
nextflow secrets set SENTIEON_LICENSE_BASE64 ${{ secrets.SENTIEON_LICENSE_BASE64 }}
nextflow secrets set SENTIEON_AUTH_MECH_BASE64 ${{ secrets.SENTIEON_AUTH_MECH_BASE64 }}
SENTIEON_ENCRYPTION_KEY=$(echo -n "${{ secrets.ENCRYPTION_KEY_BASE64 }}" | base64 -d)
SENTIEON_LICENSE_MESSAGE=$(echo -n "${{ secrets.LICENSE_MESSAGE_BASE64 }}" | base64 -d)
SENTIEON_AUTH_DATA=$(python3 tests/modules/nf-core/sentieon/license_message.py encrypt --key "$SENTIEON_ENCRYPTION_KEY" --message "$SENTIEON_LICENSE_MESSAGE")
SENTIEON_AUTH_DATA_BASE64=$(echo -n "$SENTIEON_AUTH_DATA" | base64 -w 0)
nextflow secrets set SENTIEON_AUTH_DATA_BASE64 $SENTIEON_AUTH_DATA_BASE64

# Test the module
- name: Run nf-test
run: |
nf-test test \
--profile=${{ matrix.profile }} \
--tag ${{ matrix.tags }} \
--tap=test.tap \
--verbose

confirm-pass:
runs-on: ubuntu-latest
needs:
- test
- pytest
- nftest
if: always()
steps:
- name: All tests ok
Expand Down
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
*.code-workspace
*.pyc
.nextflow*
work/
data/
results/
.DS_Store
testing/
.nf-test.log
.nf-test/
data/
testing*
*.pyc
testing/
test-datasets/
results/
work/
1 change: 1 addition & 0 deletions .nf-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ lint:
files_exist:
- conf/modules.config
files_unchanged:
- .gitignore
- assets/nf-core-sarek_logo_light.png
- docs/images/nf-core-sarek_logo_dark.png
- docs/images/nf-core-sarek_logo_light.png
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Rapaselet is a delta formed by the Rapaätno river between the Bielloriehppe mas
- [#1173](https://github.com/nf-core/sarek/pull/1173) - CI tests for VQSR track with stub runs
- [#1122](https://github.com/nf-core/sarek/pull/1122), [#1196](https://github.com/nf-core/sarek/pull/1196) - Add `annotation cache` functionality
- [#1184](https://github.com/nf-core/sarek/pull/1184) - Stub-based CI-test of Sentieon joint-germline variant-calling with VQSR
- [#1288](https://github.com/nf-core/sarek/pull/1288) - Add nf-test continuous integration.

### Changed

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 "conf/test.config"
profile "test"

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

name "Test pipeline"
script "../main.nf"
tag "pipeline"
tag "pipeline_sarek"

test("Run with profile test") {

when {
params {
outdir = "results"
max_cpus = 2
max_memory = '6.GB'
max_time = '6.h'
input = "$projectDir/tests/csv/3.0/fastq_pair.csv"
validationSchemaIgnoreParams = 'test_data_base,test_data'
}
}

then {
assertAll(
{ assert workflow.success }
)
}
}

}
5 changes: 5 additions & 0 deletions tests/tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pipeline_sarek:
- "**.nf"
- "**.config"
- "**.nf.test"
- "**.json"