|
| 1 | +name: Coverage |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: [opened, synchronize, reopened, labeled, unlabeled] |
| 9 | + workflow_dispatch: |
| 10 | + workflow_call: |
| 11 | + |
| 12 | +env: |
| 13 | + X2PY_GFORTRAN_BINARY: gfortran-13 |
| 14 | + X2PY_GFORTRAN_PACKAGE: gfortran-13 |
| 15 | + |
| 16 | +jobs: |
| 17 | + coverage: |
| 18 | + name: Python 3.12 |
| 19 | + if: >- |
| 20 | + ${{ |
| 21 | + github.event_name != 'pull_request' || |
| 22 | + contains(github.event.pull_request.labels.*.name, 'run-coverage') |
| 23 | + }} |
| 24 | + runs-on: ubuntu-24.04 |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + id-token: write |
| 28 | + steps: |
| 29 | + - name: Checkout repository |
| 30 | + uses: actions/checkout@v4 |
| 31 | + with: |
| 32 | + fetch-depth: 2 |
| 33 | + - name: Set up Python |
| 34 | + uses: actions/setup-python@v5 |
| 35 | + with: |
| 36 | + python-version: "3.12" |
| 37 | + - name: Install coverage dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + python -m pip install -e ".[qa]" |
| 41 | + - name: Install pinned GFortran |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + if ! command -v "$X2PY_GFORTRAN_BINARY" >/dev/null 2>&1; then |
| 45 | + sudo apt-get update |
| 46 | + sudo apt-get install --yes "$X2PY_GFORTRAN_PACKAGE" |
| 47 | + fi |
| 48 | + compiler_dir="$RUNNER_TEMP/x2py-gfortran" |
| 49 | + mkdir -p "$compiler_dir" |
| 50 | + ln -sf "$(command -v "$X2PY_GFORTRAN_BINARY")" "$compiler_dir/gfortran" |
| 51 | + echo "$compiler_dir" >> "$GITHUB_PATH" |
| 52 | + "$compiler_dir/gfortran" --version |
| 53 | + - name: Run tests with coverage |
| 54 | + shell: bash |
| 55 | + env: |
| 56 | + PYTHONPATH: . |
| 57 | + HYPOTHESIS_PROFILE: ci |
| 58 | + COVERAGE_PROCESS_START: ${{ github.workspace }}/pyproject.toml |
| 59 | + run: | |
| 60 | + python -m coverage run -m pytest -q --randomly-seed=1 \ |
| 61 | + -o junit_family=legacy \ |
| 62 | + --junitxml="$RUNNER_TEMP/pytest-smoke-results.xml" \ |
| 63 | + tests/fortran \ |
| 64 | + -m toolchain_smoke \ |
| 65 | + --require-toolchain-smoke \ |
| 66 | + --x2py-fortran-compiler=gfortran |
| 67 | + python -m coverage run -m pytest -q --randomly-seed=1 \ |
| 68 | + -o junit_family=legacy \ |
| 69 | + --junitxml="$RUNNER_TEMP/pytest-suite-results.xml" \ |
| 70 | + -m "not real_library and not toolchain_smoke" \ |
| 71 | + tests/architecture \ |
| 72 | + tests/c \ |
| 73 | + tests/fortran \ |
| 74 | + tests/shared |
| 75 | + - name: Summarize failed pytest nodes |
| 76 | + if: failure() |
| 77 | + shell: bash |
| 78 | + run: | |
| 79 | + shopt -s nullglob |
| 80 | + reports=("$RUNNER_TEMP"/pytest-*-results.xml) |
| 81 | + for report in "${reports[@]}"; do |
| 82 | + python tools/print_pytest_failures.py "$report" |
| 83 | + done |
| 84 | + - name: Combine coverage data |
| 85 | + run: python -m coverage combine |
| 86 | + - name: Report coverage |
| 87 | + run: python -m coverage report |
| 88 | + - name: Emit coverage XML |
| 89 | + run: python -m coverage xml -o coverage.xml |
| 90 | + - name: Upload coverage to Codecov |
| 91 | + uses: codecov/codecov-action@v6 |
| 92 | + with: |
| 93 | + files: ./coverage.xml |
| 94 | + flags: py312 |
| 95 | + use_oidc: true |
| 96 | + fail_ci_if_error: true |
0 commit comments