|
1 | 1 | --- |
2 | | - |
3 | | -name: CI |
| 2 | +name: Test |
4 | 3 |
|
5 | 4 | on: |
6 | 5 | push: |
|
13 | 12 | - cron: 0 1 * * * |
14 | 13 | workflow_dispatch: {} |
15 | 14 |
|
16 | | -# We share Vuforia credentials and therefore Vuforia databases across |
17 | | -# workflows. |
18 | | -# We therefore want to run only one workflow at a time. |
19 | | -concurrency: vuforia_credentials |
20 | | - |
21 | 15 | jobs: |
22 | | - build: |
23 | | - |
| 16 | + # CI tests with matrix |
| 17 | + ci-tests: |
24 | 18 | runs-on: ubuntu-latest |
25 | | - |
| 19 | + # We share Vuforia credentials and therefore Vuforia databases across |
| 20 | + # workflows. We therefore want to run only one workflow at a time. |
| 21 | + concurrency: vuforia_credentials |
26 | 22 | strategy: |
27 | 23 | fail-fast: false |
28 | 24 | matrix: |
@@ -170,20 +166,156 @@ jobs: |
170 | 166 | - name: Upload coverage data |
171 | 167 | uses: actions/upload-artifact@v4 |
172 | 168 | with: |
173 | | - name: | |
174 | | - coverage-data-ci-${{ matrix.python-version }}-${{ matrix.ci_pattern}} |
| 169 | + name: coverage-data-ci-${{ matrix.python-version }}-${{ matrix.ci_pattern |
| 170 | + }} |
| 171 | + path: .coverage.* |
| 172 | + include-hidden-files: true |
| 173 | + if-no-files-found: ignore |
| 174 | + |
| 175 | + # Skip tests |
| 176 | + skip-tests: |
| 177 | + runs-on: ubuntu-latest |
| 178 | + strategy: |
| 179 | + matrix: |
| 180 | + python-version: ['3.13'] |
| 181 | + platform: [ubuntu-latest] |
| 182 | + |
| 183 | + steps: |
| 184 | + - uses: actions/checkout@v5 |
| 185 | + |
| 186 | + - name: Install uv |
| 187 | + uses: astral-sh/setup-uv@v6 |
| 188 | + with: |
| 189 | + enable-cache: true |
| 190 | + cache-dependency-glob: '**/pyproject.toml' |
| 191 | + |
| 192 | + - name: Set secrets file |
| 193 | + run: | |
| 194 | + cp ./vuforia_secrets.env.example ./vuforia_secrets.env |
| 195 | +
|
| 196 | + - name: Run tests |
| 197 | + run: | |
| 198 | + uv run --extra=dev pytest \ |
| 199 | + --skip-docker_build_tests \ |
| 200 | + --skip-docker_in_memory \ |
| 201 | + --skip-mock \ |
| 202 | + --skip-real \ |
| 203 | + --capture=no \ |
| 204 | + -vvv \ |
| 205 | + --exitfirst \ |
| 206 | + --cov=src/ \ |
| 207 | + --cov=tests/ \ |
| 208 | + --cov-report=xml \ |
| 209 | + . |
| 210 | + env: |
| 211 | + UV_PYTHON: ${{ matrix.python-version }} |
| 212 | + |
| 213 | + - name: Upload coverage data |
| 214 | + uses: actions/upload-artifact@v4 |
| 215 | + with: |
| 216 | + name: coverage-data-skip-tests-${{ matrix.python-version }} |
| 217 | + path: .coverage.* |
| 218 | + include-hidden-files: true |
| 219 | + if-no-files-found: ignore |
| 220 | + |
| 221 | + # Windows tests |
| 222 | + windows-tests: |
| 223 | + runs-on: windows-latest |
| 224 | + strategy: |
| 225 | + matrix: |
| 226 | + python-version: ['3.13'] |
| 227 | + |
| 228 | + steps: |
| 229 | + - uses: actions/checkout@v5 |
| 230 | + |
| 231 | + - name: Install uv |
| 232 | + uses: astral-sh/setup-uv@v6 |
| 233 | + with: |
| 234 | + enable-cache: true |
| 235 | + cache-dependency-glob: '**/pyproject.toml' |
| 236 | + |
| 237 | + - name: Set secrets file |
| 238 | + run: | |
| 239 | + cp ./vuforia_secrets.env.example ./vuforia_secrets.env |
| 240 | +
|
| 241 | + - name: Run tests |
| 242 | + run: | |
| 243 | + # We use pytest-xdist to make this run much faster. |
| 244 | + # The downside is that we cannot use -s / --capture=no. |
| 245 | + uv run --extra=dev pytest --skip-real -vvv --exitfirst -n auto --cov=src/ --cov=tests/ --cov-report=xml . |
| 246 | + env: |
| 247 | + UV_PYTHON: ${{ matrix.python-version }} |
| 248 | + |
| 249 | + - name: Upload coverage data |
| 250 | + uses: actions/upload-artifact@v4 |
| 251 | + with: |
| 252 | + name: coverage-data-windows-${{ matrix.python-version }} |
175 | 253 | path: .coverage.* |
176 | 254 | include-hidden-files: true |
177 | 255 | if-no-files-found: ignore |
178 | 256 |
|
179 | | - completion-ci: |
180 | | - needs: build |
| 257 | + # Coverage combination and enforcement |
| 258 | + coverage: |
| 259 | + name: Combine & check coverage |
| 260 | + needs: [ci-tests, skip-tests, windows-tests] |
| 261 | + if: always() |
181 | 262 | runs-on: ubuntu-latest |
182 | | - if: always() # Run even if one matrix job fails |
| 263 | + |
183 | 264 | steps: |
184 | | - - name: Check matrix job status |
| 265 | + - uses: actions/checkout@v5 |
| 266 | + |
| 267 | + - name: Install uv |
| 268 | + uses: astral-sh/setup-uv@v6 |
| 269 | + with: |
| 270 | + enable-cache: true |
| 271 | + cache-dependency-glob: '**/pyproject.toml' |
| 272 | + |
| 273 | + - uses: actions/download-artifact@v4 |
| 274 | + with: |
| 275 | + pattern: coverage-data-* |
| 276 | + merge-multiple: true |
| 277 | + |
| 278 | + - name: Combine coverage & fail if it's <100% |
| 279 | + run: | |
| 280 | + uv tool install 'coverage[toml]' |
| 281 | +
|
| 282 | + coverage combine |
| 283 | + coverage html --skip-covered --skip-empty |
| 284 | +
|
| 285 | + # Report and write to summary. |
| 286 | + coverage report --format=markdown >> "$GITHUB_STEP_SUMMARY" |
| 287 | +
|
| 288 | + # Report again and fail if under 100%. |
| 289 | + coverage report --fail-under=100 |
| 290 | +
|
| 291 | + - name: Upload HTML report if check failed |
| 292 | + uses: actions/upload-artifact@v4 |
| 293 | + with: |
| 294 | + name: html-report |
| 295 | + path: htmlcov |
| 296 | + if: ${{ failure() }} |
| 297 | + |
| 298 | + # Final completion check |
| 299 | + completion: |
| 300 | + needs: [ci-tests, skip-tests, windows-tests, coverage] |
| 301 | + runs-on: ubuntu-latest |
| 302 | + if: always() |
| 303 | + steps: |
| 304 | + - name: Check all jobs status |
185 | 305 | run: |- |
186 | | - if ! ${{ needs.build.result == 'success' }}; then |
187 | | - echo "One or more matrix jobs failed" |
| 306 | + if ! ${{ needs.ci-tests.result == 'success' }}; then |
| 307 | + echo "CI tests failed" |
| 308 | + exit 1 |
| 309 | + fi |
| 310 | + if ! ${{ needs.skip-tests.result == 'success' }}; then |
| 311 | + echo "Skip tests failed" |
| 312 | + exit 1 |
| 313 | + fi |
| 314 | + if ! ${{ needs.windows-tests.result == 'success' }}; then |
| 315 | + echo "Windows tests failed" |
| 316 | + exit 1 |
| 317 | + fi |
| 318 | + if ! ${{ needs.coverage.result == 'success' }}; then |
| 319 | + echo "Coverage check failed" |
188 | 320 | exit 1 |
189 | 321 | fi |
0 commit comments