uv and GitHub actions #3
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "Continuous Integration" | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| jobs: | |
| tests: | |
| name: python ${{ matrix.python-version }} tests, ${{ matrix.uv-resolution }} dependencies | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| python-version: | |
| - "3.9" | |
| - "3.10" | |
| - "3.11" | |
| - "3.12" | |
| - "3.13" | |
| uv-resolution: | |
| - "lowest" | |
| - "highest" | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv and set the python version | |
| uses: astral-sh/setup-uv@v5 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| cache-dependency-glob: "**/pyproject.toml" | |
| cache-suffix: ${{ matrix.uv-resolution }} | |
| - name: Install the project | |
| run: uv sync --all-extras --dev --resolution ${{ matrix.uv-resolution }} | |
| - name: Run tests | |
| run: | | |
| export COVERAGE_FILE=.coverage.$GITHUB_JOB | |
| uv run pytest --sqlalchemy-connect-url="sqlite:///foo.sqlite" | |
| - name: Upload coverage data | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: coverage-data-${{ matrix.python-version }}-${{ matrix.uv-resolution }} | |
| path: .coverage.* | |
| include-hidden-files: true | |
| if-no-files-found: ignore | |
| coverage: | |
| needs: tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: astral-sh/setup-uv@v5 | |
| with: | |
| cache-dependency-glob: "**/pyproject.toml" | |
| - name: Download coverage data | |
| uses: actions/download-artifact@v4 | |
| with: | |
| pattern: coverage-data-* | |
| merge-multiple: true | |
| - name: Combine coverage and fail if it's <100%. | |
| run: | | |
| uv tool install coverage | |
| coverage combine | |
| coverage html --skip-covered --skip-empty | |
| # Report and write to summary. | |
| coverage report --format=markdown >> $GITHUB_STEP_SUMMARY | |
| # Report again and fail if under 100%. | |
| coverage report --fail-under=100 | |
| - name: Upload HTML report if check failed. | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: html-report | |
| path: htmlcov | |
| if: ${{ failure() }} | |
| build-and-inspect-package: | |
| needs: | |
| - coverage | |
| - tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: hynek/build-and-inspect-python-package@v2 | |
| check-package: | |
| needs: | |
| - build-and-inspect-package | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: cjw296/python-action/check-distributions@v1 | |
| with: | |
| package: ${{ inputs.package }} |