Skip to content

Commit 4cae543

Browse files
committed
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
1 parent 9fd2aca commit 4cae543

2 files changed

Lines changed: 88 additions & 0 deletions

File tree

‎.github/workflows/dump-develop.yml‎

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: dump-develop
2+
3+
# Keeps site/public/v1 in sync with data/ AFTER a data change lands on develop,
4+
# so data PRs no longer carry a dump commit (the ~33 min step that every rebase
5+
# invalidated). Runs the TechEngine dump from the pinned submodule, restricted
6+
# to the collections the pushed data can affect (app.dump --changed-since), and
7+
# commits the result back to develop. The commit touches only site/public, which
8+
# this workflow's own path filter ignores, so it cannot loop.
9+
on:
10+
push:
11+
branches: [develop]
12+
paths:
13+
- "data/**"
14+
workflow_dispatch:
15+
inputs:
16+
full:
17+
description: "Regenerate every collection"
18+
type: boolean
19+
default: false
20+
21+
permissions:
22+
contents: write
23+
24+
concurrency:
25+
group: dump-develop
26+
cancel-in-progress: false
27+
28+
jobs:
29+
dump:
30+
if: github.repository == 'GetTechAPI/TechAPI'
31+
runs-on: ubuntu-latest
32+
timeout-minutes: 120
33+
env:
34+
BEFORE: ${{ github.event.before }}
35+
FULL: ${{ inputs.full }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
with:
39+
# created_at/updated_at come from each record's git history.
40+
fetch-depth: 0
41+
42+
- uses: actions/setup-python@v5
43+
with:
44+
python-version: "3.12"
45+
46+
# NOT --recursive: TechEngine carries TechAPI back as a submodule.
47+
- name: Init TechEngine submodule
48+
run: git submodule update --init TechEngine
49+
50+
- name: Install TechEngine
51+
working-directory: TechEngine
52+
run: pip install -e .
53+
54+
- name: Generate dump
55+
working-directory: TechEngine
56+
env:
57+
TECHAPI_DATA_DIR: ${{ github.workspace }}/data
58+
run: |
59+
OUT="${GITHUB_WORKSPACE}/site/public"
60+
# An older pinned engine has no --changed-since: fall back to a full dump.
61+
python -m app.dump --help | grep -q -- --changed-since || FULL=true
62+
if [ "$FULL" = "true" ] || [ -z "$BEFORE" ] || [ "$BEFORE" = "0000000000000000000000000000000000000000" ]; then
63+
python -m app.validate
64+
python -m app.dump --output "$OUT"
65+
else
66+
python -m app.dump --changed-since "$BEFORE" --output "$OUT"
67+
fi
68+
69+
- name: Commit and push if changed
70+
run: |
71+
git add site/public
72+
if git diff --cached --quiet; then
73+
echo "dump already up to date"; exit 0
74+
fi
75+
git config user.name "github-actions[bot]"
76+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
77+
git commit -m "chore(dump): refresh public dump for ${GITHUB_SHA::7}"
78+
# Other merges may have landed while this ran.
79+
for i in 1 2 3; do
80+
git pull --rebase origin develop && git push origin HEAD:develop && exit 0
81+
sleep 5
82+
done
83+
echo "::error::could not push dump refresh"; exit 1

‎.github/workflows/validate-data.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515

1616
jobs:
1717
self-validate:
18+
# Full scan of every record: only on pushes. PRs are covered by the scoped
19+
# engine-validate below (changed records + their FK targets).
20+
if: github.event_name == 'push'
1821
runs-on: ubuntu-latest
1922
steps:
2023
- uses: actions/checkout@v4
@@ -26,6 +29,8 @@ jobs:
2629

2730
engine-validate:
2831
needs: self-validate
32+
# self-validate is skipped on PRs; a skipped need must not skip this job.
33+
if: ${{ !cancelled() && (needs.self-validate.result == 'success' || needs.self-validate.result == 'skipped') }}
2934
uses: GetTechAPI/TechEngine/.github/workflows/validate-data.yml@main
3035
with:
3136
data-ref: ${{ github.event.pull_request.head.sha || github.sha }}

0 commit comments

Comments
 (0)