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).