From 2a4d3f589dafbce3bc92bf927101105e026a3c75 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Mon, 25 May 2026 17:52:24 +0000 Subject: [PATCH 1/2] ci(contributor-check): add base-ref fallback for Gitea checkout robustness MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Gitea Actions + act_runner sometimes do not fetch the PR base ref (origin/main) even with fetch-depth: 0, causing `git merge-base` and `git diff --name-only` to fail with fatal errors. Add the same fallback pattern already used in tests.yml: 1. Try `git cat-file -e` to verify the base SHA exists. 2. If missing, `git fetch --depth=100 origin main`. 3. If still missing, fall back to `git merge-base origin/main HEAD`. 4. If merge-base also fails, exit with a clear error message. Also use `${{ github.event.pull_request.base.sha }}` consistently in both steps instead of mixing event vars with `origin/main`. Local-only change — defer PR open until CTO unblocks bundle. Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/contributor-check.yml | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/contributor-check.yml b/.gitea/workflows/contributor-check.yml index c246b6de..8900c40c 100644 --- a/.gitea/workflows/contributor-check.yml +++ b/.gitea/workflows/contributor-check.yml @@ -22,6 +22,10 @@ jobs: set -euo pipefail BASE="${{ github.event.pull_request.base.sha }}" HEAD="${{ github.event.pull_request.head.sha }}" + # Ensure the base ref exists (Gitea checkout may not fetch it). + if ! git cat-file -e "$BASE" 2>/dev/null; then + git fetch --depth=100 origin main || true + fi changed="$(git diff --name-only "$BASE" "$HEAD")" printf '%s\n' "$changed" if printf '%s\n' "$changed" | grep -Eq '(^|/).*\.py$'; then @@ -37,11 +41,26 @@ jobs: - name: Check for unmapped contributor emails if: steps.changes.outputs.run == 'true' run: | - # Get the merge base between this PR and main - MERGE_BASE=$(git merge-base origin/main HEAD) + set -euo pipefail + BASE="${{ github.event.pull_request.base.sha }}" + HEAD="${{ github.event.pull_request.head.sha }}" + + # Ensure the base ref exists (Gitea checkout may not fetch it). + if ! git cat-file -e "$BASE" 2>/dev/null; then + git fetch --depth=100 origin main || true + fi + + # If we still can't resolve the base, fall back to merge-base. + if ! git cat-file -e "$BASE" 2>/dev/null; then + BASE=$(git merge-base origin/main HEAD 2>/dev/null || echo "") + if [ -z "$BASE" ]; then + echo "❌ Cannot determine merge base — cannot verify attribution." + exit 1 + fi + fi # Find any new author emails in this PR's commits - NEW_EMAILS=$(git log ${MERGE_BASE}..HEAD --format='%ae' --no-merges | sort -u) + NEW_EMAILS=$(git log "${BASE}..${HEAD}" --format='%ae' --no-merges | sort -u) if [ -z "$NEW_EMAILS" ]; then echo "No new commits to check." -- 2.52.0 From 71f6acfe25d5406a6b5fcb378b1bf798c53d1c49 Mon Sep 17 00:00:00 2001 From: "Molecule AI Dev Engineer A (Kimi)" Date: Mon, 25 May 2026 20:23:02 +0000 Subject: [PATCH 2/2] ci(tests): add merge-base fallback for Gitea shallow clones Apply the same base-ref resolution pattern from contributor-check.yml to tests.yml so that change-detection skips don't incorrectly default to run=true when the PR base sha is unreachable after fetch. Co-Authored-By: Claude Opus 4.7 --- .gitea/workflows/tests.yml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/.gitea/workflows/tests.yml b/.gitea/workflows/tests.yml index c353b82c..39a322b3 100644 --- a/.gitea/workflows/tests.yml +++ b/.gitea/workflows/tests.yml @@ -44,8 +44,11 @@ jobs: git fetch --depth=100 origin main || true fi if ! git cat-file -e "$base" 2>/dev/null; then - echo "run=true" >> "$GITHUB_OUTPUT" - exit 0 + base=$(git merge-base origin/main HEAD 2>/dev/null || echo "") + if [ -z "$base" ]; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + fi fi changed="$(git diff --name-only "$base" "$head")" printf '%s\n' "$changed" @@ -134,8 +137,11 @@ jobs: git fetch --depth=100 origin main || true fi if ! git cat-file -e "$base" 2>/dev/null; then - echo "run=true" >> "$GITHUB_OUTPUT" - exit 0 + base=$(git merge-base origin/main HEAD 2>/dev/null || echo "") + if [ -z "$base" ]; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + fi fi changed="$(git diff --name-only "$base" "$head")" printf '%s\n' "$changed" -- 2.52.0