-
Notifications
You must be signed in to change notification settings - Fork 42
74 lines (60 loc) · 2.63 KB
/
integration-tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
name: Integration Tests
on:
pull_request:
branches: [ main ]
jobs:
check:
name: Run Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: List checks
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
respr=$(gh pr checks ${{github.event.pull_request.number}})
echo $respr
- name: Create Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
check_run_id=$(gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f name='Integration Tests Check' \
-f head_sha=${{ github.sha }} \
-f status='queued' \
-f output[title]="Integration Tests Check" \
-f output[summary]="This check is being created." \
--jq '.id' \
/repos/${{ github.repository }}/check-runs)
# Adding instructions to the check details.
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'status=queued' \
-f name='Integration Tests Check' \
-f output[title]="Integration Tests Check" \
-f output[summary]="Waiting for test to run." \
-f output[text]="Run the corresponding workflow using the provided check_run_id:
Check Run ID: $check_run_id " \
/repos/${{ github.repository }}/check-runs/$check_run_id
echo "CHECK_RUN_ID=$check_run_id" >> $GITHUB_ENV
- name: Write PR Comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete previous comment if it exists
previous_comment_id=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id')
if [ ! -z "$previous_comment_id" ]; then
gh api repos/${{ github.repository }}/issues/comments/$previous_comment_id -X DELETE
fi
# Add new comment
gh pr comment ${{ github.event.pull_request.number }} --body \
"<!-- INTEGRATION_TESTS -->
Run integration tests using the corresponding workflow:
Inputs:
pull_request_number=${{github.event.pull_request.number}}
check_run_id=${{ env.CHECK_RUN_ID }}
This check will be approved automatically on success.
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ env.CHECK_RUN_ID }}
"