fix(ci): point the pack-artifact provenance gate at the branch under test

The guard added for #10427 checks ancestry against origin/main by default. That
is the right ref at publish time (npm-publish.yml runs on main), but in a
pull_request context it can never hold: while the PR is open its head is by
construction not an ancestor of main, and the shallow checkout does not even
bring origin/main into the local graph, so the probe answers false regardless.
The job therefore failed 100% of the time and only became visible now that it
stopped being cancelled behind Build.

Pre-merge the one checkable invariant is that the stamp matches the branch under
test, so resolve the ref from refs/pull/<N>/head — which exists on origin even
for fork PRs, unlike head.ref, which only exists on the author's repository.
This commit is contained in:
Xiangzhe
2026-08-25 20:20:28 -03:00
parent a11930ec44
commit 01c40d7379

View File

@@ -703,7 +703,32 @@ jobs:
run: |
export OMNIROUTE_BUILD_SHA="${OMNIROUTE_BUILD_SHA:0:7}"
node scripts/build/write-build-sha.mjs
# O guard de proveniencia checa ancestralidade contra `origin/main` por padrao.
# Esse e o ref certo na PUBLICACAO (npm-publish.yml roda em main), mas em
# `pull_request` e estruturalmente impossivel: enquanto a PR esta aberta o head
# dela NUNCA e ancestral de main — e o checkout raso nem traz `origin/main` para
# o grafo local, entao a sonda responde `false` de qualquer jeito. Resultado: o
# gate falhava 100% das vezes em PR. Pre-merge o unico invariante checavel e "o
# stamp corresponde a branch sob teste", entao apontamos o ref para o head da PR.
# Usamos `refs/pull/<N>/head` e nao `head.ref` porque aquele existe no PROPRIO
# origin mesmo quando a PR vem de um fork; `head.ref` so existe no repo do autor.
- name: Resolve the provenance ref for the pack gate (#10427)
id: provenance-ref
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [ -n "$PR_NUMBER" ]; then
git fetch --no-tags --depth=50 origin \
"+refs/pull/$PR_NUMBER/head:refs/remotes/origin/pr-head"
echo "ref=origin/pr-head" >> "$GITHUB_OUTPUT"
else
git fetch --no-tags --depth=50 origin \
"+refs/heads/$GITHUB_REF_NAME:refs/remotes/origin/$GITHUB_REF_NAME"
echo "ref=origin/$GITHUB_REF_NAME" >> "$GITHUB_OUTPUT"
fi
- run: npm run check:pack-artifact
env:
OMNIROUTE_RELEASE_REF: ${{ steps.provenance-ref.outputs.ref }}
# WS1.2 (#7065 class): pack the real tarball, install it into a clean prefix and
# BOOT it to a healthy /api/monitoring/health — the gate that structure checks
# cannot provide (3 releases shipped boot-crashing tarballs with green lists).