Skip to content

Commit 6d9fa4b

Browse files
authored
Merge pull request #681 from PolicyEngine/fix/cicd-restructure
Restructure CI/CD pipeline and reorganize tests
2 parents f8a54cb + a881e0b commit 6d9fa4b

File tree

80 files changed

+619
-853
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+619
-853
lines changed

.codecov.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
coverage:
2+
status:
3+
project:
4+
default:
5+
informational: true
6+
patch:
7+
default:
8+
informational: true
9+
10+
comment:
11+
layout: "condensed_header, condensed_files"
12+
behavior: default

.github/workflows/code_changes.yaml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.github/workflows/pipeline.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ on:
2929
jobs:
3030
pipeline:
3131
runs-on: ubuntu-latest
32-
timeout-minutes: 30
3332
steps:
3433
- uses: actions/checkout@v4
3534

@@ -64,5 +63,15 @@ jobs:
6463
num_workers=int('${NUM_WORKERS}'),
6564
skip_national='${SKIP_NATIONAL}' == 'true',
6665
)
67-
print(f'Pipeline spawned. Monitor on the Modal dashboard.')
66+
print(f'Pipeline spawned.')
67+
print(f'Function call ID: {fc.object_id}')
68+
69+
with open('$GITHUB_STEP_SUMMARY', 'a') as f:
70+
f.write('## Pipeline Launched\n\n')
71+
f.write('| Field | Value |\n')
72+
f.write('|-------|-------|\n')
73+
f.write(f'| GPU | \`${GPU}\` |\n')
74+
f.write(f'| Epochs | \`${EPOCHS}\` / \`${NATIONAL_EPOCHS}\` |\n')
75+
f.write(f'| Function call ID | \`{fc.object_id}\` |\n\n')
76+
f.write('**[Monitor on Modal Dashboard](https://modal.com/apps)**\n')
6877
"

.github/workflows/pr.yaml

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
name: PR checks
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
concurrency:
8+
group: pr-checks-${{ github.event.pull_request.number }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
check-fork:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check if PR is from fork
16+
run: |
17+
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
18+
echo "::error::PRs must be from branches in PolicyEngine/policyengine-us-data, not forks."
19+
exit 1
20+
fi
21+
22+
check-lock-freshness:
23+
runs-on: ubuntu-latest
24+
needs: check-fork
25+
steps:
26+
- uses: actions/checkout@v4
27+
- uses: actions/setup-python@v5
28+
with:
29+
python-version: "3.14"
30+
- uses: astral-sh/setup-uv@v5
31+
- name: Check lock file is up-to-date
32+
run: |
33+
uv lock --locked || {
34+
echo "::error::uv.lock is outdated. Run 'uv lock' and commit."
35+
exit 1
36+
}
37+
38+
lint:
39+
runs-on: ubuntu-latest
40+
needs: check-fork
41+
steps:
42+
- uses: actions/checkout@v4
43+
- run: pip install ruff>=0.9.0
44+
- run: ruff format --check .
45+
46+
check-changelog:
47+
runs-on: ubuntu-latest
48+
needs: check-fork
49+
steps:
50+
- uses: actions/checkout@v4
51+
- name: Check for changelog fragment
52+
run: |
53+
FRAGMENTS=$(find changelog.d -type f ! -name '.gitkeep' | wc -l)
54+
if [ "$FRAGMENTS" -eq 0 ]; then
55+
echo "::error::No changelog fragment in changelog.d/"
56+
exit 1
57+
fi
58+
59+
unit-tests:
60+
runs-on: ubuntu-latest
61+
needs: [check-fork, lint]
62+
steps:
63+
- uses: actions/checkout@v4
64+
- uses: actions/setup-python@v5
65+
with:
66+
python-version: "3.14"
67+
- uses: astral-sh/setup-uv@v5
68+
- run: uv sync --dev
69+
- name: Run unit tests with coverage
70+
env:
71+
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
72+
run: >
73+
uv run pytest tests/unit/
74+
--cov=policyengine_us_data
75+
--cov-report=xml
76+
-v
77+
- name: Upload coverage to Codecov
78+
if: always()
79+
uses: codecov/codecov-action@v4
80+
with:
81+
file: coverage.xml
82+
flags: unit
83+
fail_ci_if_error: false
84+
env:
85+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
86+
87+
smoke-test:
88+
runs-on: ubuntu-latest
89+
needs: [check-fork, lint]
90+
steps:
91+
- uses: actions/checkout@v4
92+
- uses: actions/setup-python@v5
93+
with:
94+
python-version: "3.14"
95+
- run: python -m pip install .
96+
- run: python -c "import policyengine_us_data; print('OK')"
97+
- run: python -c "from policyengine_core.data import Dataset; print('OK')"
98+
99+
docs-build:
100+
runs-on: ubuntu-latest
101+
needs: [check-fork]
102+
steps:
103+
- uses: actions/checkout@v4
104+
- uses: actions/setup-python@v5
105+
with:
106+
python-version: "3.14"
107+
- uses: actions/setup-node@v4
108+
with:
109+
node-version: "24"
110+
- uses: astral-sh/setup-uv@v5
111+
- run: uv sync --dev
112+
- name: Test documentation builds
113+
run: uv run make documentation
114+
115+
decide-test-scope:
116+
runs-on: ubuntu-latest
117+
needs: check-fork
118+
outputs:
119+
run_integration: ${{ steps.check.outputs.run_integration }}
120+
steps:
121+
- uses: actions/checkout@v4
122+
with:
123+
fetch-depth: 0
124+
- name: Check changed files for integration scope
125+
id: check
126+
run: |
127+
CHANGED=$(git diff --name-only origin/main...HEAD)
128+
if echo "$CHANGED" | grep -qE '^(policyengine_us_data/|modal_app/|tests/integration/)'; then
129+
echo "run_integration=true" >> "$GITHUB_OUTPUT"
130+
else
131+
echo "run_integration=false" >> "$GITHUB_OUTPUT"
132+
fi
133+
134+
integration-tests:
135+
runs-on: ubuntu-latest
136+
needs: [check-fork, lint, decide-test-scope]
137+
if: needs.decide-test-scope.outputs.run_integration == 'true'
138+
env:
139+
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
140+
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
141+
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
142+
steps:
143+
- uses: actions/checkout@v4
144+
- uses: actions/setup-python@v5
145+
with:
146+
python-version: "3.14"
147+
- run: pip install modal
148+
- name: Build datasets and run integration tests on Modal
149+
run: |
150+
modal run modal_app/data_build.py \
151+
--branch=${{ github.head_ref || github.ref_name }}

.github/workflows/pr_changelog.yaml

Lines changed: 0 additions & 21 deletions
This file was deleted.

0 commit comments

Comments
 (0)