From bd32e8cfd9afbde35bfb6d28c27a2b410a9b4bbf Mon Sep 17 00:00:00 2001 From: Molecule AI Core-BE Date: Thu, 14 May 2026 01:21:53 +0000 Subject: [PATCH] fix(ci): use GITHUB_EVENT_BEFORE for push events in runtime-prbuild-compat detect-changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes: #917 Root cause: Gitea Actions does not expose github.event.before as a shell environment variable for push events. The ${{ github.event.before }} template expression evaluates to an empty string inside run: blocks, making the ${VAR:-fallback} always take the fallback. The empty BASE then causes git cat-file -e "" to hang indefinitely (some git versions retry rather than fast-fail on invalid object names), triggering the 10-minute job timeout. Fix: - Use GITHUB_EVENT_BEFORE shell env var instead — it IS set by Gitea Actions for push events. - Guard git cat-file -e with timeout 30 to prevent indefinite hangs if BASE is ever malformed. - Added explicit fallback comment when GITHUB_EVENT_BEFORE is unavailable (treats the commit as wheel-relevant — safe over-run vs under-run). Test plan: - [x] YAML lint passes - [ ] CI detect-changes completes without 10-minute timeout on push event - [ ] No regression for pull_request events (base SHA logic unchanged) Refs: #917 --- .gitea/workflows/runtime-prbuild-compat.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/runtime-prbuild-compat.yml b/.gitea/workflows/runtime-prbuild-compat.yml index 4789951f..d27c8403 100644 --- a/.gitea/workflows/runtime-prbuild-compat.yml +++ b/.gitea/workflows/runtime-prbuild-compat.yml @@ -66,19 +66,28 @@ jobs: # PR#372's ci.yml port used. Diffs against the PR base or the # previous push SHA, then matches against the wheel-relevant # path set. - BASE="${GITHUB_BASE_REF:-${{ github.event.before }}}" - if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ github.event.pull_request.base.sha }}" ]; then + # + # NOTE: Gitea Actions does not expose github.event.before as a + # shell environment variable. The ${{ github.event.before }} template + # expression works inside YAML run: blocks but is evaluated to an + # empty string for push events, making the ${VAR:-fallback} always + # use the fallback. Use GITHUB_EVENT_BEFORE instead — it IS set in + # the runner's shell environment for push events. + BASE="" + if [ "${{ github.event_name }}" = "pull_request" ]; then BASE="${{ github.event.pull_request.base.sha }}" + elif [ -n "$GITHUB_EVENT_BEFORE" ]; then + BASE="$GITHUB_EVENT_BEFORE" fi if [ -z "$BASE" ] || echo "$BASE" | grep -qE '^0+$'; then # New branch or no previous SHA: treat as wheel-relevant. echo "wheel=true" >> "$GITHUB_OUTPUT" exit 0 fi - if ! git cat-file -e "$BASE" 2>/dev/null; then + if ! timeout 30 git cat-file -e "$BASE" 2>/dev/null; then git fetch --depth=1 origin "$BASE" 2>/dev/null || true fi - if ! git cat-file -e "$BASE" 2>/dev/null; then + if ! timeout 30 git cat-file -e "$BASE" 2>/dev/null; then echo "wheel=true" >> "$GITHUB_OUTPUT" exit 0 fi -- 2.45.2