Skip to content

Commit e098fa2

Browse files
committed
ci: stop the release job re-running the test suite before it pushes
`pnpm install` reinstalls this repo's local pre-push gate, so every push the release job makes re-ran the whole suite inside CI — 20,387 tests, 17 minutes, on a commit CI had already tested. That is what failed the last release run: the push held a stale lease for the whole window and was rejected. On the publish path the same push carries the version tags and happens after npm has already accepted the packages. One flaky test there, or the 30-minute job timeout, would leave a published release untagged and skip every job that follows it — docs, native artifacts, the extension, the tap, the CDN. Two independent layers: SKIP_HOOKS, which the hook reads and which reaches the pushes a JS action spawns, and deleting the hooks after install, which does not depend on the environment surviving that hop. The delete resolves the hooks directory through git rather than assuming .git/hooks, and fails the job if a hook is still there afterwards.
1 parent 98c0121 commit e098fa2

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,22 @@ on:
55
branches:
66
- main
77

8+
# Never cancel a release in flight: a publish that is interrupted between npm
9+
# and the git tags cannot be undone. Runs therefore queue instead. GitHub keeps
10+
# only one pending run per group, so a third push while a release is running
11+
# silently drops the one waiting behind it — the commits still ship, on the
12+
# next run, but nothing announces the skip. Keeping this job short is what
13+
# keeps that window small.
814
concurrency: ${{ github.workflow }}-${{ github.ref }}
915

16+
# This repository installs a local pre-push gate that re-runs the full test
17+
# suite. It exists to save a CI round trip from a developer's machine; inside
18+
# CI it is pure duplication, and `scripts/pre-push.sh` reads this to stand
19+
# down. Set at the workflow level so it reaches every push, including the ones
20+
# a JS action spawns.
21+
env:
22+
SKIP_HOOKS: "1"
23+
1024
jobs:
1125
# Publishing to npm is irreversible — never let a commit that fails CI or
1226
# Nix Build ship. Those workflows run in parallel on the same push, so this
@@ -94,6 +108,32 @@ jobs:
94108
- name: Install dependencies
95109
run: pnpm install --frozen-lockfile
96110

111+
# The `prepare` script reinstalls the local hooks during the install
112+
# above, so this has to run after it, not before. `SKIP_HOOKS` already
113+
# tells the hook to stand down; deleting it as well removes the last way
114+
# the suite could run inside this job — an environment that reaches the
115+
# hook scrubbed, or a hook that stops honouring the variable.
116+
#
117+
# Worth the belt and braces: on the publish path, the push these hooks
118+
# would gate carries the version tags, and it runs after npm has already
119+
# accepted the packages. A hook failure there — one flaky test under
120+
# runner load is enough — leaves the release published but untagged, and
121+
# skips every job that depends on it: docs, native artifacts, the VS Code
122+
# extension, the Homebrew tap, the CDN.
123+
- name: Disarm the local git hooks
124+
run: |
125+
# `--git-path hooks` is git's own resolution of core.hooksPath, so
126+
# this deletes from the directory git will actually read rather than
127+
# assuming `.git/hooks`.
128+
hooks_dir=$(git rev-parse --git-path hooks)
129+
rm -f "${hooks_dir}/pre-push" "${hooks_dir}/pre-commit"
130+
if [ -e "${hooks_dir}/pre-push" ] || [ -e "${hooks_dir}/pre-commit" ]; then
131+
echo "::error::A git hook survived removal in ${hooks_dir}."
132+
echo "::error::The release push would re-run the full test suite; fix this before releasing."
133+
exit 1
134+
fi
135+
echo "Local git hooks disarmed (${hooks_dir})."
136+
97137
- name: Generate Pythinker Code built-in catalog
98138
shell: bash
99139
run: |

0 commit comments

Comments
 (0)