Skip to content

Commit c7a6294

Browse files
bryan-coxclaude
andauthored
CNTRLPLANE-3278: fix verify-workflows to check PR head, not merge commit (#78025)
ci-operator runs tests on a merge commit (PR merged into base branch). The verify-workflows script was comparing workflow files on HEAD, which is the merge result and always contains main's files. This caused the check to always pass, even for PRs with outdated workflows. Fix by extracting the actual PR head commit (HEAD^2, the second parent of the merge) and comparing that against main instead. Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 5457d5b commit c7a6294

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

ci-operator/config/openshift/hypershift/openshift-hypershift-main.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,12 +490,21 @@ tests:
490490
exit 1
491491
fi
492492
MAIN_REF="FETCH_HEAD"
493-
BASE=$(git merge-base HEAD "$MAIN_REF")
493+
# ci-operator runs on a merge commit (PR merged into base). HEAD is the
494+
# merge result, so workflow files from main are already present. We need
495+
# the actual PR head commit (second parent of the merge) to detect
496+
# outdated files on the PR branch itself.
497+
PR_HEAD=$(git rev-parse HEAD^2 2>/dev/null) || PR_HEAD="HEAD"
498+
BASE=$(git merge-base "$PR_HEAD" "$MAIN_REF")
499+
echo "PR_HEAD: $(git rev-parse "$PR_HEAD")"
500+
echo "MAIN: $(git rev-parse "$MAIN_REF")"
501+
echo "BASE: $BASE"
502+
echo ""
494503
FAILED=0
495504
while IFS= read -r file; do
496505
[ -z "$file" ] && continue
497506
main_hash=$(git rev-parse "${MAIN_REF}:${file}" 2>/dev/null) || continue
498-
head_hash=$(git rev-parse "HEAD:${file}" 2>/dev/null) || head_hash=""
507+
head_hash=$(git rev-parse "${PR_HEAD}:${file}" 2>/dev/null) || head_hash=""
499508
if [ -z "$head_hash" ]; then
500509
echo "MISSING: $file exists on main but not on this branch."
501510
FAILED=1

0 commit comments

Comments
 (0)