Skip to content

[Internal] Add workflows manage integration tests checks #3

[Internal] Add workflows manage integration tests checks

[Internal] Add workflows manage integration tests checks #3

name: Integration Tests
on:
pull_request:
branches: [ main ]
jobs:
check:
name: Run Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Create Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
check_run_id=$(gh api \
--method POST \
-H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/check-runs \
-f name='Integration Tests' \
-f head_sha=${{ github.sha }} \
-f status='pending' \
-f output='{
"title": "Integration Tests",
"summary": "This check is being created.",
"text": "This check is being created. Refresh for details."
}' | jq -r '.id')
# Adding instructions to the check details.
gh api \
--method PATCH \
-H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/check-runs/$check_run_id \
-f output='{
"title": "Integration Tests",
"summary": "This check is waiting for approval.",
"text": "Run the following workflow using the provided check_run_id: \n\n Workflow https://github.com/databricks-eng/eng-dev-ecosystem/actions/workflows/sdk-go-isolated-pr.yml \n\n Check Run ID: '"$check_run_id"'"
}'
echo "CHECK_RUN_ID=$check_run_id" >> $GITHUB_ENV
- name: Write PR Comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Delete previous comment if it exists
previous_comment_id=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
--jq '.[] | select(.body | startswith("<!-- INTEGRATION_TESTS -->")) | .id')
if [ ! -z "$previous_comment_id" ]; then
gh api repos/${{ github.repository }}/issues/comments/$previous_comment_id -X DELETE
fi
# Add new comment
gh pr comment ${{ github.event.pull_request.number }} --body "<!-- INTEGRATION_TESTS -->
A new approval check has been created. Run integration tests by triggering the following workflow
Workflow: https://github.com/databricks-eng/eng-dev-ecosystem/actions/workflows/sdk-go-isolated-pr.yml
Check Run ID: ${{ env.CHECK_RUN_ID }}
This check will be approved automatically on success.
Check URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}."