|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + schedule: |
| 9 | + - cron: '00 01 * * *' |
| 10 | +concurrency: |
| 11 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
| 14 | +jobs: |
| 15 | + build: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + strategy: |
| 18 | + matrix: |
| 19 | + python-version: ["3.10", "3.11", "3.12"] |
| 20 | + |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v5 |
| 23 | + - name: Install uv |
| 24 | + uses: astral-sh/setup-uv@v7 |
| 25 | + with: |
| 26 | + # Install a specific version of uv. |
| 27 | + version: "0.5.1" |
| 28 | + enable-cache: true |
| 29 | + cache-dependency-glob: "uv.lock" |
| 30 | + - name: Set up Python ${{ matrix.python-version }} |
| 31 | + run: uv python install ${{ matrix.python-version }} |
| 32 | + - name: Install the project |
| 33 | + run: uv sync --all-extras --dev |
| 34 | + - name: Run tests |
| 35 | + # For example, using `pytest` |
| 36 | + run: uv run just coverage |
| 37 | + - name: Upload Coverage to Codecov |
| 38 | + uses: codecov/codecov-action@v5 |
| 39 | + with: |
| 40 | + files: coverage.xml # optional |
| 41 | + fail_ci_if_error: true # optional (default = false) |
| 42 | + verbose: true # optional (default = false) |
| 43 | + token: ${{ secrets.CODECOV_TOKEN }} # required |
| 44 | + - name: Archive code coverage results |
| 45 | + if: matrix.python-version == '3.12' |
| 46 | + uses: actions/upload-artifact@v4 |
| 47 | + with: |
| 48 | + name: code-coverage-report |
| 49 | + path: coverage.xml |
| 50 | + retention-days: 2 |
| 51 | + post: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: build |
| 54 | + if: github.event.pull_request |
| 55 | + steps: |
| 56 | + - uses: actions/checkout@v5 |
| 57 | + - name: download coverage |
| 58 | + uses: actions/download-artifact@v5 |
| 59 | + with: |
| 60 | + name: code-coverage-report |
| 61 | + - name: check coverage |
| 62 | + run: | |
| 63 | + if [ -f coverage.xml ]; then |
| 64 | + echo "Coverage file exists" |
| 65 | + else |
| 66 | + echo "Coverage file does not exist" |
| 67 | + exit 1 |
| 68 | + fi |
| 69 | + - name: post coverage |
| 70 | + uses: orgoro/coverage@v3.2 |
| 71 | + with: |
| 72 | + coverageFile: coverage.xml |
| 73 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments