Skip to content

Use new nf-test features #49

Use new nf-test features

Use new nf-test features #49

Workflow file for this run

name: Run Linting
on:
push:
branches:
# https://docs.renovatebot.com/key-concepts/automerge/#branch-vs-pr-automerging
- "renovate/**" # branches Renovate creates
pull_request:
branches: [master]
merge_group:
types: [checks_requested]
branches: [master]
workflow_dispatch:
inputs:
runners:
description: "Runners to test on"
type: choice
options:
- "ubuntu-latest"
- "self-hosted"
default: "self-hosted"
# Cancel if a newer run is started
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
NXF_SINGULARITY_CACHEDIR: ${{ github.workspace }}/.singularity
NXF_SINGULARITY_LIBRARYDIR: ${{ github.workspace }}/.singularity
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
with:
extra_args: ""
###################
# nf-core linting #
###################
# TODO Move these to pre-commit
# https://github.com/nf-core/tools/pull/3141
nf-core-changes:
name: nf-core-changes
runs-on: ubuntu-latest
outputs:
tags: ${{ steps.filter.outputs.changes }}
modules: ${{ steps.tags.outputs.modules }}
subworkflows: ${{ steps.tags.outputs.subworkflows }}
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
fetch-depth: 2 # To retrieve the preceding commit.
- uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3
id: filter
with:
filters: "tests/config/pytest_modules.yml"
token: ""
- name: Fetch module tags
id: tags
run: |
echo modules=$(echo '${{ steps.filter.outputs.changes }}' | jq -c '. | map(select(contains("modules"))) | map(gsub("modules/"; ""))') >> $GITHUB_OUTPUT
echo subworkflows=$(echo '${{ steps.filter.outputs.changes }}' | jq '. | map(select(contains("subworkflow"))) | map(gsub("subworkflows/"; ""))') >> $GITHUB_OUTPUT
- name: debug
run: |
echo ${{ steps.tags.outputs.modules }}
echo ${{ steps.tags.outputs.subworkflows }}
nf-core-lint-modules:
runs-on: ${{ github.event.inputs.runners || 'self-hosted' }}
name: nf-core lint modules
needs: nf-core-changes
if: ${{ (needs.nf-core-changes.outputs.modules != '[]') }}
strategy:
fail-fast: false
matrix:
tags: "${{ fromJson(needs.nf-core-changes.outputs.modules) }}"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.11"
- uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 # v4
id: cache-pip
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip
restore-keys: |
${{ runner.os }}-pip
- name: Install pip
run: python -m pip install --upgrade pip
- uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: "temurin"
java-version: "17"
- name: Setup Nextflow
uses: nf-core/setup-nextflow@v2
- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/nf-core/tools.git@dev
- name: Lint module ${{ matrix.tags }}
run: nf-core modules lint ${{ matrix.tags }}
nf-core-lint-subworkflows:
runs-on: ubuntu-latest
name: nf-core lint subworkflows
needs: nf-core-changes
if: ${{ (needs.nf-core-changes.outputs.subworkflows != '[]') }}
strategy:
fail-fast: false
matrix:
tags: "${{ fromJson(needs.nf-core-changes.outputs.subworkflows) }}"
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up Python
uses: actions/setup-python@f677139bbe7f9c59b41e40162b753c062f5d49a3 # v5
with:
python-version: "3.11"
- name: Install pip
run: python -m pip install --upgrade pip
- uses: actions/setup-java@b36c23c0d998641eff861008f374ee103c25ac73 # v4
with:
distribution: "temurin"
java-version: "17"
- name: Setup Nextflow
uses: nf-core/setup-nextflow@561fcfc7146dcb12e3871909b635ab092a781f34 # v2
- name: Install nf-core tools development version
run: python -m pip install --upgrade --force-reinstall git+https://github.com/nf-core/tools.git@dev
- name: Lint module ${{ matrix.tags }}
run: nf-core subworkflows lint ${{ matrix.tags }}
confirm-pass:
runs-on: ubuntu-latest
needs: [nf-core-lint-modules, nf-core-lint-subworkflows]
if: always()
steps:
- name: All tests ok
if: ${{ success() || !contains(needs.*.result, 'failure') }}
run: exit 0
- name: One or more tests failed
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: debug-print
if: always()
run: |
echo "toJSON(needs) = ${{ toJSON(needs) }}"
echo "toJSON(needs.*.result) = ${{ toJSON(needs.*.result) }}"