Skip to content

Commit

Permalink
[Internal] Automatically trigger integration tests (#1067)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
hectorcast-db authored Oct 22, 2024
1 parent b47ecac commit dac9a9e
Showing 1 changed file with 19 additions and 30 deletions.
49 changes: 19 additions & 30 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,45 +9,34 @@ on:


jobs:
write-message:
trigger-tests:
if: github.event_name == 'pull_request'
name: Write Message
name: Trigger Tests
runs-on: ubuntu-latest
environment: "test-trigger-is"

steps:
- uses: actions/checkout@v3

- name: Delete old comments
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete previous comment if it exists
previous_comment_ids=$(gh api "repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id')
echo "Previous comment IDs: $previous_comment_ids"
# Iterate over each comment ID and delete the comment
if [ ! -z "$previous_comment_ids" ]; then
echo "$previous_comment_ids" | while read -r comment_id; do
echo "Deleting comment with ID: $comment_id"
gh api "repos/${{ github.repository }}/issues/comments/$comment_id" -X DELETE
done
fi
- name: Write new comment
- name: Generate GitHub App Token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}
private-key: ${{ secrets.DECO_WORKFLOW_TRIGGER_PRIVATE_KEY }}
owner: ${{ secrets.ORG_NAME }}
repositories: ${{secrets.REPO_NAME}}

- name: Trigger Workflow in Another Repo
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body \
"<!-- INTEGRATION_TESTS -->
Run integration tests using the corresponding workflow:
Inputs:
PR Number:${{github.event.pull_request.number}}
Commit SHA:${{ github.event.pull_request.head.sha }}
This check will be approved automatically on success.
"
gh workflow run sdk-go-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
--ref main \
-f pull_request_number=${{ github.event.pull_request.number }} \
-f commit_sha=${{ github.event.pull_request.head.sha }}
# The hash for the merge queue may not be the same as the hash for the PR.
# Auto approve the check for the merge queue to avoid running integration tests twice.
auto-approve:
Expand Down

0 comments on commit dac9a9e

Please sign in to comment.