Skip to content

Commit 999dda7

Browse files
Python: skip API check when merge ref is unavailable (#8439)
* CI: skip API check without current merge ref Co-authored-by: Copilot App <[email protected]> Copilot-Session: d1fa3e1a-596f-446f-b77f-5c84ec1eaa38 * CI: distinguish missing API merge refs Co-authored-by: Copilot App <[email protected]> Copilot-Session: d1fa3e1a-596f-446f-b77f-5c84ec1eaa38 --------- Copilot-Session: d1fa3e1a-596f-446f-b77f-5c84ec1eaa38
1 parent 39238b5 commit 999dda7

2 files changed

Lines changed: 32 additions & 3 deletions

File tree

‎.github/workflows/python-api-compatibility.yml‎

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,45 @@ jobs:
4545
UV_NO_CONFIG: "1"
4646
shell: bash
4747
run: |
48+
skip_comparison() {
49+
local reason="$1"
50+
echo "::notice title=Python public API compatibility::$reason"
51+
{
52+
echo "## Python public API compatibility"
53+
echo
54+
echo "Comparison skipped: $reason"
55+
} >> "$GITHUB_STEP_SUMMARY"
56+
exit 0
57+
}
58+
59+
set +e
60+
git ls-remote \
61+
--exit-code \
62+
--refs \
63+
"https://github.com/$GITHUB_REPOSITORY.git" \
64+
"refs/pull/$PR_NUMBER/merge" > /dev/null
65+
ref_status=$?
66+
set -e
67+
if (( ref_status == 2 )); then
68+
skip_comparison "GitHub has not produced a synthetic merge ref for the current pull request head."
69+
fi
70+
if (( ref_status != 0 )); then
71+
echo "Failed to query the pull request merge ref (exit $ref_status)." >&2
72+
exit "$ref_status"
73+
fi
74+
4875
git -C "$GITHUB_WORKSPACE" fetch \
4976
--no-tags \
5077
--no-recurse-submodules \
5178
--depth=2 \
5279
"https://github.com/$GITHUB_REPOSITORY.git" \
5380
"refs/pull/$PR_NUMBER/merge"
81+
5482
MERGE_SHA="$(git -C "$GITHUB_WORKSPACE" rev-parse --verify 'FETCH_HEAD^{commit}')"
5583
BASE_SHA="$(git -C "$GITHUB_WORKSPACE" rev-parse "$MERGE_SHA^1")"
5684
HEAD_SHA="$(git -C "$GITHUB_WORKSPACE" rev-parse "$MERGE_SHA^2")"
5785
if [[ "$HEAD_SHA" != "$EXPECTED_HEAD_SHA" ]]; then
58-
echo "Fetched merge ref head $HEAD_SHA does not match event head $EXPECTED_HEAD_SHA." >&2
59-
exit 1
86+
skip_comparison "GitHub's synthetic merge ref is not current for pull request head $EXPECTED_HEAD_SHA."
6087
fi
6188
6289
PR_SOURCE="$RUNNER_TEMP/pr-source"

‎CONTRIBUTING.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ in the job summary. The experimental `agent-framework-lab` package is excluded.
8383
workflow checks out only trusted base-branch code, fetches GitHub's synthetic merge commit
8484
without checking it out, and statically parses its Python source from a temporary directory
8585
without importing it. This supports fork pull requests while keeping the comparison current
86-
when a pull request branch is behind `main`.
86+
when a pull request branch is behind `main`. If GitHub has not produced a current synthetic
87+
merge ref—typically while the pull request has merge conflicts—the advisory comparison is
88+
skipped and reruns when the pull request is updated.
8789

8890
Only APIs from packages marked `released` in `python/PACKAGE_STATUS.md` are checked.
8991
Prerelease packages and APIs marked with `@experimental` or `@release_candidate`—including

0 commit comments

Comments
 (0)