-
Notifications
You must be signed in to change notification settings - Fork 9
164 lines (155 loc) · 5.26 KB
/
Copy pathpr_code_changes.yaml
File metadata and controls
164 lines (155 loc) · 5.26 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
# Workflow that runs on code changes to a pull request.
name: Code changes
on:
pull_request:
paths:
- src/**
- tests/**
- scripts/**
- .github/**
- changelog.d/**
- pyproject.toml
- uv.lock
- src/policyengine/data/bundle/manifest.json
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-changelog:
name: Check changelog fragment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Install towncrier
run: pip install towncrier
- name: Check for changelog fragment
run: .github/check-changelog.sh
Lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install ruff
run: pip install ruff
- name: Run ruff format check
run: ruff format --check .
- name: Run ruff check
run: ruff check .
Mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.12.14"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install package
run: uv pip install -e .[dev] --system
- name: Run mypy (informational)
run: mypy src/policyengine || echo "mypy found errors (non-blocking until codebase is clean)"
Python-Compat:
name: Install + smoke-import (py${{ matrix.python-version }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.12.14"
- name: Install package (no country-model extras)
run: uv pip install --system .
- name: Smoke-import core modules
run: python -c "import policyengine; from policyengine.core import Dataset, Policy, Simulation; from policyengine.outputs import aggregate, poverty, inequality; print('import OK')"
BundleVerification:
name: Verify release inputs and bundle packages
# Private manifest credentials are available only to trusted repository PRs.
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
env:
POLICYENGINE_SKIP_COUNTRY_IMPORTS: "1"
steps:
- uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.12.14"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.13'
- name: Install package for TRACE verification
run: uv pip install -e . h5py --system
- name: Check reviewed release inputs
env:
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
run: |
if [[ -z "${HUGGING_FACE_TOKEN:-}" ]]; then
echo "::error::Full private release verification requires HUGGING_FACE_TOKEN"
exit 1
fi
python scripts/check_release_credentials.py
python scripts/bundle.py check --published-spm --include-tros --strict-tros
python scripts/release_lock.py
- name: Install bundle package scaffold
run: |
uv pip install -e ".[models]" --system
python - <<'PY'
import subprocess
import sys
from policyengine import bundle
requirements = [
requirement
for requirement in bundle.bundle_install_requirements(
countries=["us", "uk"]
)
if not requirement.startswith("policyengine==")
]
subprocess.check_call(
[sys.executable, "-m", "pip", "install", *requirements]
)
PY
- name: Check installed package consistency
run: python -m pip check
- name: Verify bundle packages
run: policyengine bundle verify --country us --country uk --packages-only --json
Test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ['3.11', '3.12', '3.13', '3.14']
steps:
- name: Checkout repo
uses: actions/checkout@v6
- name: Install uv
uses: astral-sh/setup-uv@v8.1.0
with:
version: "0.12.14"
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install package
run: uv pip install -e .[dev] --system
- name: Install policyengine
run: uv pip install policyengine --system
- name: Run tests with coverage
run: make test
env:
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}