Merge pull request #97 from cleder/pre-commit-ci-update-config #428
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
# 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.12', '3.13', 3.14-dev] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -e ".[tests]" | |
- name: Test with pytest | |
run: | | |
pytest tests --cov=tests --cov=crepr --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 | |
strategy: | |
matrix: | |
python-version: ['3.12'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install -e ".[typing, complexity, linting]" | |
- name: Typecheck | |
run: | | |
mypy crepr tests | |
- name: Linting | |
run: | | |
flake8 crepr tests --max-line-length=88 | |
black --check crepr tests | |
ruff check --no-fix crepr tests | |
yamllint .github/workflows/ | |
- name: Check complexity | |
run: | | |
radon cc --min B crepr | |
radon mi --min B crepr | |
lizard -l python -w crepr | |
build-package: | |
name: Build & inspect our package. | |
runs-on: ubuntu-latest | |
needs: [cpython, static-tests] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hynek/build-and-inspect-python-package@v2 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: '3.12' | |
- name: Check with pyroma | |
run: | | |
python -m pip install pyroma | |
pyroma . | |
- name: Check tag name | |
if: >- | |
github.event_name == 'push' && | |
startsWith(github.ref, 'refs/tags') | |
run: | | |
python -m pip install vercheck | |
python -m pip install . | |
vercheck $GITHUB_REF_NAME | |
test-publish: | |
if: >- | |
github.event_name == 'push' && | |
github.repository == 'cleder/crepr' && | |
startsWith(github.ref, 'refs/tags') | |
needs: build-package | |
name: Test install on TestPyPI | |
runs-on: ubuntu-latest | |
environment: release-test | |
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/crepr' && | |
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 | |
... |