From 4cae5432fdbee2ef6f36a5f73e292c5dfb7f9d7d Mon Sep 17 00:00:00 2001 From: Seungpyo1007 Date: Wed, 30 Sep 2026 17:20:22 +0900 Subject: [PATCH] ci: dump after merge instead of per PR; full validation on push only dump-develop regenerates site/public from the pinned TechEngine after data lands on develop, restricted to the collections the push can affect, and commits it back. Data PRs therefore no longer need a dump commit, which was the 33 minute step every rebase invalidated. PRs keep only the scoped engine validation; the full bundled self-validate runs on pushes. Refs #350 --- .github/workflows/dump-develop.yml | 83 +++++++++++++++++++++++++++++ .github/workflows/validate-data.yml | 5 ++ 2 files changed, 88 insertions(+) create mode 100644 .github/workflows/dump-develop.yml diff --git a/.github/workflows/dump-develop.yml b/.github/workflows/dump-develop.yml new file mode 100644 index 000000000000..aac1eee94728 --- /dev/null +++ b/.github/workflows/dump-develop.yml @@ -0,0 +1,83 @@ +name: dump-develop + +# Keeps site/public/v1 in sync with data/ AFTER a data change lands on develop, +# so data PRs no longer carry a dump commit (the ~33 min step that every rebase +# invalidated). Runs the TechEngine dump from the pinned submodule, restricted +# to the collections the pushed data can affect (app.dump --changed-since), and +# commits the result back to develop. The commit touches only site/public, which +# this workflow's own path filter ignores, so it cannot loop. +on: + push: + branches: [develop] + paths: + - "data/**" + workflow_dispatch: + inputs: + full: + description: "Regenerate every collection" + type: boolean + default: false + +permissions: + contents: write + +concurrency: + group: dump-develop + cancel-in-progress: false + +jobs: + dump: + if: github.repository == 'GetTechAPI/TechAPI' + runs-on: ubuntu-latest + timeout-minutes: 120 + env: + BEFORE: ${{ github.event.before }} + FULL: ${{ inputs.full }} + steps: + - uses: actions/checkout@v4 + with: + # created_at/updated_at come from each record's git history. + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: "3.12" + + # NOT --recursive: TechEngine carries TechAPI back as a submodule. + - name: Init TechEngine submodule + run: git submodule update --init TechEngine + + - name: Install TechEngine + working-directory: TechEngine + run: pip install -e . + + - name: Generate dump + working-directory: TechEngine + env: + TECHAPI_DATA_DIR: ${{ github.workspace }}/data + run: | + OUT="${GITHUB_WORKSPACE}/site/public" + # An older pinned engine has no --changed-since: fall back to a full dump. + python -m app.dump --help | grep -q -- --changed-since || FULL=true + if [ "$FULL" = "true" ] || [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then + python -m app.validate + python -m app.dump --output "$OUT" + else + python -m app.dump --changed-since "$BEFORE" --output "$OUT" + fi + + - name: Commit and push if changed + run: | + git add site/public + if git diff --cached --quiet; then + echo "dump already up to date"; exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git commit -m "chore(dump): refresh public dump for ${GITHUB_SHA::7}" + # Other merges may have landed while this ran. + for i in 1 2 3; do + git pull --rebase origin develop && git push origin HEAD:develop && exit 0 + sleep 5 + done + echo "::error::could not push dump refresh"; exit 1 diff --git a/.github/workflows/validate-data.yml b/.github/workflows/validate-data.yml index 2661e8aab99e..96a5f20186b2 100644 --- a/.github/workflows/validate-data.yml +++ b/.github/workflows/validate-data.yml @@ -15,6 +15,9 @@ on: jobs: self-validate: + # Full scan of every record: only on pushes. PRs are covered by the scoped + # engine-validate below (changed records + their FK targets). + if: github.event_name == 'push' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,6 +29,8 @@ jobs: engine-validate: needs: self-validate + # self-validate is skipped on PRs; a skipped need must not skip this job. + if: ${{ !cancelled() && (needs.self-validate.result == 'success' || needs.self-validate.result == 'skipped') }} uses: GetTechAPI/TechEngine/.github/workflows/validate-data.yml@main with: data-ref: ${{ github.event.pull_request.head.sha || github.sha }}