|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + tags: |
| 8 | + - "**" |
| 9 | + pull_request: {} |
| 10 | + |
| 11 | +env: |
| 12 | + CI: true |
| 13 | + COLUMNS: 120 |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + lint: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - uses: astral-sh/setup-uv@v3 |
| 25 | + with: |
| 26 | + enable-cache: true |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: uv sync --python 3.11 --frozen --all-extras --all-packages |
| 30 | + |
| 31 | + - uses: pre-commit/action@v3.0.0 |
| 32 | + with: |
| 33 | + extra_args: --all-files --verbose |
| 34 | + env: |
| 35 | + SKIP: no-commit-to-branch |
| 36 | + |
| 37 | + test: |
| 38 | + name: test on ${{ matrix.python-version }} |
| 39 | + runs-on: ubuntu-latest |
| 40 | + timeout-minutes: 5 |
| 41 | + strategy: |
| 42 | + fail-fast: false |
| 43 | + matrix: |
| 44 | + python-version: ["3.11", "3.12", "3.13"] |
| 45 | + env: |
| 46 | + UV_PYTHON: ${{ matrix.python-version }} |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v4 |
| 49 | + |
| 50 | + - uses: astral-sh/setup-uv@v3 |
| 51 | + with: |
| 52 | + enable-cache: true |
| 53 | + |
| 54 | + - run: mkdir coverage |
| 55 | + |
| 56 | + - run: uv run --frozen coverage run -m pytest |
| 57 | + env: |
| 58 | + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-standard |
| 59 | + |
| 60 | + - name: store coverage files |
| 61 | + uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: coverage-${{ matrix.python-version }} |
| 64 | + path: coverage |
| 65 | + include-hidden-files: true |
| 66 | + |
| 67 | + coverage: |
| 68 | + runs-on: ubuntu-latest |
| 69 | + needs: [test] |
| 70 | + steps: |
| 71 | + - uses: actions/checkout@v4 |
| 72 | + |
| 73 | + - name: get coverage files |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + merge-multiple: true |
| 77 | + path: coverage |
| 78 | + |
| 79 | + - uses: astral-sh/setup-uv@v3 |
| 80 | + with: |
| 81 | + enable-cache: true |
| 82 | + |
| 83 | + - run: uv sync --frozen |
| 84 | + - run: uv run --frozen coverage combine coverage |
| 85 | + |
| 86 | + - run: uv run --frozen coverage html --show-contexts --title "Coverage for ${{ github.sha }}" |
| 87 | + |
| 88 | + - name: Store coverage html |
| 89 | + uses: actions/upload-artifact@v4 |
| 90 | + with: |
| 91 | + name: coverage-html |
| 92 | + path: htmlcov |
| 93 | + include-hidden-files: true |
| 94 | + |
| 95 | + - run: uv run --frozen coverage report --fail-under 70 |
| 96 | + # https://github.com/marketplace/actions/alls-green#why used for branch protection checks |
| 97 | + check: |
| 98 | + if: always() |
| 99 | + needs: [lint, test, coverage] |
| 100 | + runs-on: ubuntu-latest |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Decide whether the needed jobs succeeded or failed |
| 104 | + uses: re-actors/alls-green@release/v1 |
| 105 | + with: |
| 106 | + jobs: ${{ toJSON(needs) }} |
| 107 | + allowed-skips: test-live |
0 commit comments