Skip to content

Commit

Permalink
Check approval
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcast-db committed Sep 2, 2024
1 parent 073f831 commit 98df414
Showing 1 changed file with 110 additions and 0 deletions.
110 changes: 110 additions & 0 deletions .github/workflows/check-mark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: Mark Check Status

on:
workflow_dispatch:
inputs:
pull_request_number:
description: "Pull request number to test (if empty, tests run against main)"
required: true

test_run_id:
description: "Run ID for the integration tests run"
required: true

status:
description: "Integration test run status"
required: true

check_run_id:
description: "Run ID for the check run"
required: true


env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:

mark-as-running:
runs-on: linux-ubuntu-latest
if: ${{ github.event.inputs.status != 'running' }}
steps:
- name: Acknowledge Request
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'status=in_progress' \
-f output[title]="Integration Tests Check" \
-f output[summary]="Running." \
-f output[text]="Tests running:
Details https://github.com/databricks-eng/eng-dev-ecosystem/actions/runs/${{inputs.test_run_id}}" \
/repos/${{github.repository}}/check-runs/${{ inputs.check_run_id }}
mark-as-done:
if: ${{ github.event.inputs.check_run_id != 'completed' }}
runs-on: linux-ubuntu-latest
steps:
- name: Acknowledge Request
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/check-runs/${{ inputs.check_run_id }} \
--input - <<- EOF
{
"conclusion": "success",
"details_url": "https://github.com/databricks-eng/eng-dev-ecosystem/actions/runs/${{inputs.test_run_id}}",
"output": {
"title": "Integration Tests Succeed 🚀",
"summary": "**Summary**: The tests succeded.",
"text": "Details https://github.com/databricks-eng/eng-dev-ecosystem/actions/runs/${{inputs.test_run_id}}"
}
}
EOF
mark-as-failed:
if: ${{ github.event.inputs.check_run_id != 'failed' }}
runs-on: linux-ubuntu-latest
steps:
- name: Acknowledge Request
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/databricks/databricks-sdk-go/check-runs/${{ inputs.check_run_id }} \
--input - <<- EOF
{
"conclusion": "failure",
"details_url": "https://github.com/${{ github.repository }}/actions/runs/${{inputs.test_run_id}}",
"output": {
"title": "Integration Tests Failed",
"summary": "**Summary**: The tests failed.",
"text": "Details https://github.com/${{ github.repository }}/actions/runs/${{inputs.test_run_id}}"
}
}
EOF
pr-comment:
runs-on: linux ubuntu-latest
steps:
- 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/${{ inputs.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 ${{ inputs.pull_request_number }} --body \
"<!-- INTEGRATION_TESTS -->
Test status: ${{ github.event.inputs.status}}
Workflow: https://github.com/databricks-eng/eng-dev-ecosystem/actions/workflows/sdk-go-isolated-pr.yml
Check Run ID: ${{ inputs.check_run_id }}
This check will be approved automatically on success.
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ inputs.check_run_id }}
"

0 comments on commit 98df414

Please sign in to comment.