|
6 | 6 | branches: [main] |
7 | 7 |
|
8 | 8 | jobs: |
| 9 | + |
9 | 10 | mypy: |
10 | 11 | runs-on: ubuntu-latest |
11 | 12 | strategy: |
12 | 13 | matrix: |
13 | | - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] |
| 14 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13'] |
14 | 15 | steps: |
15 | | - - uses: actions/checkout@v3 |
16 | | - - uses: actions/setup-python@v4 |
| 16 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 17 | + - uses: ./.github/actions/setup |
17 | 18 | with: |
18 | 19 | python-version: ${{matrix.python-version}} |
19 | | - architecture: x64 |
20 | | - - run: | |
21 | | - pip install hatch |
22 | | - hatch run +python=${{matrix.python-version}} all:test-mypy |
| 20 | + - run: uvx hatch run +py=${{matrix.python-version}} types:check |
23 | 21 |
|
24 | 22 | test: |
25 | 23 | runs-on: ${{matrix.os}} |
26 | 24 | strategy: |
27 | 25 | matrix: |
28 | | - python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] |
29 | | - os: [ubuntu-latest, windows-latest] |
| 26 | + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13', pypy3.9, pypy3.10] |
| 27 | + os: [ubuntu-latest, windows-latest, macos-13] |
| 28 | + env: |
| 29 | + TOP: ${{github.workspace}} |
| 30 | + COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml |
30 | 31 | steps: |
31 | | - - uses: actions/checkout@v3 |
32 | | - - uses: actions/setup-python@v4 |
| 32 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 33 | + - uses: ./.github/actions/setup |
33 | 34 | with: |
34 | 35 | python-version: ${{matrix.python-version}} |
35 | | - architecture: x64 |
36 | | - |
37 | | - - name: run tests for ${{matrix.python-version}} |
38 | | - env: |
39 | | - TOP: ${{github.workspace}} |
40 | | - COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml |
41 | | - run: | |
42 | | - pip install hatch |
43 | | - hatch run +python=${{matrix.python-version}} all:test-cov |
44 | 36 |
|
45 | | - - name: Combine data |
46 | | - env: |
47 | | - TOP: ${{github.workspace}} |
48 | | - COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml |
49 | | - run: | |
50 | | - pip install coverage |
51 | | - coverage combine |
52 | | - mv .coverage .coverage.${{ matrix.python-version }}.${{matrix.os}} |
| 37 | + - run: | |
| 38 | + uv run -m ${{ matrix.os == 'ubuntu-latest' && 'coverage run -m' || '' }} pytest ${{ matrix.os != 'windows-latest' && '-n=auto' || '' }} -vv |
| 39 | + - run: | |
| 40 | + uv run -m coverage combine |
| 41 | + mv .coverage .coverage.${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} |
| 42 | + if: matrix.os == 'ubuntu-latest' |
53 | 43 |
|
54 | 44 | - name: Upload coverage data |
55 | | - uses: actions/upload-artifact@v3 |
| 45 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 46 | + if: matrix.os == 'ubuntu-latest' |
56 | 47 | with: |
57 | | - name: coverage |
| 48 | + name: coverage-data-${{github.run_id}}-${{ matrix.python-version }}-${{matrix.os}}-${{strategy.job-index}} |
58 | 49 | path: .coverage.* |
| 50 | + include-hidden-files: true |
| 51 | + if-no-files-found: ignore |
59 | 52 |
|
60 | | - combine_coverage: |
61 | | - name: combine coverage and check for 100% |
| 53 | + coverage: |
| 54 | + name: Combine & check coverage |
| 55 | + env: |
| 56 | + TOP: ${{github.workspace}} |
| 57 | + if: always() |
62 | 58 | needs: test |
63 | 59 | runs-on: ubuntu-latest |
64 | 60 |
|
65 | 61 | steps: |
66 | | - - uses: actions/checkout@v3 |
67 | | - - uses: actions/setup-python@v4 |
68 | | - with: |
69 | | - python-version: '3.11' |
70 | | - architecture: x64 |
| 62 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 63 | + - uses: ./.github/actions/setup |
71 | 64 |
|
72 | | - - name: Download coverage data |
73 | | - uses: actions/download-artifact@v3 |
| 65 | + - uses: actions/download-artifact@cc203385981b70ca67e1cc392babf9cc229d5806 # v4.1.9 |
74 | 66 | with: |
75 | | - name: coverage |
| 67 | + pattern: coverage-data-${{github.run_id}}-* |
| 68 | + merge-multiple: true |
76 | 69 |
|
77 | | - - name: Combine data |
78 | | - env: |
79 | | - TOP: ${{github.workspace}} |
80 | | - COVERAGE_PROCESS_START: ${{github.workspace}}/pyproject.toml |
| 70 | + - name: Combine coverage & fail if it's <100% |
81 | 71 | run: | |
82 | | - # i have problems to combine windows coverage files with linux coverage files |
83 | | - rm .coverage.*.windows-latest |
84 | | - pip install coverage |
| 72 | + uv pip install --upgrade coverage[toml] |
| 73 | +
|
85 | 74 | coverage combine |
86 | | - coverage |
87 | | - coverage report --fail-under 100 |
| 75 | + coverage html --skip-covered --skip-empty |
| 76 | +
|
| 77 | + # Report and write to summary. |
| 78 | + coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |
| 79 | +
|
| 80 | + # Report again and fail if under 100%. |
| 81 | + coverage report --fail-under=100 |
| 82 | +
|
| 83 | + - name: Upload HTML report if check failed |
| 84 | + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4.6.1 |
| 85 | + with: |
| 86 | + name: html-report |
| 87 | + path: htmlcov |
| 88 | + if: ${{ failure() }} |
| 89 | + |
| 90 | + |
| 91 | + publish: |
| 92 | + name: Publish new release |
| 93 | + runs-on: ubuntu-latest |
| 94 | + needs: [test, coverage] |
| 95 | + environment: pypi |
| 96 | + permissions: |
| 97 | + # IMPORTANT: this permission is mandatory for Trusted Publishing |
| 98 | + id-token: write |
| 99 | + # this permission is mandatory to create github releases |
| 100 | + contents: write |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: Checkout main |
| 104 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 105 | + with: |
| 106 | + fetch-depth: 0 |
| 107 | + - uses: ./.github/actions/setup |
| 108 | + |
| 109 | + - name: Check if the commit has a vx.y.z tag |
| 110 | + id: check-version |
| 111 | + run: | |
| 112 | + if git tag --list --points-at ${{ github.sha }} | grep -q -E '^v[0-9]+\.[0-9]+\.[0-9]+$'; then |
| 113 | + echo "is new version" |
| 114 | + echo "should_continue=true" >> "$GITHUB_OUTPUT" |
| 115 | + else |
| 116 | + echo "is not a new version" |
| 117 | + echo "should_continue=false" >> "$GITHUB_OUTPUT" |
| 118 | + fi |
| 119 | +
|
| 120 | + - run: uv pip install hatch scriv |
| 121 | + |
| 122 | + - name: build package |
| 123 | + run: hatch build |
| 124 | + |
| 125 | + - name: Publish package distributions to PyPI |
| 126 | + if: ${{ steps.check-version.outputs.should_continue == 'true' }} |
| 127 | + uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4 |
| 128 | + |
| 129 | + - name: create github release |
| 130 | + if: ${{ steps.check-version.outputs.should_continue == 'true' }} |
| 131 | + env: |
| 132 | + GITHUB_TOKEN: ${{ github.token }} |
| 133 | + run: scriv github-release |
0 commit comments