Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions .github/workflows/check-for-integration-result-comment.yml

This file was deleted.

105 changes: 105 additions & 0 deletions .github/workflows/integration-result.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: integration-result

on:
status:

jobs:
label:
if: >-
startsWith(github.event.context, 'github-ui') &&
contains(fromJSON('["success", "failure", "error"]'), github.event.state) &&
github.event.description != 'Skipped' &&
github.event.description != 'Manual override'
runs-on: ubuntu-latest
permissions:
statuses: read
pull-requests: write
steps:
- name: Find pull request for status commit
id: pull-request
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.event.sha }}
shell: bash
run: |
pull_requests=$(gh api --paginate --slurp \
"repos/$GH_REPO/commits/$SHA/pulls?per_page=100")

number=$(jq -r --arg sha "$SHA" '
[ .[][] | select(.state == "open" and .head.sha == $sha) | .number ]
| unique
| if length > 1 then
error("Multiple open pull requests match the status commit")
else
.[0] // empty
end
' <<< "$pull_requests")

echo "number=$number" >> "$GITHUB_OUTPUT"
- name: Get status check results
id: integration
if: ${{ steps.pull-request.outputs.number != '' }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.event.sha }}
shell: bash
run: |
statuses=$(gh api --paginate --slurp \
"repos/$GH_REPO/commits/$SHA/status?per_page=100")

passing=$(jq '
[.[].statuses[] | select(.context | startswith("github-ui"))]
| length > 0 and all(.[]; .state == "success")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Added an explicit skipped/override check across the aggregated statuses and bypassed label updates when either description is present. Fixed in 8229210.

' <<< "$statuses")

failing=$(jq '
[.[].statuses[] | select(.context | startswith("github-ui"))]
| any(.[]; .state == "failure" or .state == "error")
' <<< "$statuses")

skipped=$(jq '
[.[].statuses[]
| select(.context | startswith("github-ui"))
| select(.description == "Skipped" or .description == "Manual override")]
| length > 0
' <<< "$statuses")

echo "passing=$passing" >> "$GITHUB_OUTPUT"
echo "failing=$failing" >> "$GITHUB_OUTPUT"
echo "skipped=$skipped" >> "$GITHUB_OUTPUT"
- name: Update integration labels
if: ${{ (steps.integration.outputs.passing == 'true' || steps.integration.outputs.failing == 'true') && steps.integration.outputs.skipped != 'true' }}
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
SHA: ${{ github.event.sha }}
PR_NUMBER: ${{ steps.pull-request.outputs.number }}
PASSING: ${{ steps.integration.outputs.passing }}
shell: bash
run: |
if [ "$PASSING" = "true" ]; then
ADD_LABEL="integration-tests: passing"
REMOVE_LABEL="integration-tests: failing"
else
ADD_LABEL="integration-tests: failing"
REMOVE_LABEL="integration-tests: passing"
fi

pull_request=$(gh pr view -R "$GH_REPO" "$PR_NUMBER" \
--json labels,headRefOid,state)

eligible=$(jq --arg sha "$SHA" '
.state == "OPEN" and .headRefOid == $sha and
all(.labels[]; .name != "integration-tests: skipped manually")
' <<< "$pull_request")

if [ "$eligible" != "true" ]; then
echo "Skipping PR #$PR_NUMBER: closed, outdated commit, or manually skipped"
exit 0
fi

gh pr edit -R "$GH_REPO" "$PR_NUMBER" \
--add-label "$ADD_LABEL" \
--remove-label "$REMOVE_LABEL"
Loading