Skip to content

PERF: implement multi-threading parallelism in inifix-validate CLI #1276

PERF: implement multi-threading parallelism in inifix-validate CLI

PERF: implement multi-threading parallelism in inifix-validate CLI #1276

Workflow file for this run

name: CI
on:
push:
branches:
- main
pull_request:
paths-ignore:
- README.md
- CHANGELOG.md
concurrency:
# auto-cancel any in-progress job *on the same branch*
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
unit-tests:
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- '3.11'
- '3.12'
- '3.13'
include:
- os: ubuntu-20.04
python-version: 3.10.0
label: oldestdeps
- os: macos-latest
python-version: 3.10.0
- os: macos-latest
python-version: '3.13'
- os: windows-latest
python-version: 3.10.0
- os: windows-latest
python-version: '3.13'
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
with:
python-version: ${{ matrix.python-version }}
- if: ${{ matrix.label == 'oldestdeps' }}
run: echo "UV_RESOLUTION=lowest-direct" >> $GITHUB_ENV
- name: Run tests (without coverage)
if: ${{ ! startswith( matrix.os, 'ubuntu' ) }}
shell: bash # for windows portability
run: |
uv run --frozen --no-editable --group test \
pytest --color=yes
- name: Run tests (with coverage)
if: ${{ startswith( matrix.os, 'ubuntu' ) }}
run: |
uv run --group covcheck \
coverage run --parallel-mode -m pytest --color=yes
- name: Upload coverage data
# only using reports from ubuntu because
# combining reports from multiple platforms is tricky (or impossible ?)
if: ${{ startswith( matrix.os, 'ubuntu' ) }}
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: inifix_coverage_data-${{ matrix.os }}-${{ matrix.python-version }}
path: .coverage.*
if-no-files-found: ignore
include-hidden-files: true
concurrency-tests:
strategy:
matrix:
os:
- ubuntu-latest
python-version:
- 3.10.0
- '3.13'
- 3.13t
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
with:
python-version: ${{ matrix.python-version }}
- run: uv sync --frozen --no-editable --group concurrency
- run: |
uv run --no-sync \
pytest --color=yes --count 100 -k concurrency
coverage:
name: Combine & check coverage
runs-on: ubuntu-latest
needs: unit-tests
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
- run: uv sync --only-group covcheck
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
with:
pattern: inifix_coverage_data-*
merge-multiple: true
- name: Check coverage
run: |
uv run coverage combine
uv run coverage html --skip-covered --skip-empty
uv run coverage report --fail-under=100
- name: Upload HTML report if check failed.
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: inifix_coverage_report
path: htmlcov
if: ${{ failure() }}
type-check:
strategy:
matrix:
python-version:
- '3.10'
- '3.13'
typechecker:
- mypy
- pyright
- basedpyright
runs-on: ubuntu-latest
name: type check
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
with:
python-version: ${{ matrix.python-version }}
- run: uv sync --frozen --group typecheck
- name: Typecheck source code (inifix-cli)
run: uv run --no-sync ${{ matrix.typechecker }} src
- name: Typecheck source code (inifix)
run: uv run --no-sync ${{ matrix.typechecker }} lib/inifix/src typechecks
- name: Verify Types (pyright only)
if: ${{ startsWith( matrix.typechecker , 'pyright' ) }}
run: uv run --no-sync ${{ matrix.typechecker }} --verifytypes inifix
optimized_python:
runs-on: ubuntu-latest
name: optimized Python
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-optimized
cancel-in-progress: true
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
with:
python-version: '3.13'
- name: Run pytest with PYTHONOPTIMIZE=2
run: |
uv run --frozen --no-editable --group test \
pytest --color=yes
env:
PYTHONOPTIMIZE: 2
pre-publish-checks:
runs-on: ubuntu-latest
name: pre-publication checks
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- uses: astral-sh/setup-uv@4db96194c378173c656ce18a155ffc14a9fc4355 # v5.2.2
- run: uv run scripts/pre_publish_checks.py