-
Notifications
You must be signed in to change notification settings - Fork 2
180 lines (154 loc) · 6 KB
/
Copy pathpython-package.yml
File metadata and controls
180 lines (154 loc) · 6 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
name: CI
on:
push:
branches: [main, "release/**"]
pull_request:
branches: [main]
# Least-privilege default: CI only reads the checkout; no write scopes needed.
permissions:
contents: read
# Cancel superseded runs on the same ref so rapid rotation pushes / PR
# syncs don't pile up redundant full-matrix (ubuntu+macOS+windows × 3 py)
# jobs and burn runner minutes. Each ref gets an independent group, so an
# in-progress main-branch run is never cancelled by activity on another ref.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: pytest (${{ matrix.os }}, py${{ matrix.python-version }})
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
# PR runs: ubuntu × py3.11 only (fast feedback).
# Push to main / release branches: full matrix incl. windows-latest (#121).
os: ${{ fromJson(github.event_name == 'pull_request' && '["ubuntu-latest"]' || '["ubuntu-latest","macos-latest","windows-latest"]') }}
python-version: ${{ fromJson(github.event_name == 'pull_request' && '["3.11"]' || '["3.10","3.11","3.12"]') }}
env:
# macOS first-run matplotlib font-cache build dominates wall-clock (~30s).
# Per-run tmpdir keeps the cache off `$HOME` so it doesn't survive
# the runner cleanup; cheap on ubuntu/windows. #122
MPLCONFIGDIR: ${{ runner.temp }}/mpl-cache-${{ github.run_id }}-${{ github.run_attempt }}
steps:
- uses: actions/checkout@v5
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
check-latest: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package and dev dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
- name: Run pytest (PR — fast subset, parallel, exclude slow)
if: github.event_name == 'pull_request'
env:
MPLBACKEND: Agg
run: python -m pytest -n auto -m "not slow"
- name: Run pytest (push — full suite, parallel, coverage-gated)
if: github.event_name != 'pull_request'
env:
MPLBACKEND: Agg
run: python -m pytest -n auto -v --cov=src/chilmesh --cov-report=term --cov-fail-under=80
build-and-smoke:
name: build sdist+wheel + smoke install
if: github.event_name != 'pull_request'
needs: test
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.12"
check-latest: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Build sdist + wheel
run: |
python -m pip install --upgrade pip build
python -m build
- name: twine check
run: |
python -m pip install twine
python -m twine check dist/*
- name: Smoke test installed wheel
shell: bash
run: |
python -m venv "$RUNNER_TEMP/smoke"
VENV_PY=$(python -c "import os, sys; root = os.environ['RUNNER_TEMP'] + '/smoke'; print(root + ('/Scripts/python.exe' if sys.platform == 'win32' else '/bin/python'))")
"$VENV_PY" -m pip install --upgrade pip
"$VENV_PY" -m pip install dist/*.whl
"$VENV_PY" -c "import chilmesh; m = chilmesh.examples.annulus(); print('OK', m.n_elems)"
cpp-equivalence:
name: cpp backend parity (ubuntu)
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
check-latest: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package, dev deps, and C++ backend
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]"
python -m pip install ./src/chilmesh_cpp
- name: Assert C++ backend is active (no silent skip)
run: |
python - <<'PY'
import chilmesh, sys
info = chilmesh.backend_info()
print("backend_info:", info)
if "cpp" not in info["available"]:
sys.exit("C++ backend not available — wheel build/install failed; "
"parity suite would silently skip")
PY
- name: Run cross-backend equivalence suite
env:
MPLBACKEND: Agg
run: python -m pytest tests/test_backend_equivalence.py -v
rust-equivalence:
name: rust backend parity (ubuntu)
runs-on: ubuntu-latest
timeout-minutes: 25
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
check-latest: true
cache: pip
cache-dependency-path: pyproject.toml
- name: Set up Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Install package, dev deps, and Rust backend
run: |
python -m pip install --upgrade pip
python -m pip install -e ".[dev]" maturin
maturin build --release --manifest-path src/chilmesh_core/Cargo.toml --out wheelhouse
python -m pip install --force-reinstall wheelhouse/chilmesh_core-*.whl
- name: Assert Rust backend is active (no silent skip)
run: |
python - <<'PY'
import chilmesh, sys
info = chilmesh.backend_info()
print("backend_info:", info)
if "rust" not in info["available"]:
sys.exit("Rust backend not available — crate build/install failed; "
"parity suite would silently skip")
PY
- name: Run cross-backend equivalence suite
env:
MPLBACKEND: Agg
run: python -m pytest tests/test_backend_equivalence.py -v