Skip to content

Commit 779b6e3

Browse files
[Internal] Automatically trigger integration tests on PR (#369)
## Changes Automatically trigger integration tests when a PR is opened or updated ## Tests Workflow below.
1 parent 7b32354 commit 779b6e3

File tree

1 file changed

+57
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)