Measure coverage over the tests/ matrix, not just pytest #864
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: Test | |
| permissions: | |
| contents: read | |
| on: | |
| push: | |
| merge_group: | |
| schedule: | |
| - cron: 0 13 * * 1 | |
| workflow_dispatch: | |
| env: | |
| RUFF_OUTPUT_FORMAT: github | |
| UV_FROZEN: 1 | |
| ARTISATOMIC_TESTMODE: 1 | |
| jobs: | |
| lint: | |
| name: Format, lint, and type check | |
| runs-on: ubuntu-26.04-arm | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| activate-environment: true | |
| - name: Install artisatomic | |
| run: uv sync --compile-bytecode | |
| - name: Run Ruff | |
| if: always() | |
| run: | | |
| uv run -- ruff --version | |
| uv run -- ruff check --exit-non-zero-on-fix --no-fix | |
| - name: Run Ruff Format | |
| if: always() | |
| run: uv run -- ruff format --check --exit-non-zero-on-format | |
| - name: Run pyrefly | |
| if: always() | |
| run: uv run -- pyrefly check --output-format github | |
| - name: Run basedpyright | |
| if: always() | |
| run: uv run -- basedpyright | |
| - name: Run prek pre-commit checks | |
| uses: j178/prek-action@v2.0.6 | |
| pytest: | |
| runs-on: ubuntu-26.04-arm | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| activate-environment: true | |
| - name: Install artisatomic | |
| run: uv sync --compile-bytecode | |
| - name: Cache CMFGEN atomic data | |
| uses: actions/cache@v6 | |
| id: cache-cmfgendata | |
| with: | |
| path: atomic-data-hillier/atomic_21jun23/** | |
| key: atomic-data-hillier/atomic_data_21jun23/files | |
| - name: Download/extract CMFGEN atomic data | |
| if: ${{ steps.cache-cmfgendata.outputs.cache-hit != 'true' }} | |
| working-directory: atomic-data-hillier/ | |
| run: source ./setup_cmfgen_data.sh | |
| # -p writes .coverage.<host>.<pid>.<random>, so this file and the one from each tests/ | |
| # matrix job survive being downloaded into one directory and combined | |
| - name: Test with pytest | |
| run: uv run python3 -m coverage run -p -m pytest | |
| - name: Upload coverage data | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-data-pytest | |
| path: .coverage.* | |
| include-hidden-files: true | |
| upload-coverage-python: | |
| needs: [pytest, tests] | |
| if: ${{ !cancelled() && needs.pytest.result == 'success' && needs.tests.result == 'success' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name | |
| == github.repository) }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| code-quality: write | |
| pull-requests: read | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| activate-environment: true | |
| # one directory holding every job's .coverage.* file | |
| - name: Download coverage data | |
| uses: actions/download-artifact@v8 | |
| with: | |
| pattern: coverage-data-* | |
| merge-multiple: true | |
| - name: Combine coverage into one report | |
| run: | | |
| uvx coverage combine | |
| uvx coverage xml -o coverage.xml | |
| uvx coverage report | |
| - name: Check for a pull request associated with this commit | |
| id: haspr | |
| if: github.ref != 'refs/heads/main' | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| run: echo "found=$(gh api "repos/${{ github.repository }}/commits/${{ github.sha }}/pulls" --jq 'length > 0')" >> "$GITHUB_OUTPUT" | |
| - uses: actions/upload-code-coverage@v1 | |
| if: github.ref == 'refs/heads/main' || steps.haspr.outputs.found == 'true' | |
| with: | |
| file: coverage.xml | |
| language: Python | |
| label: code-coverage-agent | |
| tests: | |
| strategy: | |
| matrix: | |
| testname: [cmfgen, cmfgen_lowz, floers25, jplt, kurucz, qub] | |
| fail-fast: false | |
| runs-on: ubuntu-26.04-arm | |
| timeout-minutes: 45 | |
| name: test ${{ matrix.testname }} | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v7 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| activate-environment: true | |
| - name: Install artisatomic | |
| run: uv sync --compile-bytecode | |
| # every matrix entry needs this, not just the cmfgen ones: makeartisatomicfiles reads the | |
| # hydrogenic photoionisation tables from HYD/I on any run without -nophixs, so gating this | |
| # on the test name breaks the other jobs as a phixsdata_v2.txt checksum mismatch | |
| - name: Cache CMFGEN atomic data | |
| uses: actions/cache@v6 | |
| id: cache-cmfgendata | |
| with: | |
| path: atomic-data-hillier/atomic_21jun23/** | |
| key: atomic-data-hillier/atomic_data_21jun23/files | |
| - name: Download/extract CMFGEN atomic data | |
| if: ${{ steps.cache-cmfgendata.outputs.cache-hit != 'true' }} | |
| working-directory: atomic-data-hillier/ | |
| run: source ./setup_cmfgen_data.sh | |
| - name: Cache JPLT atomic data | |
| if: matrix.testname == 'jplt' | |
| uses: actions/cache@v6 | |
| with: | |
| path: atomic-data-tanaka-jplt/data_v2.1/** | |
| key: atomic-data-tanaka-jplt-files-v2.1 | |
| - name: Download/extract JPLT atomic data | |
| if: matrix.testname == 'jplt' | |
| working-directory: atomic-data-tanaka-jplt/ | |
| run: source ./setup_jplt_data.sh | |
| - name: Extract Floers25 atomic data | |
| if: matrix.testname == 'floers25' | |
| working-directory: atomic-data-floers25/ | |
| run: tar -xJvf testdata.tar.xz | |
| # under coverage, so the readers this set exercises reach the combined report. The | |
| # console script is run as a file because the entry point is artisatomic:main, which | |
| # coverage run -m cannot name | |
| - name: Generate artis atomic data files | |
| run: | | |
| cp tests/${{ matrix.testname }}/artisatomicionhandlers.json . | |
| uv run python3 -m coverage run -p .venv/bin/makeartisatomicfiles -output_folder tests/${{ matrix.testname }}/output | |
| - name: Upload coverage data | |
| if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: coverage-data-${{ matrix.testname }} | |
| path: .coverage.* | |
| include-hidden-files: true | |
| - name: Checksum output files | |
| working-directory: tests/${{ matrix.testname }}/output | |
| run: | | |
| cat compositiondata.txt | |
| cat atomic_data_logs/*.json | |
| echo | |
| md5sum *.txt | |
| md5sum -c ../checksums.txt | |
| - name: tar and zip output files | |
| if: always() | |
| run: | | |
| tar -cvzf artis_files_${{ matrix.testname }}.tar.gz tests/${{ matrix.testname }}/output/* | |
| - name: Upload output files | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: artis_files_${{ matrix.testname }}.tar.gz | |
| path: artis_files_${{ matrix.testname }}.tar.gz |