Skip to content

ci: Use gh pr list to get PR number#8123

Merged
yurishkuro merged 1 commit intojaegertracing:mainfrom
yurishkuro:fix-codecov-gate-4
Mar 2, 2026
Merged

ci: Use gh pr list to get PR number#8123
yurishkuro merged 1 commit intojaegertracing:mainfrom
yurishkuro:fix-codecov-gate-4

Conversation

@yurishkuro
Copy link
Copy Markdown
Member

No description provided.

Signed-off-by: Yuri Shkuro <github@ysh.us>
Copilot AI review requested due to automatic review settings March 2, 2026 01:40
@yurishkuro yurishkuro requested a review from a team as a code owner March 2, 2026 01:40
@yurishkuro yurishkuro added the changelog:ci Change related to continuous integration / testing label Mar 2, 2026
@yurishkuro yurishkuro merged commit e5c655b into jaegertracing:main Mar 2, 2026
62 checks passed
@yurishkuro yurishkuro deleted the fix-codecov-gate-4 branch March 2, 2026 01:41
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the CI Summary Report workflow to better resolve the PR number for workflow_run-triggered executions (notably when the workflow_run.pull_requests array is empty), so the workflow can still post PR comments and checks.

Changes:

  • Add a fallback path that uses gh pr list to locate the PR number by head branch when workflow_run.pull_requests[0] is missing.
  • Log the resolved PR number for easier debugging of fork PR scenarios.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +78 to +80
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gh pr list can return multiple PRs for the same head: search (e.g., same branch name across forks), and the current --jq expression would then output multiple numbers separated by newlines. That can corrupt subsequent $GITHUB_OUTPUT writes (pr_number=$PR_NUMBER) and make the workflow flaky. Consider constraining the query (--limit 1, --state open) and/or making the jq expression return a single scalar (e.g., pick the first match) and only logging success when PR_NUMBER is non-empty/non-null.

Suggested change
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
--state open \
--limit 20 \
--json number,headRefOid \
--jq "map(select(.headRefOid == \"$HEAD_SHA\")) | .[0].number")
if [ -n "$PR_NUMBER" ] && [ "$PR_NUMBER" != "null" ]; then
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
fi

Copilot uses AI. Check for mistakes.
Comment on lines +72 to +73
# workflow_run.pull_requests is empty for fork PRs (renovate-bot, dependabot, etc.).
# Fall back to searching for a PR matching the head branch.
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment says fork PRs are "(renovate-bot, dependabot, etc.)", but those actors don't necessarily imply a cross-repo fork (e.g., dependabot PRs are typically branches on the same repo). Consider rewording to describe the actual condition (workflow_run.pull_requests is empty for cross-repo fork PRs) to avoid misleading future readers.

Suggested change
# workflow_run.pull_requests is empty for fork PRs (renovate-bot, dependabot, etc.).
# Fall back to searching for a PR matching the head branch.
# For cross-repo fork PRs, workflow_run.pull_requests is empty in the event payload.
# In that case, fall back to searching for a PR matching the head branch and commit.

Copilot uses AI. Check for mistakes.
Comment on lines +73 to +80
# Fall back to searching for a PR matching the head branch.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh pr list \
--repo "${{ github.repository }}" \
--search "head:${{ github.event.workflow_run.head_branch }}" \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fork-PR fallback is likely never going to match because HEAD_SHA falls back to github.event.workflow_run.head_sha, which (for workflows triggered by pull_request) is typically the PR merge commit SHA, while gh pr list --json headRefOid returns the PR head commit OID. This means the select(.headRefOid == "$HEAD_SHA") filter will often produce no results and PR_NUMBER stays empty. Prefer resolving the PR number directly from the run SHA via the REST endpoint repos/{owner}/{repo}/commits/{sha}/pulls (or request/compare against the PR's merge commit OID instead of headRefOid).

Suggested change
# Fall back to searching for a PR matching the head branch.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh pr list \
--repo "${{ github.repository }}" \
--search "head:${{ github.event.workflow_run.head_branch }}" \
--json number,headRefOid \
--jq ".[] | select(.headRefOid == \"$HEAD_SHA\") | .number")
echo "Resolved PR #$PR_NUMBER from head branch (fork PR fallback)"
# Fall back to resolving the PR directly from the run's commit SHA.
if [ -z "$PR_NUMBER" ] && [ "${{ github.event.workflow_run.event }}" == "pull_request" ]; then
PR_NUMBER=$(gh api "repos/${{ github.repository }}/commits/$HEAD_SHA/pulls" --jq '.[0].number')
echo "Resolved PR #$PR_NUMBER from commit SHA $HEAD_SHA (fork PR fallback)"

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.67%. Comparing base (aeab642) to head (1c8e6bc).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #8123   +/-   ##
=======================================
  Coverage   95.67%   95.67%           
=======================================
  Files         317      317           
  Lines       16734    16734           
=======================================
  Hits        16010    16010           
  Misses        571      571           
  Partials      153      153           
Flag Coverage Δ
badger_v1 9.06% <ø> (ø)
badger_v2 1.04% <ø> (ø)
cassandra-4.x-v1-manual 13.26% <ø> (ø)
cassandra-4.x-v2-auto 1.03% <ø> (ø)
cassandra-4.x-v2-manual 1.03% <ø> (ø)
cassandra-5.x-v1-manual 13.26% <ø> (ø)
cassandra-5.x-v2-auto 1.03% <ø> (ø)
cassandra-5.x-v2-manual 1.03% <ø> (ø)
clickhouse 1.16% <ø> (ø)
elasticsearch-6.x-v1 16.62% <ø> (ø)
elasticsearch-7.x-v1 16.65% <ø> (ø)
elasticsearch-8.x-v1 16.80% <ø> (ø)
elasticsearch-8.x-v2 1.04% <ø> (ø)
elasticsearch-9.x-v2 1.04% <ø> (-0.05%) ⬇️
grpc_v1 7.80% <ø> (ø)
grpc_v2 1.04% <ø> (ø)
kafka-3.x-v2 1.04% <ø> (ø)
memory_v2 1.04% <ø> (ø)
opensearch-1.x-v1 16.70% <ø> (ø)
opensearch-2.x-v1 16.70% <ø> (ø)
opensearch-2.x-v2 1.04% <ø> (ø)
opensearch-3.x-v2 1.04% <ø> (ø)
query 1.04% <ø> (ø)
tailsampling-processor 0.52% <ø> (ø)
unittests 94.35% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog:ci Change related to continuous integration / testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants