From ca24b0fe27b107b3f939cfa26dca675f0aa406dc Mon Sep 17 00:00:00 2001 From: Molecule AI Core-BE Date: Thu, 14 May 2026 03:05:40 +0000 Subject: [PATCH] fix(ci): use GITHUB_EVENT_BEFORE in handlers-pg-integ detect-changes Gitea Actions `github.event.before` template expression evaluates to empty string in shell scripts. Replace with the GITHUB_EVENT_BEFORE shell environment variable (correctly populated for push events). Same fix as #919 (runtime-prbuild-compat.yml) applied here. Also adds timeout 30 guards around both `git cat-file -e` calls to prevent indefinite hangs on corrupted refs. Refs: molecule-ai/molecule-core#919 Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/handlers-postgres-integration.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/handlers-postgres-integration.yml b/.gitea/workflows/handlers-postgres-integration.yml index bb4cd81e..65203fc3 100644 --- a/.gitea/workflows/handlers-postgres-integration.yml +++ b/.gitea/workflows/handlers-postgres-integration.yml @@ -90,18 +90,25 @@ jobs: - id: filter # Inline replacement for dorny/paths-filter — see e2e-api.yml. run: | - BASE="${GITHUB_BASE_REF:-${{ github.event.before }}}" + # Gitea Actions evaluates github.event.before to empty string in shell + # scripts. Use GITHUB_EVENT_BEFORE shell env var instead (Gitea + # correctly populates it for push events). PR case uses template var. + BASE="" if [ "${{ github.event_name }}" = "pull_request" ] && [ -n "${{ github.event.pull_request.base.sha }}" ]; 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 echo "handlers=true" >> "$GITHUB_OUTPUT" exit 0 fi - if ! git cat-file -e "$BASE" 2>/dev/null; then + # timeout 30 guards against the case where BASE points to a ref that + # git can resolve but cat-file hangs (rare on corrupted objects). + 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 "handlers=true" >> "$GITHUB_OUTPUT" exit 0 fi -- 2.45.2