tests #49
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: tests | |
| on: | |
| push: | |
| # Avoid using all the resources/limits available by checking only | |
| # relevant branches and tags. Other branches can be checked via PRs. | |
| branches: [master] | |
| tags: ['v[0-9]*', '[0-9]+.[0-9]+*'] # Match tags that resemble a version | |
| pull_request: | |
| workflow_dispatch: # Allow manually triggering the workflow | |
| schedule: | |
| # Run roughly every 15 days at 00:00 UTC | |
| # (useful to check if updates on dependencies break the package) | |
| - cron: '0 0 1,16 * *' | |
| concurrency: | |
| group: >- | |
| ${{ github.workflow }}-${{ github.ref_type }}- | |
| ${{ github.event.pull_request.number || github.sha }} | |
| cancel-in-progress: true | |
| jobs: | |
| prepare: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| wheel-distribution: ${{ steps.wheel-distribution.outputs.path }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: {fetch-depth: 0} # deep clone for setuptools-scm | |
| - uses: actions/setup-python@v5 | |
| with: {python-version-file: "pyproject.toml"} | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Run static analysis and format checkers | |
| run: uv run --with '.[dev]' pre-commit run --all-files | |
| - name: Build package distribution files | |
| run: uv build | |
| - name: Record the path of wheel distribution | |
| id: wheel-distribution | |
| run: echo "path=$(ls dist/*.whl)" >> $GITHUB_OUTPUT | |
| - name: Store the distribution files for use in other stages | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: python-distribution-files | |
| path: dist/ | |
| retention-days: 1 | |
| test: | |
| needs: prepare | |
| strategy: | |
| matrix: | |
| python: | |
| - "3.8" # oldest Python supported by validate-pyproject | |
| - "3.x" # newest Python that is stable | |
| platform: | |
| - ubuntu-latest | |
| - macos-13 | |
| - windows-latest | |
| runs-on: ${{ matrix.platform }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: ${{ matrix.python }} | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Retrieve pre-built distribution files | |
| uses: actions/download-artifact@v4 | |
| with: {name: python-distribution-files, path: dist/} | |
| - name: Run tests | |
| run: uv run --with '.[dev]' pytest --cov-report=lcov:coverage.lcov | |
| - name: Upload partial coverage report | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| path-to-lcov: coverage.lcov | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| flag-name: ${{ matrix.platform }} - py${{ matrix.python }} | |
| parallel: true | |
| finalize: | |
| needs: test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Finalize coverage report | |
| uses: coverallsapp/github-action@v2 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| parallel-finished: true | |
| publish: | |
| needs: finalize | |
| if: ${{ github.event_name == 'push' && contains(github.ref, 'refs/tags/') }} | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: {python-version-file: "pyproject.toml"} | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Retrieve pre-built distribution files | |
| uses: actions/download-artifact@v4 | |
| with: {name: python-distribution-files, path: dist/} | |
| - name: Publish Package to PyPI | |
| run: uv publish dist/* |