|
| 1 | +name: Test |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + pull_request: |
| 8 | + types: |
| 9 | + - opened |
| 10 | + - synchronize |
| 11 | + workflow_dispatch: |
| 12 | + inputs: |
| 13 | + debug_enabled: |
| 14 | + description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' |
| 15 | + required: false |
| 16 | + default: 'false' |
| 17 | + schedule: |
| 18 | + # cron every week on monday |
| 19 | + - cron: "0 0 * * 1" |
| 20 | + |
| 21 | +env: |
| 22 | + UV_SYSTEM_PYTHON: 1 |
| 23 | + |
| 24 | +jobs: |
| 25 | + test: |
| 26 | + strategy: |
| 27 | + matrix: |
| 28 | + os: |
| 29 | + - ubuntu-latest |
| 30 | + - windows-latest |
| 31 | + - macos-latest |
| 32 | + python-version: |
| 33 | + - "3.14" |
| 34 | + include: |
| 35 | + - os: macos-latest |
| 36 | + python-version: "3.8" |
| 37 | + - os: windows-latest |
| 38 | + python-version: "3.9" |
| 39 | + - os: ubuntu-latest |
| 40 | + python-version: "3.10" |
| 41 | + - os: macos-latest |
| 42 | + python-version: "3.11" |
| 43 | + - os: windows-latest |
| 44 | + python-version: "3.12" |
| 45 | + - os: ubuntu-latest |
| 46 | + python-version: "3.13" |
| 47 | + - os: macos-latest |
| 48 | + python-version: "3.13" |
| 49 | + fail-fast: false |
| 50 | + runs-on: ${{ matrix.os }} |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v5 |
| 53 | + - name: Set up Python |
| 54 | + uses: actions/setup-python@v6 |
| 55 | + with: |
| 56 | + python-version: ${{ matrix.python-version }} |
| 57 | + - name: Setup uv |
| 58 | + uses: astral-sh/setup-uv@v7 |
| 59 | + with: |
| 60 | + version: "0.4.15" |
| 61 | + enable-cache: true |
| 62 | + cache-dependency-glob: | |
| 63 | + requirements**.txt |
| 64 | + pyproject.toml |
| 65 | + # Allow debugging with tmate |
| 66 | + - name: Setup tmate session |
| 67 | + uses: mxschmitt/action-tmate@v3 |
| 68 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }} |
| 69 | + with: |
| 70 | + limit-access-to-actor: true |
| 71 | + - name: Install Dependencies |
| 72 | + run: uv pip install -r requirements-tests.txt |
| 73 | + - name: Lint |
| 74 | + run: bash scripts/lint.sh |
| 75 | + - run: mkdir coverage |
| 76 | + - name: Test |
| 77 | + run: bash scripts/test.sh |
| 78 | + env: |
| 79 | + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }} |
| 80 | + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }} |
| 81 | + - name: Store coverage files |
| 82 | + uses: actions/upload-artifact@v4 |
| 83 | + with: |
| 84 | + name: coverage-${{ runner.os }}-${{ matrix.python-version }} |
| 85 | + path: coverage |
| 86 | + include-hidden-files: true |
| 87 | + |
| 88 | + coverage-combine: |
| 89 | + needs: |
| 90 | + - test |
| 91 | + runs-on: ubuntu-latest |
| 92 | + steps: |
| 93 | + - uses: actions/checkout@v5 |
| 94 | + - uses: actions/setup-python@v6 |
| 95 | + with: |
| 96 | + python-version: '3.13' |
| 97 | + - name: Setup uv |
| 98 | + uses: astral-sh/setup-uv@v7 |
| 99 | + with: |
| 100 | + version: "0.4.15" |
| 101 | + enable-cache: true |
| 102 | + cache-dependency-glob: | |
| 103 | + requirements**.txt |
| 104 | + pyproject.toml |
| 105 | + - name: Get coverage files |
| 106 | + uses: actions/download-artifact@v5 |
| 107 | + with: |
| 108 | + pattern: coverage-* |
| 109 | + path: coverage |
| 110 | + merge-multiple: true |
| 111 | + # Allow debugging with tmate |
| 112 | + - name: Setup tmate session |
| 113 | + uses: mxschmitt/action-tmate@v3 |
| 114 | + if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled == 'true' }} |
| 115 | + with: |
| 116 | + limit-access-to-actor: true |
| 117 | + - name: Install Dependencies |
| 118 | + run: uv pip install -r requirements-tests.txt |
| 119 | + - run: ls -la coverage |
| 120 | + - run: coverage combine coverage |
| 121 | + - run: coverage report |
| 122 | + - run: coverage html --title "Coverage for ${{ github.sha }}" |
| 123 | + - name: Store coverage HTML |
| 124 | + uses: actions/upload-artifact@v4 |
| 125 | + with: |
| 126 | + name: coverage-html |
| 127 | + path: htmlcov |
| 128 | + include-hidden-files: true |
| 129 | + |
| 130 | + # https://github.com/marketplace/actions/alls-green#why |
| 131 | + alls-green: # This job does nothing and is only used for the branch protection |
| 132 | + if: always() |
| 133 | + needs: |
| 134 | + - coverage-combine |
| 135 | + runs-on: ubuntu-latest |
| 136 | + steps: |
| 137 | + - name: Decide whether the needed jobs succeeded or failed |
| 138 | + uses: re-actors/alls-green@release/v1 |
| 139 | + with: |
| 140 | + jobs: ${{ toJSON(needs) }} |
0 commit comments