-
Notifications
You must be signed in to change notification settings - Fork 10
153 lines (142 loc) · 4.34 KB
/
pr.yaml
File metadata and controls
153 lines (142 loc) · 4.34 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
name: PR checks
on:
pull_request:
branches: [main]
concurrency:
group: pr-checks-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
check-fork:
runs-on: ubuntu-latest
steps:
- name: Check if PR is from fork
run: |
if [ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]; then
echo "::error::PRs must be from branches in PolicyEngine/policyengine-us-data, not forks."
exit 1
fi
check-lock-freshness:
runs-on: ubuntu-latest
needs: check-fork
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: astral-sh/setup-uv@v5
- name: Check lock file is up-to-date
run: |
uv lock --locked || {
echo "::error::uv.lock is outdated. Run 'uv lock' and commit."
exit 1
}
lint:
runs-on: ubuntu-latest
needs: check-fork
steps:
- uses: actions/checkout@v4
- run: pip install ruff>=0.9.0
- run: ruff format --check .
check-changelog:
runs-on: ubuntu-latest
needs: check-fork
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: astral-sh/setup-uv@v5
- run: uv sync --dev
- name: Check for changelog fragment
run: uv run towncrier check --compare-with origin/main
unit-tests:
runs-on: ubuntu-latest
needs: [check-fork, lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: astral-sh/setup-uv@v5
- run: uv sync --dev
- name: Run unit tests with coverage
env:
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
run: >
uv run pytest tests/unit/
--cov=policyengine_us_data
--cov-report=xml
-v
- name: Upload coverage to Codecov
if: always()
uses: codecov/codecov-action@v4
with:
file: coverage.xml
flags: unit
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
smoke-test:
runs-on: ubuntu-latest
needs: [check-fork, lint]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- run: python -m pip install .
- run: python -c "import policyengine_us_data; print('OK')"
- run: python -c "from policyengine_core.data import Dataset; print('OK')"
docs-build:
runs-on: ubuntu-latest
needs: [check-fork]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- uses: actions/setup-node@v4
with:
node-version: "24"
- uses: astral-sh/setup-uv@v5
- run: uv sync --dev
- name: Test documentation builds
run: uv run make documentation
decide-test-scope:
runs-on: ubuntu-latest
needs: check-fork
outputs:
run_integration: ${{ steps.check.outputs.run_integration }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check changed files for integration scope
id: check
run: |
CHANGED=$(git diff --name-only origin/main...HEAD)
if echo "$CHANGED" | grep -qE '^(policyengine_us_data/|modal_app/|tests/integration/)'; then
echo "run_integration=true" >> "$GITHUB_OUTPUT"
else
echo "run_integration=false" >> "$GITHUB_OUTPUT"
fi
integration-tests:
runs-on: ubuntu-latest
needs: [check-fork, lint, decide-test-scope]
if: needs.decide-test-scope.outputs.run_integration == 'true'
env:
MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }}
MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }}
HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.14"
- run: pip install modal
- name: Build datasets and run integration tests on Modal
run: |
modal run modal_app/data_build.py \
--branch=${{ github.head_ref || github.ref_name }}