Use uv github actions #550
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: on-push | |
| on: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - '*' | |
| pull_request: | |
| branches: | |
| - main | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| defaults: | |
| run: | |
| shell: bash -l {0} | |
| jobs: | |
| pre-commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: 3.x | |
| - uses: pre-commit/action@v3.0.1 | |
| unit-tests: | |
| name: unit-tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.7.20" | |
| enable-cache: true | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Run unit tests | |
| run: uv run --frozen -m pytest . | |
| type-check: | |
| needs: [unit-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.7.20" | |
| enable-cache: true | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Run type checking | |
| run: uv run --frozen -m mypy . | |
| docs-build: | |
| needs: [unit-tests] | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.7.20" | |
| enable-cache: true | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: ".python-version" | |
| - name: Build documentation | |
| run: uv run --frozen make docs-build | |
| integration-tests: | |
| needs: [unit-tests] | |
| if: | | |
| success() && true | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| python-version: | |
| - "3.11" | |
| - "3.12" | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv and set the python version | |
| uses: astral-sh/setup-uv@v6 | |
| with: | |
| version: "0.7.20" | |
| enable-cache: true | |
| python-version: ${{ matrix.python-version }} | |
| - name: Run unit tests | |
| run: uv run --frozen -m pytest . | |
| minver-tests: | |
| needs: [unit-tests] | |
| if: | | |
| success() && true | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install uv and set the python version | |
| uses: astral-sh/setup-uv@v5 | |
| - name: Run tests | |
| run: uv run --resolution lowest-direct -p python3.11 -m pytest . | |
| distribution: | |
| runs-on: ubuntu-latest | |
| needs: [unit-tests, type-check, docs-build, integration-tests] | |
| if: | | |
| always() && | |
| needs.unit-tests.result == 'success' && | |
| needs.type-check.result == 'success' && | |
| needs.docs-build.result == 'success' && | |
| (needs.integration-tests.result == 'success' || needs.integration-tests.result == 'skipped') | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install package | |
| run: | | |
| python -m pip install --upgrade pip | |
| python -m pip install build twine | |
| - name: Build distribution | |
| run: | | |
| python -m build | |
| - name: Check wheels | |
| run: | | |
| cd dist || exit | |
| python -m pip install sarsen*.whl || exit | |
| python -m twine check --strict * || exit | |
| python -c "import sarsen" || exit | |
| cd .. | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: distribution | |
| path: dist | |
| upload-to-pypi: | |
| runs-on: ubuntu-latest | |
| needs: distribution | |
| if: | | |
| always() && true && | |
| needs.distribution.result == 'success' && | |
| github.event_name == 'push' && | |
| startsWith(github.ref, 'refs/tags') | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/sarsen | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publish | |
| steps: | |
| - uses: actions/download-artifact@v5 | |
| with: | |
| name: distribution | |
| path: dist | |
| - uses: pypa/gh-action-pypi-publish@v1.12.4 | |
| with: | |
| verbose: true |