Skip to content

Commit dac9a9e

Browse files
[Internal] Automatically trigger integration tests (#1067)
## 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 b47ecac commit dac9a9e

File tree

1 file changed

+19
-30
lines changed

1 file changed

+19
-30
lines changed

.github/workflows/integration-tests.yml

Lines changed: 19 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,34 @@ on:
99

1010

1111
jobs:
12-
write-message:
12+
trigger-tests:
1313
if: github.event_name == 'pull_request'
14-
name: Write Message
14+
name: Trigger Tests
1515
runs-on: ubuntu-latest
16+
environment: "test-trigger-is"
1617

1718
steps:
1819
- uses: actions/checkout@v3
1920

20-
- name: Delete old comments
21-
env:
22-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23-
run: |
24-
# Delete previous comment if it exists
25-
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
26-
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id')
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
34-
fi
35-
36-
- name: Write new comment
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
3731
env:
38-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
3933
run: |
40-
gh pr comment ${{ github.event.pull_request.number }} --body \
41-
"<!-- INTEGRATION_TESTS -->
42-
Run integration tests using the corresponding workflow:
43-
44-
Inputs:
45-
PR Number:${{github.event.pull_request.number}}
46-
Commit SHA:${{ github.event.pull_request.head.sha }}
47-
48-
This check will be approved automatically on success.
49-
"
34+
gh workflow run sdk-go-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 }}
5038
39+
5140
# The hash for the merge queue may not be the same as the hash for the PR.
5241
# Auto approve the check for the merge queue to avoid running integration tests twice.
5342
auto-approve:

0 commit comments

Comments
 (0)