|
1 | | -name: lint_python |
2 | | -on: [pull_request, push] |
| 1 | +name: Python CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + pull_request: |
| 6 | + |
| 7 | +permissions: |
| 8 | + contents: read |
| 9 | + |
| 10 | +concurrency: |
| 11 | + group: python-ci-${{ github.workflow }}-${{ github.ref }} |
| 12 | + cancel-in-progress: true |
| 13 | + |
3 | 14 | jobs: |
4 | | - lint_python: |
| 15 | + quality: |
| 16 | + name: Lint, type-check, and test |
5 | 17 | runs-on: ubuntu-24.04 |
| 18 | + timeout-minutes: 15 |
6 | 19 | steps: |
7 | 20 | - uses: actions/checkout@v6 |
| 21 | + |
8 | 22 | - uses: actions/setup-python@v6 |
9 | 23 | with: |
10 | | - python-version: 3.12 |
11 | | - - name: Install dependencies |
| 24 | + python-version: "3.12" |
| 25 | + cache: pip |
| 26 | + cache-dependency-path: Pipfile.lock |
| 27 | + |
| 28 | + - name: Run quality checks |
| 29 | + run: ./lint.sh |
| 30 | + |
| 31 | + tests: |
| 32 | + name: Test on Python ${{ matrix.python-version }} |
| 33 | + runs-on: ubuntu-24.04 |
| 34 | + timeout-minutes: 15 |
| 35 | + strategy: |
| 36 | + fail-fast: false |
| 37 | + matrix: |
| 38 | + python-version: |
| 39 | + - "3.10" |
| 40 | + - "3.11" |
| 41 | + - "3.12" |
| 42 | + - "3.13" |
| 43 | + - "3.14" |
| 44 | + steps: |
| 45 | + - uses: actions/checkout@v6 |
| 46 | + |
| 47 | + - uses: actions/setup-python@v6 |
| 48 | + with: |
| 49 | + python-version: ${{ matrix.python-version }} |
| 50 | + cache: pip |
| 51 | + cache-dependency-path: Pipfile.lock |
| 52 | + |
| 53 | + - name: Install locked dependencies |
12 | 54 | run: | |
13 | 55 | python -m pip install --upgrade pip |
14 | | - pip install pipenv |
15 | | - pipenv sync --dev --system |
16 | | - pip install --no-build-isolation --no-deps -e . |
17 | | - - name: Lint with flake8 |
18 | | - run: flake8 ./patterns --count --show-source --statistics |
19 | | - continue-on-error: true |
20 | | - - name: Format check with isort and black |
21 | | - run: | |
22 | | - isort --profile black --check ./patterns |
23 | | - black --check ./patterns |
24 | | - continue-on-error: true |
25 | | - - name: Type check with mypy |
26 | | - run: mypy --ignore-missing-imports ./patterns || true |
27 | | - continue-on-error: true |
28 | | - - name: Run tests with pytest |
29 | | - run: | |
30 | | - pytest ./patterns |
31 | | - pytest --doctest-modules ./patterns || true |
32 | | - continue-on-error: true |
33 | | - - name: Check Python version compatibility |
34 | | - run: shopt -s globstar && pyupgrade --py310-plus ./patterns/**/*.py |
35 | | - continue-on-error: true |
36 | | - - name: Run tox |
37 | | - run: tox |
38 | | - continue-on-error: true |
| 56 | + python -m pip install pipenv |
| 57 | + pipenv requirements --dev > "${RUNNER_TEMP}/requirements-dev.txt" |
| 58 | + python -m pip install -r "${RUNNER_TEMP}/requirements-dev.txt" |
| 59 | + python -m pip install --no-build-isolation --no-deps -e . |
| 60 | +
|
| 61 | + - name: Run tests |
| 62 | + run: python -m pytest tests patterns |
0 commit comments