Skip to content

Commit c50f6b7

Browse files
committed
[WIP] Run Integration Tests on PR
1 parent 887d63c commit c50f6b7

File tree

2 files changed

+109
-0
lines changed

2 files changed

+109
-0
lines changed
+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Integration Tests
2+
on:
3+
repository_dispatch:
4+
types: [integration-check]
5+
jobs:
6+
myEvent:
7+
runs-on: ubuntu-latest
8+
steps:
9+
####################################################
10+
# Update the status to show that the queued message
11+
# was received and is being processed
12+
####################################################
13+
- name: Acknowledge Request
14+
env:
15+
GH_TOKEN: ${{ github.token }}
16+
run: |
17+
gh api -X PATCH -H "Accept: application/vnd.github+json" \
18+
-H "X-GitHub-Api-Version: 2022-11-28" \
19+
-f 'status=in_progress' \
20+
-f 'output[title]=Integration Tests' \
21+
-f 'output[summary]=Running Integration Tests for Py SDK' \
22+
/repos/${{ github.repository }}/check-runs/${{ github.event.client_payload.checkRunId }}
23+
24+
####################################################
25+
# Actually, we'll just sleep to simulate some work
26+
####################################################
27+
- name: Processing
28+
run: sleep 10
29+
30+
#####################################################
31+
# Send a final message to complete the run and
32+
# provide any final updates. Doing this one in JSON
33+
# to make it more readable. This approach can also
34+
# be used to get total control over the serialized
35+
# data types (for example, integers).
36+
#####################################################
37+
- name: Complete Check
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
gh api -X PATCH -H "Accept: application/vnd.github+json" \
42+
-H "X-GitHub-Api-Version: 2022-11-28" \
43+
/repos/${{ github.repository }}/check-runs/${{ github.event.client_payload.checkRunId }} \
44+
--input - <<- EOF
45+
{
46+
"conclusion": "success",
47+
"details_url": "TODO",
48+
"output": {
49+
"title": "Integration Tests",
50+
"summary": "**Summary**: The run completed.",
51+
"text": "Everything worked as expected."
52+
}
53+
}
54+
EOF

.github/workflows/test-check.yml

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Integration Tests Validation
2+
3+
# To trigger the check
4+
on:
5+
pull_request:
6+
branches: [ "main" ]
7+
8+
jobs:
9+
start-check:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
checks: write # Permission to create a Check Run
13+
contents: write # Permission to write a repository_dispatch requests
14+
steps:
15+
- name: Integration Tests Check
16+
id: testcheck # An ID to allow the step to be referenced
17+
env:
18+
GH_TOKEN: ${{ github.token }} # Expose the token for GH CLI
19+
run: |
20+
##########################################################
21+
# Create a Check Run and indicate that it is being queued
22+
# Use --jq to return the ID
23+
##########################################################
24+
25+
CHECKID=$(gh api -X POST -H "Accept: application/vnd.github+json" \
26+
-H "X-GitHub-Api-Version: 2022-11-28" \
27+
-f name='Integration Tests Check' \
28+
-f head_sha='${{ github.event.pull_request.head.sha }}' \
29+
-f status='queued' \
30+
-f 'output[title]=Integration Tests' \
31+
-f 'output[summary]=Pending Integration Tests for Py SDK' \
32+
--jq '.id' \
33+
/repos/${{ github.repository }}/check-runs)
34+
35+
####################################################
36+
# Put the ID into a step variable
37+
####################################################
38+
39+
echo "checkId=$CHECKID" >> $GITHUB_OUTPUT
40+
41+
- name: Trigger Integration Tests
42+
env:
43+
GH_TOKEN: ${{ github.token }}
44+
run: |
45+
##########################################################
46+
# Create a repository_dispatch event of type my-check
47+
# Send the SHA and the Check Run ID in the client_payload
48+
##########################################################
49+
50+
gh api -X POST -H "Accept: application/vnd.github+json" \
51+
-H "X-GitHub-Api-Version: 2022-11-28" \
52+
-f 'event_type=integration-check' \
53+
-f 'client_payload[checkRunId]=${{ steps.checkrun.outputs.checkId }}' \
54+
-f 'client_payload[sha]=${{ github.sha }}' \
55+
/repos/${{ github.repository }}/dispatches

0 commit comments

Comments
 (0)