|
| 1 | +name: 🔂 Unit tests |
| 2 | + |
| 3 | +concurrency: |
| 4 | + group: ${{ github.head_ref || github.run_id }} |
| 5 | + cancel-in-progress: true |
| 6 | + |
| 7 | +on: |
| 8 | + push: |
| 9 | + branches: [main] |
| 10 | + pull_request: |
| 11 | + branches: [main] |
| 12 | + paths: |
| 13 | + - "src/**" |
| 14 | + - "noxfile.py" |
| 15 | + - "pyproject.toml" |
| 16 | + - "uv.lock" |
| 17 | + - ".github/workflows/test.yml" |
| 18 | + |
| 19 | +jobs: |
| 20 | + generate-jobs-tests: |
| 21 | + name: 💻 Generate test matrix |
| 22 | + runs-on: ubuntu-latest |
| 23 | + outputs: |
| 24 | + sessions: ${{ steps.set-matrix.outputs.sessions }} |
| 25 | + steps: |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + - name: Install uv |
| 28 | + uses: astral-sh/setup-uv@v3 |
| 29 | + - run: uv venv |
| 30 | + - run: uv pip install nox |
| 31 | + - id: set-matrix |
| 32 | + shell: bash |
| 33 | + run: | |
| 34 | + . .venv/bin/activate |
| 35 | + echo sessions=$( |
| 36 | + nox --json -t tests -l | |
| 37 | + jq 'map( |
| 38 | + { |
| 39 | + session, |
| 40 | + name: "\( .name ) on \( .python )\( if .call_spec != {} then " (\(.call_spec | to_entries | map("\(.key)=\(.value)") | join(", ")))" else "" end )" |
| 41 | + } |
| 42 | + )' |
| 43 | + ) | tee --append $GITHUB_OUTPUT |
| 44 | +
|
| 45 | + unit-tests: |
| 46 | + name: 🔬 ${{ matrix.session.name }} |
| 47 | + needs: [generate-jobs-tests] |
| 48 | + runs-on: ubuntu-latest |
| 49 | + strategy: |
| 50 | + fail-fast: false |
| 51 | + matrix: |
| 52 | + session: ${{ fromJson(needs.generate-jobs-tests.outputs.sessions) }} |
| 53 | + |
| 54 | + steps: |
| 55 | + - uses: actions/checkout@v4 |
| 56 | + - uses: actions/setup-python@v5 |
| 57 | + with: |
| 58 | + python-version: | |
| 59 | + 3.9 |
| 60 | + 3.10 |
| 61 | + 3.11 |
| 62 | + 3.12 |
| 63 | + 3.13 |
| 64 | +
|
| 65 | + - run: pip install nox uv |
| 66 | + - run: nox -r -t tests -s "${{ matrix.session.session }}" |
| 67 | + - uses: actions/upload-artifact@v4 |
| 68 | + if: ${{ always() }} |
| 69 | + with: |
| 70 | + name: coverage-${{ matrix.session.session }} |
| 71 | + path: coverage.xml |
| 72 | + |
| 73 | + upload-coverage: |
| 74 | + name: 🆙 Upload Coverage |
| 75 | + needs: [unit-tests] |
| 76 | + runs-on: ubuntu-latest |
| 77 | + |
| 78 | + steps: |
| 79 | + - uses: actions/download-artifact@v4 |
| 80 | + - uses: codecov/codecov-action@v4 |
| 81 | + with: |
| 82 | + token: ${{ secrets.CODECOV_TOKEN }} |
| 83 | + fail_ci_if_error: true |
| 84 | + verbose: true |
| 85 | + |
| 86 | + # lint: |
| 87 | + # name: ✨ Lint |
| 88 | + # runs-on: ubuntu-latest |
| 89 | + |
| 90 | + # steps: |
| 91 | + # - uses: actions/checkout@v4 |
| 92 | + # - run: pipx install coverage |
| 93 | + # - uses: actions/setup-python@v5 |
| 94 | + # id: setup-python |
| 95 | + # with: |
| 96 | + # python-version: "3.12" |
| 97 | + |
| 98 | + # - run: poetry install --with integrations |
| 99 | + # if: steps.setup-python.outputs.cache-hit != 'true' |
| 100 | + |
| 101 | + # - run: | |
| 102 | + # mkdir .mypy_cache |
| 103 | + |
| 104 | + # uv run mypy --install-types --non-interactive --cache-dir=.mypy_cache/ --config-file mypy.ini |
0 commit comments