|
| 1 | +name: "[TEST] Push workflow dry run" |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: [main] |
| 6 | + |
| 7 | +jobs: |
| 8 | + # ── Lint ──────────────────────────────────────────────────── |
| 9 | + lint: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + steps: |
| 12 | + - uses: actions/checkout@v4 |
| 13 | + - name: Install ruff |
| 14 | + run: pip install ruff>=0.9.0 |
| 15 | + - name: Check formatting |
| 16 | + run: ruff format --check . |
| 17 | + |
| 18 | + # ── Per-dataset build and test on Modal ───────────────────── |
| 19 | + build-and-test: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + needs: lint |
| 22 | + if: github.event.head_commit.message != 'Update package version' |
| 23 | + timeout-minutes: 240 |
| 24 | + env: |
| 25 | + MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} |
| 26 | + MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} |
| 27 | + HUGGING_FACE_TOKEN: ${{ secrets.HUGGING_FACE_TOKEN }} |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@v4 |
| 30 | + - uses: actions/setup-python@v5 |
| 31 | + with: |
| 32 | + python-version: "3.13" |
| 33 | + - uses: astral-sh/setup-uv@v5 |
| 34 | + - name: Install Modal CLI |
| 35 | + run: pip install modal |
| 36 | + - name: Install package |
| 37 | + run: uv sync --dev |
| 38 | + |
| 39 | + - name: Initialize summary |
| 40 | + run: | |
| 41 | + echo "## Data Build & Integration Tests" >> $GITHUB_STEP_SUMMARY |
| 42 | + echo "" >> $GITHUB_STEP_SUMMARY |
| 43 | + echo "| Step | Status | Duration |" >> $GITHUB_STEP_SUMMARY |
| 44 | + echo "|------|--------|----------|" >> $GITHUB_STEP_SUMMARY |
| 45 | +
|
| 46 | + # ── Phase 1: Download prerequisites ─────────────────── |
| 47 | + - name: "Build: download prerequisites" |
| 48 | + run: | |
| 49 | + START=$(date +%s) |
| 50 | + modal run modal_app/data_build.py --script download_prerequisites \ |
| 51 | + --branch=${{ github.ref_name }} |
| 52 | + ELAPSED=$(( $(date +%s) - START )) |
| 53 | + echo "| download_prerequisites | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 54 | +
|
| 55 | + # ── Phase 1: Independent datasets (sequential) ──────── |
| 56 | + - name: "Build: uprating" |
| 57 | + run: | |
| 58 | + START=$(date +%s) |
| 59 | + modal run modal_app/data_build.py --script uprating \ |
| 60 | + --branch=${{ github.ref_name }} |
| 61 | + ELAPSED=$(( $(date +%s) - START )) |
| 62 | + echo "| uprating | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 63 | +
|
| 64 | + - name: "Build: acs" |
| 65 | + run: | |
| 66 | + START=$(date +%s) |
| 67 | + modal run modal_app/data_build.py --script acs \ |
| 68 | + --branch=${{ github.ref_name }} |
| 69 | + ELAPSED=$(( $(date +%s) - START )) |
| 70 | + echo "| acs | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 71 | +
|
| 72 | + - name: "Test: acs" |
| 73 | + run: | |
| 74 | + uv run pytest policyengine_us_data/tests/integration/test_acs.py -v |
| 75 | + echo "| test_acs | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 76 | +
|
| 77 | + - name: "Build: irs_puf" |
| 78 | + run: | |
| 79 | + START=$(date +%s) |
| 80 | + modal run modal_app/data_build.py --script irs_puf \ |
| 81 | + --branch=${{ github.ref_name }} |
| 82 | + ELAPSED=$(( $(date +%s) - START )) |
| 83 | + echo "| irs_puf | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 84 | +
|
| 85 | + # ── Phase 2: CPS and PUF (depend on Phase 1) ───────── |
| 86 | + - name: "Build: cps" |
| 87 | + run: | |
| 88 | + START=$(date +%s) |
| 89 | + modal run modal_app/data_build.py --script cps \ |
| 90 | + --branch=${{ github.ref_name }} |
| 91 | + ELAPSED=$(( $(date +%s) - START )) |
| 92 | + echo "| cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 93 | +
|
| 94 | + - name: "Test: cps" |
| 95 | + run: | |
| 96 | + uv run pytest policyengine_us_data/tests/integration/test_cps.py -v |
| 97 | + echo "| test_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 98 | +
|
| 99 | + - name: "Build: puf" |
| 100 | + run: | |
| 101 | + START=$(date +%s) |
| 102 | + modal run modal_app/data_build.py --script puf \ |
| 103 | + --branch=${{ github.ref_name }} |
| 104 | + ELAPSED=$(( $(date +%s) - START )) |
| 105 | + echo "| puf | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 106 | +
|
| 107 | + # ── Phase 3: Extended CPS (depends on CPS + PUF) ───── |
| 108 | + - name: "Build: extended_cps" |
| 109 | + run: | |
| 110 | + START=$(date +%s) |
| 111 | + modal run modal_app/data_build.py --script extended_cps \ |
| 112 | + --branch=${{ github.ref_name }} |
| 113 | + ELAPSED=$(( $(date +%s) - START )) |
| 114 | + echo "| extended_cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 115 | +
|
| 116 | + - name: "Test: extended_cps" |
| 117 | + run: | |
| 118 | + uv run pytest policyengine_us_data/tests/integration/test_extended_cps.py -v |
| 119 | + echo "| test_extended_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 120 | +
|
| 121 | + # ── Phase 4: Enhanced + Stratified CPS ──────────────── |
| 122 | + - name: "Build: enhanced_cps" |
| 123 | + run: | |
| 124 | + START=$(date +%s) |
| 125 | + modal run modal_app/data_build.py --script enhanced_cps \ |
| 126 | + --branch=${{ github.ref_name }} |
| 127 | + ELAPSED=$(( $(date +%s) - START )) |
| 128 | + echo "| enhanced_cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 129 | +
|
| 130 | + - name: "Test: enhanced_cps" |
| 131 | + run: | |
| 132 | + uv run pytest policyengine_us_data/tests/integration/test_enhanced_cps.py -v |
| 133 | + echo "| test_enhanced_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 134 | +
|
| 135 | + - name: "Build: stratified_cps" |
| 136 | + run: | |
| 137 | + START=$(date +%s) |
| 138 | + modal run modal_app/data_build.py --script stratified_cps \ |
| 139 | + --branch=${{ github.ref_name }} |
| 140 | + ELAPSED=$(( $(date +%s) - START )) |
| 141 | + echo "| stratified_cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 142 | +
|
| 143 | + # ── Phase 5: Source imputed + Small enhanced CPS ────── |
| 144 | + - name: "Build: source_imputed_cps" |
| 145 | + run: | |
| 146 | + START=$(date +%s) |
| 147 | + modal run modal_app/data_build.py --script source_imputed_cps \ |
| 148 | + --branch=${{ github.ref_name }} |
| 149 | + ELAPSED=$(( $(date +%s) - START )) |
| 150 | + echo "| source_imputed_cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 151 | +
|
| 152 | + - name: "Test: source_imputed_cps" |
| 153 | + run: | |
| 154 | + uv run pytest policyengine_us_data/tests/integration/test_source_imputed_cps_masking.py policyengine_us_data/tests/integration/test_source_imputed_cps_consistency.py -v |
| 155 | + echo "| test_source_imputed_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 156 | +
|
| 157 | + - name: "Build: small_enhanced_cps" |
| 158 | + run: | |
| 159 | + START=$(date +%s) |
| 160 | + modal run modal_app/data_build.py --script small_enhanced_cps \ |
| 161 | + --branch=${{ github.ref_name }} |
| 162 | + ELAPSED=$(( $(date +%s) - START )) |
| 163 | + echo "| small_enhanced_cps | :white_check_mark: | ${ELAPSED}s |" >> $GITHUB_STEP_SUMMARY |
| 164 | +
|
| 165 | + - name: "Test: small_enhanced_cps" |
| 166 | + run: | |
| 167 | + uv run pytest policyengine_us_data/tests/integration/test_small_enhanced_cps.py -v |
| 168 | + echo "| test_small_enhanced_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 169 | +
|
| 170 | + # ── Remaining integration tests ─────────────────────── |
| 171 | + - name: "Test: sparse_enhanced_cps" |
| 172 | + run: | |
| 173 | + uv run pytest policyengine_us_data/tests/integration/test_sparse_enhanced_cps.py -v |
| 174 | + echo "| test_sparse_enhanced_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 175 | +
|
| 176 | + - name: "Test: sipp_assets" |
| 177 | + run: | |
| 178 | + uv run pytest policyengine_us_data/tests/integration/test_sipp_assets.py -v |
| 179 | + echo "| test_sipp_assets | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 180 | +
|
| 181 | + - name: "Test: census_cps" |
| 182 | + run: | |
| 183 | + uv run pytest policyengine_us_data/tests/integration/test_census_cps.py -v |
| 184 | + echo "| test_census_cps | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 185 | +
|
| 186 | + - name: "Test: database_build" |
| 187 | + run: | |
| 188 | + uv run pytest policyengine_us_data/tests/integration/test_database_build.py -v |
| 189 | + echo "| test_database_build | :white_check_mark: | - |" >> $GITHUB_STEP_SUMMARY |
| 190 | +
|
| 191 | + # ── Manual approval gate ──────────────────────────────────── |
| 192 | + approval-gate: |
| 193 | + needs: build-and-test |
| 194 | + runs-on: ubuntu-latest |
| 195 | + environment: pipeline-approval |
| 196 | + steps: |
| 197 | + - run: echo "Pipeline approved. Dispatching H5 build." |
| 198 | + |
| 199 | + # ── Dispatch pipeline ─────────────────────────────────────── |
| 200 | + trigger-pipeline: |
| 201 | + needs: approval-gate |
| 202 | + runs-on: ubuntu-latest |
| 203 | + steps: |
| 204 | + - name: Trigger pipeline workflow |
| 205 | + uses: actions/github-script@v7 |
| 206 | + with: |
| 207 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 208 | + script: | |
| 209 | + await github.rest.actions.createWorkflowDispatch({ |
| 210 | + owner: context.repo.owner, |
| 211 | + repo: context.repo.repo, |
| 212 | + workflow_id: 'pipeline.yaml', |
| 213 | + ref: 'main', |
| 214 | + inputs: { scope: 'all' } |
| 215 | + }) |
| 216 | + console.log('Pipeline dispatched with scope=all') |
| 217 | +
|
| 218 | + # ── PyPI publish (version bump commits only) ──────────────── |
| 219 | + publish: |
| 220 | + runs-on: ubuntu-latest |
| 221 | + needs: lint |
| 222 | + if: github.event.head_commit.message == 'Update package version' |
| 223 | + steps: |
| 224 | + - uses: actions/checkout@v4 |
| 225 | + - uses: actions/setup-python@v5 |
| 226 | + with: |
| 227 | + python-version: "3.13" |
| 228 | + - uses: astral-sh/setup-uv@v5 |
| 229 | + - name: Install package |
| 230 | + run: uv sync --dev |
| 231 | + - name: Build package |
| 232 | + run: uv run python -m build |
| 233 | + - name: Publish to PyPI |
| 234 | + uses: pypa/gh-action-pypi-publish@release/v1 |
| 235 | + with: |
| 236 | + user: __token__ |
| 237 | + password: ${{ secrets.PYPI }} |
| 238 | + skip-existing: true |
0 commit comments