|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ main ] |
| 6 | + pull_request: |
| 7 | + branches: [ main ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: ci-${{ github.ref }} |
| 15 | + cancel-in-progress: true |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-test: |
| 19 | + name: ${{ matrix.os }} / Python ${{ matrix.python-version }} |
| 20 | + runs-on: ${{ matrix.os }} |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + os: [ubuntu-latest, windows-latest] |
| 25 | + python-version: ["3.11", "3.12"] |
| 26 | + |
| 27 | + steps: |
| 28 | + - name: Checkout repository |
| 29 | + uses: actions/checkout@v4 |
| 30 | + |
| 31 | + - name: Set up Python |
| 32 | + uses: actions/setup-python@v5 |
| 33 | + with: |
| 34 | + python-version: ${{ matrix.python-version }} |
| 35 | + cache: 'pip' |
| 36 | + |
| 37 | + - name: Install dependencies |
| 38 | + run: | |
| 39 | + python -m pip install --upgrade pip |
| 40 | + pip install -r requirements.txt |
| 41 | +
|
| 42 | + - name: Lint (flake8) |
| 43 | + run: | |
| 44 | + python -m flake8 src tests |
| 45 | +
|
| 46 | + - name: Format check (black) |
| 47 | + run: | |
| 48 | + python -m black --check src tests |
| 49 | +
|
| 50 | + - name: Run tests (pytest) |
| 51 | + run: | |
| 52 | + python -m pytest -q --disable-warnings --maxfail=1 --cov=src --cov-report=xml --cov-report=term-missing |
| 53 | +
|
| 54 | + - name: Upload coverage to Codecov (public repos only) |
| 55 | + uses: codecov/codecov-action@v4 |
| 56 | + with: |
| 57 | + files: coverage.xml |
| 58 | + flags: ${{ matrix.os }}-py${{ matrix.python-version }} |
| 59 | + fail_ci_if_error: true |
| 60 | + continue-on-error: true |
| 61 | + |
| 62 | + - name: Upload coverage report |
| 63 | + if: always() |
| 64 | + uses: actions/upload-artifact@v4 |
| 65 | + with: |
| 66 | + name: coverage-${{ matrix.python-version }} |
| 67 | + path: ./coverage.xml |
| 68 | + if-no-files-found: ignore |
| 69 | + |
| 70 | + summary: |
| 71 | + name: CI Summary |
| 72 | + runs-on: ubuntu-latest |
| 73 | + needs: build-test |
| 74 | + if: always() |
| 75 | + steps: |
| 76 | + - name: Generate summary |
| 77 | + run: | |
| 78 | + echo "All matrix jobs finished: ${{ needs.build-test.result }}" >> $GITHUB_STEP_SUMMARY |
0 commit comments