Skip to content

🔧 Update project from python-template v0.24.0 #221

🔧 Update project from python-template v0.24.0

🔧 Update project from python-template v0.24.0 #221

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
push:
branches: [main, develop]
workflow_call:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
# Many color libraries just need this variable to be set to any value.
# Set it to 3 to support 8-bit color graphics (256 colors per channel)
# for libraries that care about the value set.
FORCE_COLOR: 3
jobs:
format-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: psf/black@stable
with:
jupyter: false
use_pyproject: true
ruff-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/ruff-action@v3
pre-commit:
env:
COLUMNS: 120
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: pre-commit/[email protected]
mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
- name: Install packages
run: >-
uv sync
--all-extras
--no-default-groups
--group typing
--group test
--exact
--locked
- name: List packages
run: uv pip list
- name: Run mypy
run: uv run --no-sync mypy
dependencies:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
- name: Install packages
run: >-
uv sync
--all-extras
--all-groups
--exact
--locked
- name: List packages
run: uv pip list
- name: Run deptry
run: uv run --no-sync --with deptry deptry src/
- name: Run pip-audit
run: >-
uv run --no-sync --with pip-audit pip-audit --skip-editable
--ignore-vuln GHSA-4xh5-x5gv-qwph
# pip-audit ignored vuln:
# GHSA-4xh5-x5gv-qwph:
# vuln is in pip, which is not a pinned requirwement
# vuln is fixed in recent python versions
# see https://github.com/pypa/pip/issues/13607
test:
strategy:
matrix:
include:
# test with highest resolution
- resolution: highest
os: ubuntu-latest
python-version: '3.14'
# test with lowest resolution
- resolution: lowest
os: ubuntu-latest
python-version: '3.10'
# test with different os
- resolution: locked
os: ubuntu-latest
python-version: '3.10'
- resolution: locked
os: macos-latest
python-version: '3.10'
- resolution: locked
os: windows-latest
python-version: '3.10'
fail-fast: false
runs-on: ${{ matrix.os }}
name: test-${{ matrix.python-version }}-${{ matrix.resolution }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
cache-suffix: ${{ matrix.resolution }}
- name: Install packages
id: install_packages
run: >-
uv sync
--all-extras
--no-default-groups
--group test
--exact
${{ matrix.resolution == 'locked' && '--locked'
|| matrix.resolution == 'lowest' && '--upgrade --resolution lowest-direct'
|| matrix.resolution == 'highest' && '--upgrade --resolution highest'
|| '--NON_RECOGNIZED_RESOLUTION'
}}
- name: List packages
run: uv pip list
- name: Run tests
id: run_tests
run: uv run --no-sync pytest --cov-branch --cov-report=xml --junitxml=junit.xml
- name: Upload test results to Codecov
if: ${{ !cancelled() && steps.run_tests.conclusion != 'skipped' }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
test-pypy-and-prerelease:
strategy:
matrix:
include:
# test with pypy
- resolution: highest
os: ubuntu-latest
python-version: 'pypy3.11'
# test on prerelease
- resolution: prerelease
os: ubuntu-latest
python-version: '3.14'
- resolution: prerelease
os: ubuntu-latest
python-version: '3.15'
fail-fast: false
runs-on: ${{ matrix.os }}
name: test-${{ matrix.python-version }}-${{ matrix.resolution }}-${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
with:
python-version: ${{ matrix.python-version }}
cache-suffix: ${{ matrix.resolution }}
- name: Install packages
id: install_packages
run: >-
uv sync
--all-extras
--no-default-groups
--group test
--exact
${{ matrix.resolution == 'locked' && '--locked'
|| matrix.resolution == 'lowest' && '--upgrade --resolution lowest-direct'
|| matrix.resolution == 'highest' && '--upgrade --resolution highest'
|| matrix.resolution == 'prerelease' && '--upgrade --resolution highest --prerelease allow'
|| '--NON_RECOGNIZED_RESOLUTION'
}}
continue-on-error: true
- name: Stop job with warning if install fails
if: ${{ steps.install_packages.outcome == 'failure' }}
run: >-
echo "::warning::Stopping job due to installation failure on Python ${{ matrix.python-version }}"
- name: List packages
if: ${{ steps.install_packages.outcome == 'success' }}
run: uv pip list
- name: Run tests
if: ${{ steps.install_packages.outcome == 'success' }}
run: uv run --no-sync pytest --cov-branch --cov-report=xml --junitxml=junit.xml
pylint:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v5
with:
persist-credentials: false
- uses: astral-sh/setup-uv@v7
- name: Install packages
run: >-
uv sync
--all-extras
--no-default-groups
--exact
--locked
- name: List packages
run: uv pip list
# use pylint exitcode to fail only on errors.
- name: Run Pylint
run: |
set +e
uv run --no-sync --with pylint pylint src --output-format=github
result=$?
set -e
[ $((result & 1)) -ne 0 ] && echo "::error ::Pylint fatal(s) found"
[ $((result & 2)) -ne 0 ] && echo "::error ::Pylint error(s) found"
[ $((result & 4)) -ne 0 ] && echo "::warning ::Pylint warning(s) found"
[ $((result & 8)) -ne 0 ] && echo "::warning ::Pylint refactor(s) found"
[ $((result & 16)) -ne 0 ] && echo "::warning ::Pylint convention(s) found"
[ $((result & 32)) -ne 0 ] && echo "::error ::Pylint usage error"
exit $((result & 35))
pass:
if: ${{ always() }}
needs:
- format-python
- ruff-check
- pre-commit
- mypy
- dependencies
- test
- test-pypy-and-prerelease
- pylint
runs-on: ubuntu-latest
steps:
- uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}