-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (130 loc) · 4.41 KB
/
Copy pathci.yml
File metadata and controls
143 lines (130 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: CI
on:
push:
branches: [master]
pull_request:
workflow_dispatch:
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
# Read-only by default. A job that needs more asks for it itself, so a
# compromised dependency in one step cannot push to the repository.
permissions:
contents: read
env:
PYTHONUNBUFFERED: "1"
PIP_DISABLE_PIP_VERSION_CHECK: "1"
FORCE_COLOR: "1"
jobs:
lint:
name: Lint and types
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- run: pip install -e ".[dev]"
# No `ruff format --check` yet: twenty files predate the formatter and
# reformatting them belongs in its own commit, not in a lint gate that
# would be red from the day it lands. pre-commit formats what a
# contributor touches in the meantime.
- name: ruff check
run: python -m ruff check .
- name: mypy
run: python -m mypy glia
test:
name: Tests (Python ${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v7
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install (dev extras)
run: |
python -m pip install --upgrade pip
pip install -e ".[dev]"
- name: Tests (pytest, fully offline) + coverage gate
run: python -m pytest -q --cov=glia --cov-report=term-missing --cov-fail-under=90
- name: Examples run offline
run: |
for f in examples/0*.py; do
echo "--- $f ---"
python "$f"
done
platforms:
name: Tests (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
cache: pip
cache-dependency-path: pyproject.toml
- run: pip install -e ".[dev]"
# The suite only, without the coverage gate and the examples loop. The
# shell ships Windows and macOS binaries, so the library underneath them
# has to be known to work there; the gate and the examples are already
# measured once on Linux and measuring them three times says nothing new.
- name: Tests
run: python -m pytest -q
build:
name: Package builds and installs cleanly
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: "3.12"
- run: pip install build twine
- name: Build the wheel and sdist
run: python -m build
- name: Check the metadata
run: twine check dist/*
# An editable install hides packaging mistakes: it puts the working tree
# on the path, so a module missing from the wheel still imports and a
# broken console script still resolves.
- name: Install the wheel into a clean environment
run: |
python -m venv /tmp/fresh
/tmp/fresh/bin/pip install dist/*.whl
# The distribution is glia-agents and the import package is glia.
# That mismatch is the one packaging mistake nobody notices locally.
/tmp/fresh/bin/python -c "import glia; print(glia.__name__)"
/tmp/fresh/bin/glia-shell --help > /dev/null
- uses: actions/upload-artifact@v7
with:
name: dist
path: dist/
retention-days: 14
ci:
name: CI
runs-on: ubuntu-latest
if: always()
needs: [lint, test, platforms, build]
steps:
# One aggregate check to require in branch protection. Without it, adding
# a job to the matrix silently leaves it unrequired, and a red job stops
# blocking merges.
- name: Fail if any job did not succeed
if: contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
run: |
echo "One or more jobs failed:"
echo '${{ toJSON(needs) }}'
exit 1
- run: echo "All checks passed."