From 01c40d73790b06ce35610609abf87295141db237 Mon Sep 17 00:00:00 2001 From: Xiangzhe Date: Tue, 25 Aug 2026 20:20:28 -0300 Subject: [PATCH] fix(ci): point the pack-artifact provenance gate at the branch under test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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//head — which exists on origin even for fork PRs, unlike head.ref, which only exists on the author's repository. --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d1a227cde7..ab4a44268d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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//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).