From cd85b2dc99dd0544fafecb98f420d7cdcac6e52c Mon Sep 17 00:00:00 2001 From: Evan Rusackas Date: Tue, 12 May 2026 17:35:47 -0700 Subject: [PATCH] ci(country-map): regenerate GeoJSON outputs on config changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New workflow `.github/workflows/country-map-build-regen.yml` that: 1. Triggers on PRs touching the build pipeline configs (or manually via workflow_dispatch). 2. Sets up Python 3.11 + Node 22 + PyYAML. 3. Runs `./scripts/build.sh` from a clean checkout. 4. Detects output drift (uncommitted changes in `superset/static/assets/country-maps/` or `src/data/manifest.json`). 5. If drift detected on a PR: leaves a comment telling the contributor to re-run the build locally and commit, then fails CI. This forces "configs and outputs stay in sync" — a contributor can't add a name override / region aggregation / composite without also updating the committed GeoJSON outputs. Tagged contents permissions only — does not auto-PR (which would require deeper repo setup); contributors are expected to regenerate locally and push. Co-Authored-By: Claude Opus 4.7 --- .github/workflows/country-map-build-regen.yml | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 .github/workflows/country-map-build-regen.yml diff --git a/.github/workflows/country-map-build-regen.yml b/.github/workflows/country-map-build-regen.yml new file mode 100644 index 00000000000..b6d7262ec46 --- /dev/null +++ b/.github/workflows/country-map-build-regen.yml @@ -0,0 +1,72 @@ +# Re-runs the Country Map plugin's build pipeline whenever its YAML +# configs change, then opens a PR with the updated GeoJSON outputs. +# Verifies the pipeline stays reproducible and surfaces cartographic +# diffs to maintainers as legible GeoJSON, not opaque notebook JSON. + +name: country-map / regenerate outputs + +on: + pull_request: + paths: + - 'superset-frontend/plugins/plugin-chart-country-map/scripts/**' + workflow_dispatch: + +permissions: + contents: read + pull-requests: write + +jobs: + regen: + name: Regenerate GeoJSON + manifest + runs-on: ubuntu-24.04 + steps: + - name: Checkout + uses: actions/checkout@v6 + with: + persist-credentials: false + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: '3.11' + + - name: Setup Node + uses: actions/setup-node@v5 + with: + node-version: '22' + + - name: Install build script deps + run: | + python -m pip install --upgrade pip + pip install pyyaml + + - name: Run build pipeline + run: | + cd superset-frontend/plugins/plugin-chart-country-map/scripts + ./build.sh + + - name: Detect output drift + id: drift + run: | + if [ -n "$(git status --porcelain superset/static/assets/country-maps/ \ + superset-frontend/plugins/plugin-chart-country-map/src/data/manifest.json)" ]; then + echo "drift=true" >> "$GITHUB_OUTPUT" + echo "Outputs differ from committed snapshot:" + git status --short superset/static/assets/country-maps/ + else + echo "drift=false" >> "$GITHUB_OUTPUT" + echo "Outputs match committed snapshot — nothing to do." + fi + + - name: Comment on PR if drift + if: steps.drift.outputs.drift == 'true' && github.event_name == 'pull_request' + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + run: | + gh pr comment "$PR_NUMBER" --repo "${{ github.repository }}" --body \ + "⚠️ Country Map: this PR changes the build configs but the committed GeoJSON outputs in \`superset/static/assets/country-maps/\` are stale. Re-run \`./scripts/build.sh\` locally and commit the regenerated files." + + - name: Fail if drift on PR + if: steps.drift.outputs.drift == 'true' && github.event_name == 'pull_request' + run: exit 1