Repository navigation
200 lines (200 loc) · 8.11 KB
/
Copy pathpython-tests.yaml
File metadata and controls
200 lines (200 loc) · 8.11 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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
name: Python tests
on:
workflow_call:
# RestPlan spreads the Rest Python groups over parallel shards by the latest
# release run's times (policyengine_us/tests/rest_python_shards.py); each
# process still runs files of one Makefile group. Rest runs no tests: it
# fails unless the plan and every shard succeeded.
# Only the guarded PR workflow calls this file; it has no automatic triggers.
jobs:
RestPlan:
name: Plan Rest Python shards
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
actions: read
contents: read
outputs:
matrix: ${{ steps.plan.outputs.matrix }}
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Update system certificate authorities
id: system-ca
uses: ./.github/actions/setup-system-ca
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.13.4"
- name: Install dependencies
run: uv sync --locked --extra dev
# A successful release run on main has every shard's JUnit and GNU time
# reports; a failed one can lack a lost runner's, which would skew the
# estimates. Without any, the plan counts each file the same.
- name: Download recent Rest Python timings
id: timings
shell: bash
env:
GH_TOKEN: ${{ github.token }}
run: |
set -uo pipefail
runs=$(gh run list --repo "$GITHUB_REPOSITORY" --workflow push.yaml \
--branch main --status success --limit 40 \
--json databaseId,displayTitle \
--jq '.[] | select(.displayTitle == "Update PolicyEngine US") | .databaseId') || runs=""
for run in $(echo "$runs" | head -n 3); do
if gh run download "$run" --repo "$GITHUB_REPOSITORY" \
--dir "rest-timings/$run" \
--pattern 'rest-python-test-timings-*' \
--pattern rest-variables-test-timings; then
echo "source=release run $run" >> "$GITHUB_OUTPUT"
exit 0
fi
rm -rf "rest-timings/$run"
done
echo "::warning::No Rest Python timing reports found; the plan counts every file the same."
- name: Plan shards
id: plan
env:
TIMINGS_SOURCE: ${{ steps.timings.outputs.source }}
run: uv run --no-sync python policyengine_us/tests/rest_python_shards.py plan --timings rest-timings --source "$TIMINGS_SOURCE" --github-output "$GITHUB_OUTPUT" --summary "$GITHUB_STEP_SUMMARY"
RestPython:
needs: [RestPlan]
name: Full Suite - Rest (Python shard ${{ matrix.shard }})
runs-on: ubuntu-latest
# Plans aim at 25 minutes a shard (26-30 from the October 2026 reports);
# one made without reports can run longer.
timeout-minutes: 90
strategy:
fail-fast: false
matrix: ${{ fromJSON(needs.RestPlan.outputs.matrix) }}
env:
PYTHONUNBUFFERED: 1
OMP_NUM_THREADS: 4
OPENBLAS_NUM_THREADS: 4
MKL_NUM_THREADS: 4
VECLIB_MAXIMUM_THREADS: 4
NUMEXPR_NUM_THREADS: 4
OMP_WAIT_POLICY: PASSIVE
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Update system certificate authorities
id: system-ca
uses: ./.github/actions/setup-system-ca
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.13.4"
- name: Resolve latest compatible PolicyEngine Core
run: uv lock --upgrade-package policyengine-core
- name: Install dependencies
run: uv sync --locked --extra dev
- name: Turn off default branching
shell: bash
run: bash ./update_itemization.sh
# Each planned process runs files of one group, one process at a time.
# SPM simulation/API contracts stay in the Microsimulation job.
- name: Run remaining Python tests
if: ${{ !cancelled() && steps.system-ca.outcome == 'success' }}
env:
PYTEST_ADDOPTS: "--durations=0 -v -p no:unraisableexception -p no:threadexception"
REST_PYTHON_PROCESSES: ${{ matrix.processes }}
run: uv run --no-sync python policyengine_us/tests/rest_python_shards.py run --report-dir .
- name: Upload Rest Python timing and memory reports
if: always()
uses: actions/upload-artifact@v4
with:
name: rest-python-test-timings-shard-${{ matrix.shard }}
path: |
rest-python-*.xml
rest-python-*-resources.txt
- name: Run tests/variables YAML tests
if: ${{ !cancelled() && steps.system-ca.outcome == 'success' && matrix.variables }}
env:
PYTEST_ADDOPTS: "--durations=0 --junitxml=rest-variables.xml -p no:unraisableexception -p no:threadexception"
run: /usr/bin/time -v -o rest-variables-resources.txt uv run --no-sync make test-yaml-variables
- name: Upload Rest variables timing and memory reports
if: ${{ always() && matrix.variables }}
uses: actions/upload-artifact@v4
with:
name: rest-variables-test-timings
path: |
rest-variables.xml
rest-variables-resources.txt
Rest:
needs: [RestPlan, RestPython]
# Runs after a failed plan or shard but stops when the run is cancelled.
# always() kept this runner alive after cancellation.
if: ${{ !cancelled() }}
name: Check Rest Python shards
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Check all Rest jobs succeeded
shell: bash
env:
PLAN_RESULT: ${{ needs.RestPlan.result }}
PYTHON_RESULT: ${{ needs.RestPython.result }}
run: |
if [[ "$PLAN_RESULT" != "success" || "$PYTHON_RESULT" != "success" ]]; then
echo "::error::Rest jobs did not all succeed: plan=$PLAN_RESULT, shards=$PYTHON_RESULT"
exit 1
fi
Microsimulation:
name: Full Suite - Microsimulation
runs-on: ubuntu-latest
timeout-minutes: 60
env:
PYTHONUNBUFFERED: 1
PYTEST_ADDOPTS: "--durations=25 -p no:unraisableexception -p no:threadexception"
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Update system certificate authorities
id: system-ca
uses: ./.github/actions/setup-system-ca
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: 3.14
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.13.4"
- name: Resolve latest compatible PolicyEngine Core
run: uv lock --upgrade-package policyengine-core
- name: Install dependencies
run: uv sync --locked --extra dev
- name: Turn off default branching
shell: bash
run: bash ./update_itemization.sh
# Keep simulation/API and dataset compatibility on this existing runner.
# Use separate, sequential processes: combining these suites in one
# pytest process previously accumulated enough memory to kill the runner.
- name: Run SPM Python tests
env:
PYTEST_ADDOPTS: "--durations=0 -v --junitxml=simulation-spm.xml -p no:unraisableexception -p no:threadexception"
run: /usr/bin/time -v -o simulation-spm-resources.txt uv run --no-sync make test-other-python-spm
- name: Run microsimulation tests
# Continue after failures, but stop when the workflow is cancelled.
if: ${{ !cancelled() && steps.system-ca.outcome == 'success' }}
env:
PYTEST_ADDOPTS: "--durations=0 -v --junitxml=simulation-microsimulation.xml -p no:unraisableexception -p no:threadexception"
run: /usr/bin/time -v -o simulation-microsimulation-resources.txt uv run --no-sync make test-microsimulation
- name: Upload simulation timing and memory reports
if: always()
uses: actions/upload-artifact@v4
with:
name: simulation-test-timings
path: |
simulation-*.xml
simulation-*-resources.txt