Skip to content

Update pre-commit hook renovatebot/pre-commit-hooks to v42.92.14 #476

Update pre-commit hook renovatebot/pre-commit-hooks to v42.92.14

Update pre-commit hook renovatebot/pre-commit-hooks to v42.92.14 #476

name: Lint, Type-Check, Test, Build and Publish Package
"on":
pull_request:
branches: [main]
push:
branches: [main]
tags: [v*]
jobs:
uv-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Check uv.lock (ensure all dependencies up to date)
run: uv lock --check
# yamllint disable-line rule:key-ordering
flake8:
env:
SKIP_MISSING_DOWNDOC: "True"
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
needs: [uv-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set Up Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install Flake8 From Locked Dependencies
run: uv sync --no-group dev --group lint-format
- name: Run Flake8
run: uv run -- flake8
# yamllint disable-line rule:key-ordering
mypy:
env:
SKIP_MISSING_DOWNDOC: "True"
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
needs: [uv-check]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
component: [package, scripts, tests]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
exclude: # yamllint disable-line rule:key-ordering
- component: scripts
include: # yamllint disable-line rule:key-ordering
- component: scripts
python-version: ""
steps:
- uses: actions/checkout@v6
- if: matrix.component == 'package' || matrix.component == 'tests'
name: Set Up Python (Using Matrix Version)
uses: actions/setup-python@v6
with:
python-version: ${{matrix.python-version}}
- if: matrix.component == 'scripts'
name: Set Up Python (Using .python-version File)
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- if: matrix.component == 'package' || matrix.component == 'tests'
name: Install uv (With Matrix Python Version)
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{matrix.python-version}}
- if: matrix.component == 'scripts'
name: Install uv (With .python-version File)
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install mypy From Locked Dependencies
run: |
if [ "${{matrix.component}}" == "package" ]; then
ARGS=("--no-group" "dev" "--group" "type-check")
elif [ "${{matrix.component}}" == "scripts" ]; then
ARGS=("--only-group" "type-check" "--only-group" "build-dev")
elif [ "${{matrix.component}}" == "tests" ]; then
ARGS=("--no-group" "dev" "--group" "type-check" "--group" "test")
else
echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2
exit 1
fi
uv sync "${ARGS[@]}"
- id: store-hashed-python-version
name: Store Hashed Python Version
run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)"
>> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
key: mypy|${{steps.store-hashed-python-version.outputs.hashed_python_version}}|${{matrix.component}}
path: ./.mypy_cache
- name: Run mypy # TODO: Add GitHub workflows output format
run: |
if [ "${{matrix.component}}" == "package" ]; then
ARGS=("typed_classproperties/")
elif [ "${{matrix.component}}" == "scripts" ]; then
ARGS=("hatch_build.py")
elif [ "${{matrix.component}}" == "tests" ]; then
ARGS=("tests.py")
else
echo "Error: Unknown matrix.component value: '${{matrix.component}}'" >&2
exit 1
fi
uv run -- mypy "${ARGS[@]}"
# yamllint disable-line rule:key-ordering
pre-commit:
env:
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Add GB Locale
run: |
sudo apt-get update
sudo apt-get install -y locales
sudo locale-gen en_GB.UTF-8
shell: bash
- name: Set Up Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install prek From Locked Dependencies
run: uv sync --only-group pre-commit
- id: store-hashed-python-version
name: Store Hashed Python Version
run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)"
>> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
key: prek|${{steps.store-hashed-python-version.outputs.hashed_python_version}}|${{hashFiles('.pre-commit-config.yaml')}}
path: ~/.cache/prek
- name: Setup pre-commit Environments
run: uv run -- prek install-hooks
- name: Run prek
run: |
set -o pipefail
uv run -- prek run --all-files --hook-stage manual --color never --skip ruff-check --skip uv-lock --skip flake8 | tee /tmp/prek.log
- name: Ensure No Warnings
run: "if grep -q '^warning: ' /tmp/prek.log; then exit 1; fi"
- if: "!cancelled()"
uses: pre-commit-ci/lite-action@v1.1.0
# yamllint disable-line rule:key-ordering
pytest:
env:
SKIP_MISSING_DOWNDOC: "True"
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
needs: [uv-check]
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set Up Python
uses: actions/setup-python@v6
with:
python-version: ${{matrix.python-version}}
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
python-version: ${{matrix.python-version}}
- name: Install pytest From Locked Dependencies
run: uv sync --no-group dev --group test
- id: store-hashed-python-version
name: Store Hashed Python Version
run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)"
>> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
key: pytest|${{steps.store-hashed-python-version.outputs.hashed_python_version}}
path: ./.pytest_cache
- name: Run pytest # TODO: Add GitHub workflows output format
run: uv run -- pytest
# yamllint disable-line rule:key-ordering
ruff-lint:
env:
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set Up Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install ruff From Locked Dependencies
run: uv sync --only-group lint-format
- id: store-hashed-python-version
name: Store Hashed Python Version
run: echo "hashed_python_version=$(uv run -- python -VV | sha256sum | cut -d' ' -f1)"
>> "$GITHUB_OUTPUT"
- uses: actions/cache@v5
with:
key: ruff|${{steps.store-hashed-python-version.outputs.hashed_python_version}}
path: ./.ruff_cache
- name: Run Ruff
run: uv run -- ruff check --no-fix --output-format=github
# yamllint disable-line rule:key-ordering
build:
env:
SKIP_MISSING_DOWNDOC: "False"
UV_FROZEN: true
UV_NO_SYNC: true
UV_PYTHON_DOWNLOADS: never
needs: [flake8, mypy, pre-commit, pytest, ruff-lint, uv-check]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set Up Python
uses: actions/setup-python@v6
with:
python-version-file: .python-version
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install downdoc
run: uv tool install Pydowndoc-bin
- name: Build Package
run: uv build --no-sources --build
- name: Save Build Artifacts
uses: actions/upload-artifact@v6
with:
name: built-typed_classproperties-package
path: dist/
# yamllint disable-line rule:key-ordering
publish:
environment: publish
if: github.ref_type == 'tag'
needs: [build]
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Download Build Artifacts
uses: actions/download-artifact@v7
with:
name: built-typed_classproperties-package
path: dist/
- name: Publish to PyPI
run: uv publish
# yamllint disable-line rule:key-ordering
test-publish:
environment: test-publish
if: (github.event_name != 'push' || github.ref_type != 'tag') && (github.event_name != 'pull_request'
|| github.event.pull_request.head.repo.full_name == 'CarrotManMatt/typed_classproperties')
needs: [build]
permissions:
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Download Build Artifacts
uses: actions/download-artifact@v7
with:
name: built-typed_classproperties-package
path: dist/
- name: Publish to Test-PyPI
run: uv publish --index Test-PyPI
# yamllint disable-line rule:key-ordering
release:
if: github.ref_type == 'tag'
needs: [publish]
permissions:
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- name: Download Build Artifacts
uses: actions/download-artifact@v7
with:
name: built-typed_classproperties-package
path: dist/
- name: Sign Build Artifacts
uses: sigstore/gh-action-sigstore-python@v3.2.0
with:
inputs: ./dist/typed_classproperties-*.tar.gz ./dist/typed_classproperties-*.whl
- name: Create GitHub Release
# yamllint disable-line rule:key-ordering
env:
GITHUB_TOKEN: ${{github.token}}
run: gh release create '${{github.ref_name}}' dist/** --repo '${{github.repository}}'
--verify-tag --generate-notes