Skip to content

Commit 34f37f9

Browse files
[Internal] Use statuses instead of checks (#1036)
## Changes Use statuses instead of checks ## Tests <!-- How is this tested? Please see the checklist below and also describe any other relevant tests --> This PR ![Screenshot 2024-09-03 at 09 19 44](https://github.com/user-attachments/assets/bfc6a04a-6d84-4212-b0b8-9bd884b4aaf8)
1 parent 590d597 commit 34f37f9

File tree

2 files changed

+40
-144
lines changed

2 files changed

+40
-144
lines changed

.github/workflows/check-mark.yml

Lines changed: 0 additions & 104 deletions
This file was deleted.

.github/workflows/integration-tests.yml

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,64 +3,64 @@ name: Integration Tests
33
on:
44

55
pull_request:
6-
branches: [ main ]
6+
types: [opened, synchronize]
7+
8+
merge_group:
9+
710

811
jobs:
9-
check:
10-
name: Run Check
12+
write-message:
13+
if: github.event_name == 'pull_request'
14+
name: Write Message
1115
runs-on: ubuntu-latest
1216

1317
steps:
1418
- uses: actions/checkout@v3
1519

16-
- name: Create Check
17-
env:
18-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19-
run: |
20-
check_run_id=$(gh api -X POST -H "Accept: application/vnd.github+json" \
21-
-H "X-GitHub-Api-Version: 2022-11-28" \
22-
-f name='Integration Tests Check' \
23-
-f head_sha=${{ github.sha }} \
24-
-f status='queued' \
25-
-f output[title]="Integration Tests Check" \
26-
-f output[summary]="This check is being created." \
27-
--jq '.id' \
28-
/repos/${{ github.repository }}/check-runs)
29-
30-
# Adding instructions to the check details.
31-
gh api -X PATCH -H "Accept: application/vnd.github+json" \
32-
-H "X-GitHub-Api-Version: 2022-11-28" \
33-
-f 'status=queued' \
34-
-f name='Integration Tests Check' \
35-
-f output[title]="Integration Tests Check" \
36-
-f output[summary]="Waiting for test to run." \
37-
-f output[text]="Run the corresponding workflow using the provided check_run_id:
38-
Check Run ID: $check_run_id " \
39-
/repos/${{ github.repository }}/check-runs/$check_run_id
40-
41-
echo "CHECK_RUN_ID=$check_run_id" >> $GITHUB_ENV
42-
43-
- name: Write PR Comment
20+
- name: Delete old comments
4421
env:
4522
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4623
run: |
4724
# Delete previous comment if it exists
48-
previous_comment_id=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
25+
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
4926
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id')
50-
if [ ! -z "$previous_comment_id" ]; then
51-
gh api repos/${{ github.repository }}/issues/comments/$previous_comment_id -X DELETE
27+
echo "Previous comment IDs: $previous_comment_ids"
28+
# Iterate over each comment ID and delete the comment
29+
if [ ! -z "$previous_comment_ids" ]; then
30+
echo "$previous_comment_ids" | while read -r comment_id; do
31+
echo "Deleting comment with ID: $comment_id"
32+
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" -X DELETE
33+
done
5234
fi
53-
54-
# Add new comment
35+
36+
- name: Write new comment
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
39+
run: |
5540
gh pr comment ${{ github.event.pull_request.number }} --body \
5641
"<!-- INTEGRATION_TESTS -->
5742
Run integration tests using the corresponding workflow:
5843
5944
Inputs:
60-
pull_request_number=${{github.event.pull_request.number}}
61-
check_run_id=${{ env.CHECK_RUN_ID }}
45+
PR Number:${{github.event.pull_request.number}}
46+
Commit SHA:${{ github.event.pull_request.head.sha }}
6247
6348
This check will be approved automatically on success.
64-
65-
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ env.CHECK_RUN_ID }}
6649
"
50+
51+
# The hash for the merge queue may not be the same as the hash for the PR.
52+
# Auto approve the check for the merge queue to avoid running integration tests twice.
53+
auto-approve:
54+
if: github.event_name == 'merge_group'
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Mark Check
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
shell: bash
61+
run: |
62+
gh api -X POST -H "Accept: application/vnd.github+json" \
63+
-H "X-GitHub-Api-Version: 2022-11-28" \
64+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
65+
-f 'state=success' \
66+
-f 'context=Integration Tests Check'

0 commit comments

Comments
 (0)