|
| 1 | +name: Fork checks (temporary proof, do not merge) |
| 2 | +# Copy of fork-checks.yml on pull_request so the branch's version runs; deleted with this PR. |
| 3 | + |
| 4 | +# Rules for this fork's own changes, run on every pull request. Upstream's CI needs runners a fork |
| 5 | +# does not have; fork-tests.yml runs upstream's tests on hosted runners instead. |
| 6 | +# |
| 7 | +# pull_request_target, not pull_request: GitHub then runs this workflow file and the check script |
| 8 | +# from the default branch, so a pull request cannot weaken, skip or delete the check that judges |
| 9 | +# it. The pull request's commits are only fetched as git objects and read as text; nothing from |
| 10 | +# them is checked out or run, so the base branch's permissions never reach pull request code. |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + types: [opened, synchronize, reopened, edited] |
| 14 | + |
| 15 | +permissions: |
| 16 | + contents: read |
| 17 | + |
| 18 | +jobs: |
| 19 | + no_schema_changes: |
| 20 | + name: No database schema changes |
| 21 | + runs-on: ubuntu-latest |
| 22 | + timeout-minutes: 5 |
| 23 | + steps: |
| 24 | + # Plain git, not actions/checkout: upstream's tree has gitlinks under .repos/ but no |
| 25 | + # .gitmodules, and checkout's credential cleanup runs `git submodule foreach`, which fails on |
| 26 | + # them. The full checkout fetches the default branch's blobs in one batch; a sparse one leaves |
| 27 | + # the check to fetch every blob it reads one at a time. |
| 28 | + - name: Check out the default branch and fetch the pull request's commits (not checked out) |
| 29 | + env: |
| 30 | + DEFAULT_SHA: ${{ github.sha }} |
| 31 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 32 | + HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 33 | + run: | |
| 34 | + set -euo pipefail |
| 35 | + git init -q |
| 36 | + git remote add origin "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" |
| 37 | + git fetch -q --no-tags --no-recurse-submodules --filter=blob:none origin \ |
| 38 | + "$DEFAULT_SHA" "$BASE_SHA" "$HEAD_SHA" |
| 39 | + git checkout -q --detach "$DEFAULT_SHA" |
| 40 | +
|
| 41 | + - name: Test the check |
| 42 | + run: node --test .github/scripts/fork-schema-check.test.cjs |
| 43 | + |
| 44 | + # T3 has no down-migrations, so a fork migration strands installs that return to upstream. |
| 45 | + - name: Refuse schema and migration changes |
| 46 | + env: |
| 47 | + BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 48 | + HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 49 | + run: node .github/scripts/fork-schema-check.cjs "$BASE_SHA" "$HEAD_SHA" |
0 commit comments