Skip to content

Merge pull request #62 from mxstack/feature/54-fixed-install-mode #124

Merge pull request #62 from mxstack/feature/54-fixed-install-mode

Merge pull request #62 from mxstack/feature/54-fixed-install-mode #124

Workflow file for this run

name: Testing
on:
push:
pull_request:
types:
- "reopened"
- "opened"
workflow_call:
workflow_dispatch:
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Run lint with tox
run: uvx --with tox-uv tox -e lint
test:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-config:
- version: "3.8"
tox-env: "py38"
- version: "3.9"
tox-env: "py39"
- version: "3.10"
tox-env: "py310"
- version: "3.11"
tox-env: "py311"
- version: "3.12"
tox-env: "py312"
- version: "3.13"
tox-env: "py313"
- version: "3.14"
tox-env: "py314"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0 # Fetch all history for hatch-vcs to work
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python ${{ matrix.python-config.version }}
run: uv python install ${{ matrix.python-config.version }}
- name: Configure git for tests
run: git config --global protocol.file.allow always
- name: Run tests with tox
run: uvx --with tox-uv tox -e ${{ matrix.python-config.tox-env }}
# Upload coverage data from this matrix job
- name: Upload coverage data
uses: actions/upload-artifact@v4
with:
name: coverage-data-${{ matrix.os }}-${{ matrix.python-config.tox-env }}
path: .coverage.*
include-hidden-files: true
if-no-files-found: ignore
# Combine coverage from all matrix jobs and report
coverage:
name: Combine & check coverage
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
run: uv python install 3.12
- name: Create virtual environment
run: uv venv
- name: Install coverage
run: uv pip install coverage[toml]
# Download all coverage artifacts from matrix jobs
- name: Download coverage data
uses: actions/download-artifact@v4
with:
pattern: coverage-data-*
merge-multiple: true
# Combine all .coverage.* files into one .coverage database
- name: Combine coverage data
run: |
uv run python -Im coverage combine
uv run python -Im coverage html
uv run python -Im coverage json
# Export total coverage percentage for badge
export TOTAL=$(uv run python -c "import json;print(json.load(open('coverage.json'))['totals']['percent_covered_display'])")
echo "total=$TOTAL" >> $GITHUB_ENV
echo "### Total coverage: ${TOTAL}%" >> $GITHUB_STEP_SUMMARY
# Generate markdown report and add to GitHub summary
- name: Generate coverage report
run: |
echo "## Coverage Report" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
uv run python -Im coverage report --format=markdown >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Upload HTML coverage report as artifact for debugging
- name: Upload HTML coverage report
uses: actions/upload-artifact@v4
with:
name: html-coverage-report
path: htmlcov/
# Fail if coverage is below threshold
- name: Fail if coverage is below threshold
run: |
uv run python -Im coverage report --fail-under=35