Skip to content

Commit a1bfd69

Browse files
[Internal] Automatically trigger integration tests on PR (#800)
## Changes Automatically trigger integration tests when a PR is opened or updated ## Tests Updated workflow triggered the tests. On success, the tests marked the check as succesfull. - [ ] `make test` passing - [ ] `make fmt` applied - [ ] relevant integration tests applied
1 parent d3b85cb commit a1bfd69

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Integration Tests
2+
3+
on:
4+
5+
pull_request:
6+
types: [opened, synchronize]
7+
8+
merge_group:
9+
10+
11+
jobs:
12+
trigger-tests:
13+
if: github.event_name == 'pull_request'
14+
name: Trigger Tests
15+
runs-on: ubuntu-latest
16+
environment: "test-trigger-is"
17+
18+
steps:
19+
- uses: actions/checkout@v3
20+
21+
- name: Generate GitHub App Token
22+
id: generate-token
23+
uses: actions/create-github-app-token@v1
24+
with:
25+
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
26+
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
27+
owner: ${{ secrets.ORG_NAME }}
28+
repositories: ${{secrets.REPO_NAME}}
29+
30+
- name: Trigger Workflow in Another Repo
31+
env:
32+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
33+
run: |
34+
gh workflow run sdk-py-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
35+
--ref main \
36+
-f pull_request_number=${{ github.event.pull_request.number }} \
37+
-f commit_sha=${{ github.event.pull_request.head.sha }}
38+
39+
# Statuses and checks apply to specific commits (by hash).
40+
# Enforcement of required checks is done both at the PR level and the merge queue level.
41+
# In case of multiple commits in a single PR, the hash of the squashed commit
42+
# will not match the one for the latest (approved) commit in the PR.
43+
# We auto approve the check for the merge queue for two reasons:
44+
# * Queue times out due to duration of tests.
45+
# * Avoid running integration tests twice, since it was already run at the tip of the branch before squashing.
46+
auto-approve:
47+
if: github.event_name == 'merge_group'
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Mark Check
51+
env:
52+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
53+
shell: bash
54+
run: |
55+
gh api -X POST -H "Accept: application/vnd.github+json" \
56+
-H "X-GitHub-Api-Version: 2022-11-28" \
57+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
58+
-f 'state=success' \
59+
-f 'context=Integration Tests Check'

0 commit comments

Comments
 (0)