|
| 1 | +name: lint-and-test |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + tags-ignore: |
| 9 | + - "**" # Skip re-linting when tags are added |
| 10 | + |
| 11 | +jobs: |
| 12 | + lint: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + steps: |
| 16 | + - uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Install uv |
| 19 | + uses: astral-sh/setup-uv@v6 |
| 20 | + with: |
| 21 | + version: "0.6.x" |
| 22 | + enable-cache: true |
| 23 | + cache-dependency-glob: "uv.lock" |
| 24 | + |
| 25 | + - name: Set up Python |
| 26 | + uses: actions/setup-python@v5 |
| 27 | + with: |
| 28 | + python-version-file: "pyproject.toml" |
| 29 | + |
| 30 | + - name: Install dependencies |
| 31 | + run: uv sync --all-extras --dev |
| 32 | + |
| 33 | + - name: Run mypy |
| 34 | + run: uv run mypy . |
| 35 | + if: always() |
| 36 | + |
| 37 | + test: |
| 38 | + runs-on: ubuntu-latest |
| 39 | + strategy: |
| 40 | + matrix: |
| 41 | + python-version: ["3.11", "3.12", "3.13"] |
| 42 | + fail-fast: false |
| 43 | + |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v4 |
| 46 | + |
| 47 | + - name: Install uv |
| 48 | + uses: astral-sh/setup-uv@v6 |
| 49 | + with: |
| 50 | + version: "0.6.x" |
| 51 | + enable-cache: true |
| 52 | + cache-dependency-glob: "uv.lock" |
| 53 | + |
| 54 | + - name: Set up (release) Python ${{ matrix.python-version }} |
| 55 | + uses: actions/setup-python@v5 |
| 56 | + if: "!endsWith(matrix.python-version, '-dev')" |
| 57 | + with: |
| 58 | + python-version: ${{ matrix.python-version }} |
| 59 | + |
| 60 | + - name: Set up (deadsnakes) Python ${{ matrix.python-version }} |
| 61 | + uses: deadsnakes/action@v3.2.0 |
| 62 | + if: endsWith(matrix.python-version, '-dev') |
| 63 | + with: |
| 64 | + python-version: ${{ matrix.python-version }} |
| 65 | + |
| 66 | + - name: Install dependencies |
| 67 | + run: | |
| 68 | + uv venv |
| 69 | + uv pip install tox-gh-actions tox-uv |
| 70 | +
|
| 71 | + - name: Run tests w/tox |
| 72 | + run: uv run tox |
| 73 | + |
| 74 | + - name: Cache coverage for ${{ matrix.python-version }} |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: cov_py${{ matrix.python-version }} |
| 78 | + path: .coverage |
| 79 | + if-no-files-found: error |
| 80 | + include-hidden-files: true |
| 81 | + |
| 82 | + combine-cov: |
| 83 | + runs-on: ubuntu-latest |
| 84 | + needs: test |
| 85 | + |
| 86 | + steps: |
| 87 | + - uses: actions/checkout@v4 |
| 88 | + |
| 89 | + - name: Set up Python |
| 90 | + uses: actions/setup-python@v5 |
| 91 | + with: |
| 92 | + python-version-file: "pyproject.toml" |
| 93 | + |
| 94 | + - name: Pull coverage workflow artifacts |
| 95 | + uses: actions/download-artifact@v4 |
| 96 | + with: |
| 97 | + path: cov_cache/ |
| 98 | + |
| 99 | + - name: Install cov & combine |
| 100 | + run: | |
| 101 | + python -m pip install coverage |
| 102 | + coverage combine ./cov_cache/**/.coverage |
| 103 | +
|
| 104 | + - name: Report coverage |
| 105 | + run: | |
| 106 | + coverage html |
| 107 | +
|
| 108 | + # Report a markdown version to the action summary |
| 109 | + echo '**Combined Coverage**' >> $GITHUB_STEP_SUMMARY |
| 110 | + coverage report --format=markdown >> $GITHUB_STEP_SUMMARY |
| 111 | +
|
| 112 | + - name: Publish cov HTML |
| 113 | + uses: actions/upload-artifact@v4 |
| 114 | + with: |
| 115 | + path: htmlcov/ |
| 116 | + name: cov_report_html |
0 commit comments