Merge pull request #29 from cleder/pre-commit-ci-update-config #113
This file contains 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
# This workflow will install Python dependencies, | |
# run tests and lint with a variety of Python versions | |
--- | |
name: Tests | |
on: [push, pull_request] | |
jobs: | |
cpython: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: | |
- '3.10' | |
- '3.11' | |
- '3.12' | |
- '3.13' | |
- '3.14-dev' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
uv sync --extra tests | |
- name: Test with pytest | |
run: | | |
uv run pytest tests --cov=tests --cov=vercheck --cov-report=xml | |
- name: "Upload coverage to Codecov" | |
if: ${{ matrix.python-version==3.12 }} | |
uses: codecov/codecov-action@v5 | |
with: | |
fail_ci_if_error: true | |
verbose: true | |
token: ${{ secrets.CODECOV_TOKEN }} | |
static-tests: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version-file: "pyproject.toml" | |
- name: Install dependencies | |
run: | | |
uv sync --all-extras | |
- name: Typecheck | |
run: | | |
uv run mypy src/vercheck tests | |
- name: Linting | |
run: | | |
uv run flake8 src/vercheck tests --max-line-length=88 | |
uv run ruff check --no-fix src/vercheck tests | |
uv run ruff format --check src/vercheck tests | |
uv run yamllint .github/workflows/ | |
- name: Check complexity | |
run: | | |
uv run radon cc --min B src/vercheck | |
uv run radon mi --min B src/vercheck | |
uv run lizard -l python -w src/vercheck | |
build-package: | |
name: Build & inspect our package. | |
runs-on: ubuntu-latest | |
needs: [cpython, static-tests] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v4 | |
with: | |
enable-cache: true | |
- uses: hynek/build-and-inspect-python-package@v2 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version-file: "pyproject.toml" | |
- name: Install dependencies | |
run: | | |
uv sync --extra build | |
- name: Check with pyroma | |
run: | | |
uv run pyroma . | |
- name: Check tag name | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
run: | | |
uv run vercheck $GITHUB_REF_NAME src/vercheck/about.py | |
test-publish: | |
if: >- | |
github.event_name == 'push' && | |
github.repository == 'cleder/vercheck' && | |
startsWith(github.ref, 'refs/tags') | |
needs: build-package | |
name: Test install on TestPyPI | |
runs-on: ubuntu-latest | |
environment: test-release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download packages built by build-package | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist | |
- name: Upload package to Test PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
publish: | |
if: >- | |
github.event_name == 'push' && | |
github.repository == 'cleder/vercheck' && | |
github.ref == 'refs/heads/main' | |
needs: build-package | |
name: Build and publish to PyPI and TestPyPI | |
runs-on: ubuntu-latest | |
environment: release | |
permissions: | |
id-token: write | |
steps: | |
- name: Download packages built by build-package | |
uses: actions/download-artifact@v4 | |
with: | |
name: Packages | |
path: dist | |
- name: Publish distribution 📦 to PyPI for push to main | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
... |