@@ -3,64 +3,64 @@ name: Integration Tests
33on :
44
55 pull_request :
6- branches : [ main ]
6+ types : [opened, synchronize]
7+
8+ merge_group :
9+
710
811jobs :
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