[TEST] Push workflow dry run - DO NOT MERGE #60
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: "[TEST] Push workflow dry run" | |
| on: | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| # ── Lint ──────────────────────────────────────────────────── | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install ruff | |
| run: pip install ruff>=0.9.0 | |
| - name: Check formatting | |
| run: ruff format --check . | |
| # ── Deploy Modal app (build image once) ───────────────────── | |
| deploy-modal: | |
| runs-on: ubuntu-latest | |
| if: github.event.head_commit.message != 'Update package version' | |
| outputs: | |
| app-name: ${{ steps.deploy.outputs.app_name }} | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: Deploy Modal app | |
| id: deploy | |
| run: | | |
| APP_NAME="policyengine-us-data-ci-${{ github.run_id }}" | |
| echo "app_name=${APP_NAME}" >> "$GITHUB_OUTPUT" | |
| MODAL_APP_NAME="${APP_NAME}" modal deploy modal_app/data_build.py | |
| # ── Download prerequisites ────────────────────────────────── | |
| download-prerequisites: | |
| runs-on: ubuntu-latest | |
| needs: deploy-modal | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: Download prerequisites on Modal | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='download_prerequisites', | |
| branch='${{ github.ref_name }}', | |
| ) | |
| print(result) | |
| " | |
| # ── Phase 1: Independent datasets (parallel) ─────────────── | |
| phase1: | |
| needs: [deploy-modal, download-prerequisites] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| dataset: [uprating, acs, irs_puf] | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Build + test: ${{ matrix.dataset }}" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='${{ matrix.dataset }}', | |
| branch='${{ github.ref_name }}', | |
| run_tests=True, | |
| ) | |
| print(result) | |
| " | |
| # ── Phase 2: CPS + PUF (depend on Phase 1) ───────────────── | |
| phase2: | |
| needs: [deploy-modal, phase1] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| dataset: [cps, puf] | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Build + test: ${{ matrix.dataset }}" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='${{ matrix.dataset }}', | |
| branch='${{ github.ref_name }}', | |
| run_tests=True, | |
| ) | |
| print(result) | |
| " | |
| # ── Phase 3: Extended CPS (depends on Phase 2) ───────────── | |
| phase3: | |
| needs: [deploy-modal, phase2] | |
| runs-on: ubuntu-latest | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Build + test: extended_cps" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='extended_cps', | |
| branch='${{ github.ref_name }}', | |
| run_tests=True, | |
| ) | |
| print(result) | |
| " | |
| # ── Phase 4: Enhanced + Stratified CPS (depend on Phase 3) ─ | |
| phase4: | |
| needs: [deploy-modal, phase3] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| dataset: [enhanced_cps, stratified_cps] | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Build + test: ${{ matrix.dataset }}" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='${{ matrix.dataset }}', | |
| branch='${{ github.ref_name }}', | |
| run_tests=True, | |
| ) | |
| print(result) | |
| " | |
| # ── Phase 5: Source imputed + Small enhanced (depend on 4) ── | |
| phase5: | |
| needs: [deploy-modal, phase4] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| dataset: [source_imputed_cps, small_enhanced_cps] | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Build + test: ${{ matrix.dataset }}" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_single_script') | |
| result = fn.remote( | |
| script_name='${{ matrix.dataset }}', | |
| branch='${{ github.ref_name }}', | |
| run_tests=True, | |
| ) | |
| print(result) | |
| " | |
| # ── Remaining integration tests (depend on Phase 4) ───────── | |
| remaining-tests: | |
| needs: [deploy-modal, phase4] | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| test: | |
| - policyengine_us_data/tests/integration/test_census_cps.py | |
| - policyengine_us_data/tests/integration/test_database_build.py | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: "Test: ${{ matrix.test }}" | |
| run: | | |
| python -c " | |
| import modal | |
| fn = modal.Function.from_name('${{ needs.deploy-modal.outputs.app-name }}', 'run_integration_test') | |
| result = fn.remote( | |
| test_path='${{ matrix.test }}', | |
| branch='${{ github.ref_name }}', | |
| ) | |
| print(result) | |
| " | |
| # ── Cleanup Modal deployment ──────────────────────────────── | |
| cleanup-modal: | |
| needs: [deploy-modal, phase5, remaining-tests] | |
| runs-on: ubuntu-latest | |
| if: always() | |
| env: | |
| MODAL_TOKEN_ID: ${{ secrets.MODAL_TOKEN_ID }} | |
| MODAL_TOKEN_SECRET: ${{ secrets.MODAL_TOKEN_SECRET }} | |
| steps: | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - name: Install Modal CLI | |
| run: pip install modal | |
| - name: Stop deployed app | |
| run: modal app stop ${{ needs.deploy-modal.outputs.app-name }} 2>/dev/null || true | |
| # ── Manual approval gate ──────────────────────────────────── | |
| approval-gate: | |
| needs: [phase5, remaining-tests] | |
| runs-on: ubuntu-latest | |
| environment: pipeline-approval | |
| steps: | |
| - run: echo "Pipeline approved. Dispatching H5 build." | |
| # ── Dispatch pipeline ─────────────────────────────────────── | |
| trigger-pipeline: | |
| needs: approval-gate | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger pipeline workflow | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| await github.rest.actions.createWorkflowDispatch({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| workflow_id: 'pipeline.yaml', | |
| ref: 'main', | |
| inputs: { scope: 'all' } | |
| }) | |
| console.log('Pipeline dispatched with scope=all') | |
| # ── PyPI publish (version bump commits only) ──────────────── | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| if: github.event.head_commit.message == 'Update package version' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.13" | |
| - uses: astral-sh/setup-uv@v5 | |
| - name: Install package | |
| run: uv sync --dev | |
| - name: Build package | |
| run: uv run python -m build | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| user: __token__ | |
| password: ${{ secrets.PYPI }} | |
| skip-existing: true |