117 lines
2.8 KiB
YAML
117 lines
2.8 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
pull_request:
|
|
|
|
jobs:
|
|
|
|
style-check:
|
|
name: Code Style (autopep8)
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install PDM + autopep8
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install pdm autopep8
|
|
|
|
- name: Install dependencies
|
|
run: pdm install --dev
|
|
|
|
- name: Run autopep8 style check
|
|
run: |
|
|
autopep8 --recursive --diff --exit-code --ignore E501 src
|
|
continue-on-error: false
|
|
|
|
|
|
tests:
|
|
name: Tests (Python ${{ matrix.python-version }})
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
matrix:
|
|
python-version: ["3.12", "3.13", "3.14"]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: ${{ matrix.python-version }}
|
|
|
|
- name: Install PDM
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install pdm
|
|
|
|
- name: Install dependencies
|
|
run: pdm install --dev
|
|
|
|
- name: Run tests
|
|
run: pdm run test
|
|
|
|
|
|
coverage:
|
|
name: Coverage (Python 3.12)
|
|
runs-on: ubuntu-latest
|
|
needs: tests
|
|
|
|
steps:
|
|
- name: Checkout (with parent)
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 2
|
|
|
|
- name: Install Python 3.12
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: "3.12"
|
|
|
|
- name: Install PDM
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install pdm
|
|
|
|
- name: Run coverage on parent commit
|
|
run: |
|
|
git checkout HEAD^
|
|
pdm install --dev
|
|
pdm run coverage
|
|
pdm run python -m coverage json -o /tmp/parent-coverage.json
|
|
git checkout -
|
|
|
|
- name: Install dependencies
|
|
run: pdm install --dev
|
|
|
|
- name: Run coverage on current commit
|
|
run: |
|
|
pdm run coverage
|
|
pdm run python -m coverage json -o /tmp/current-coverage.json
|
|
|
|
- name: Check coverage did not decrease
|
|
run: |
|
|
pdm run python -c "
|
|
import json, sys
|
|
with open('/tmp/parent-coverage.json') as f:
|
|
parent = json.load(f)['totals']['percent_covered']
|
|
with open('/tmp/current-coverage.json') as f:
|
|
current = json.load(f)['totals']['percent_covered']
|
|
print(f'Parent coverage: {parent:.2f}%')
|
|
print(f'Current coverage: {current:.2f}%')
|
|
if current < parent:
|
|
print(f'ERROR: Coverage decreased by {parent - current:.2f}%')
|
|
sys.exit(1)
|
|
print(f'OK: Coverage maintained or improved by {current - parent:.2f}%')
|
|
"
|