Add --help-json flag for machine-readable CLI help
#12490
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Python tests | |
| # This workflow is triggered on pushes and PRs to the repository. | |
| # Only run if we changed a Python file | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| # https://docs.renovatebot.com/key-concepts/automerge/#branch-vs-pr-automerging | |
| - "renovate/**" # branches Renovate creates | |
| paths-ignore: | |
| - "docs/**" | |
| - "CHANGELOG.md" | |
| pull_request: | |
| paths-ignore: | |
| - "docs/**" | |
| - "CHANGELOG.md" | |
| # ignore github workflows except for the current one | |
| - ".github/**" | |
| - "!.github/workflows/pytest.yml" | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| nextflow-version: | |
| description: "Nextflow version to test against" | |
| required: false | |
| default: "latest-stable" | |
| # Cancel if a newer run with the same workflow name is queued | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| jobs: | |
| # create a test matrix based on all python files in /tests | |
| list_tests: | |
| name: Get test file matrix | |
| runs-on: "ubuntu-latest" | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| name: Check out source-code repository | |
| - name: List tests | |
| id: list_tests | |
| run: | | |
| echo "tests=$(find tests -type f -name "test_*.py" | tac | sed 's/tests\///g' | jq -R -s -c '{test: (split("\n")[:-1])}')" >> $GITHUB_OUTPUT | |
| outputs: | |
| tests: ${{ steps.list_tests.outputs.tests }} | |
| test: | |
| name: Run ${{matrix.test}} with Python ${{ matrix.python-version }} and Nextflow ${{ matrix.nextflow-version }} | |
| needs: list_tests | |
| runs-on: | |
| - runs-on=${{ github.run_id }}-run-test | |
| - runner=4cpu-linux-x64 | |
| strategy: | |
| matrix: | |
| # On PRs to main test with 3.10 and 3.14, otherwise just 3.10 | |
| python-version: ${{ github.base_ref == 'main' && fromJson('["3.10", "3.14"]') || fromJson('["3.10"]') }} | |
| test: ${{ fromJson(needs.list_tests.outputs.tests).test }} | |
| # On push/release test both NF versions, otherwise just 25.10.4 | |
| # Note: python×nextflow must stay ≤2 with 88 tests to stay under GitHub's 256-config limit | |
| nextflow-version: ${{ (github.event_name == 'push' || github.event_name == 'release') && fromJson('["25.10.4", "latest-stable"]') || fromJson('["25.10.4"]') }} | |
| fail-fast: false # run all tests even if one fails | |
| steps: | |
| - name: go to subdirectory and change nextflow workdir | |
| run: | | |
| mkdir -p pytest | |
| cd pytest | |
| export NXF_WORK=$(pwd) | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | |
| name: Check out source-code repository | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@08807647e7069bb48b6ef5acd8ec9567f424441b # v8.1.0 | |
| with: | |
| enable-cache: true | |
| - name: Install dependencies | |
| run: uv sync --all-extras | |
| - name: Set up Apptainer | |
| if: ${{ startsWith(matrix.test, 'pipelines/download/') }} | |
| uses: eWaterCycle/setup-apptainer@4bb22c52d4f63406c49e94c804632975787312b3 # v2.0.0 | |
| - name: Install Nextflow | |
| uses: nf-core/setup-nextflow@b4ec1bc7c16a94435159de94a05253542fddf6ef # v3 | |
| with: | |
| version: ${{ github.event.inputs.nextflow-version || matrix.nextflow-version }} | |
| - name: Install nf-test | |
| uses: nf-core/setup-nf-test@4069fbbaabe94c08faba4ad261bfa88225ba133f # v2 | |
| with: | |
| version: 0.9.5 | |
| install-fast-diff: true | |
| - name: move coveragerc file up | |
| run: | | |
| mv .github/.coveragerc . | |
| - name: Test with pytest | |
| id: pytest | |
| run: | | |
| uv run python -m pytest tests/${{matrix.test}} --color=yes --cov --cov-config=.coveragerc --durations=0 -n logical && exit_code=0|| exit_code=$? | |
| # don't fail if no tests were collected, e.g. for test_licence.py | |
| if [ "${exit_code}" -eq 5 ]; then | |
| echo "No tests were collected" | |
| exit 0 | |
| elif [ "${exit_code}" -ne 0 ]; then | |
| echo "Tests failed with exit code ${exit_code}" | |
| exit 1 | |
| fi | |
| - name: Generate coverage XML | |
| if: always() | |
| run: | | |
| uv run coverage xml --rcfile=.coveragerc | |
| - name: Upload coverage to Codecov | |
| if: always() | |
| uses: codecov/codecov-action@e79a6962e0d4c0c17b229090214935d2e33f8354 # v6 | |
| with: | |
| files: ./coverage.xml | |
| flags: python-${{ matrix.python-version }} | |
| env_vars: MATRIX_TEST | |
| env: | |
| CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
| MATRIX_TEST: ${{ matrix.test }} | |
| - name: remove slashes from test name | |
| run: | | |
| test=$(echo ${{ matrix.test }} | sed 's/\//__/g') | |
| echo "test=${test}" >> $GITHUB_ENV | |
| - name: Store snapshot report | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 | |
| if: always() && contains(matrix.test, 'test_create_app') && steps.pytest.outcome == 'failure' | |
| with: | |
| include-hidden-files: true | |
| name: Snapshot Report ${{ env.test }} | |
| path: ./snapshot_report.html |