Skip to content

Commit

Permalink
[Internal] Use statuses instead of tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hectorcast-db committed Sep 3, 2024
1 parent 02f3e0c commit b9d7273
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 91 deletions.
64 changes: 9 additions & 55 deletions .github/workflows/check-mark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,12 @@ on:
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"
state:
description: "Integration test run state"
required: true

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

Expand All @@ -26,56 +22,16 @@ env:

jobs:

mark-as-running:
mark-check:
runs-on: ubuntu-latest
if: ${{ github.event.inputs.status == 'running' }}
steps:
- name: Acknowledge Request
run: |
gh api -X PATCH -H "Accept: application/vnd.github+json" \
gh api -X POST -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." \
/repos/${{github.repository}}/check-runs/${{ inputs.check_run_id }}
mark-as-done:
if: ${{ github.event.inputs.status == 'completed' }}
runs-on: 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",
"output": {
"title": "Integration Tests Succeed 🚀",
"summary": "**Summary**: The tests succeded."
}
}
EOF
mark-as-failed:
if: ${{ github.event.inputs.status == 'failed' }}
runs-on: 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",
"output": {
"title": "Integration Tests Failed",
"summary": "**Summary**: The tests failed."
}
}
EOF
/repos/databricks/databricks-sdk-go/statuses/${{ inputs.commit_sha }} \
-f 'state=${{inputs.state}}' \
-f 'context=Integration Tests Check'
pr-comment:
runs-on: ubuntu-latest
Expand All @@ -96,9 +52,7 @@ jobs:
# Add new comment
gh pr comment ${{ inputs.pull_request_number }} --body \
"<!-- INTEGRATION_TESTS -->
Test status: ${{ github.event.inputs.status}}
Test status: ${{ github.event.inputs.state}}
This check will be approved automatically on success.
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ inputs.check_run_id }}
"
44 changes: 9 additions & 35 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,54 +13,28 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Create Check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
check_run_id=$(gh api -X POST -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f name='Integration Tests Check' \
-f head_sha=${{ github.sha }} \
-f status='queued' \
-f output[title]="Integration Tests Check" \
-f output[summary]="This check is being created." \
--jq '.id' \
/repos/${{ github.repository }}/check-runs)
# Adding instructions to the check details.
gh api -X PATCH -H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-f 'status=queued' \
-f name='Integration Tests Check' \
-f output[title]="Integration Tests Check" \
-f output[summary]="Waiting for test to run." \
-f output[text]="Run the corresponding workflow using the provided check_run_id:
Check Run ID: $check_run_id " \
/repos/${{ github.repository }}/check-runs/$check_run_id
echo "CHECK_RUN_ID=$check_run_id" >> $GITHUB_ENV
- name: Write PR Comment
- name: Delete old 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 \
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
gh api "repos/${{ github.repository }}/issues/comments/$previous_comment_id" -X DELETE
fi
# Add new comment
- name: Write new comment
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body \
"<!-- INTEGRATION_TESTS -->
Run integration tests using the corresponding workflow:
Inputs:
pull_request_number=${{github.event.pull_request.number}}
check_run_id=${{ env.CHECK_RUN_ID }}
commit_sha=${{ github.event.pull_request.head.sha }}
This check will be approved automatically on success.
Check URL: ${{ github.server_url }}/${{ github.repository }}/runs/${{ env.CHECK_RUN_ID }}
"
1 change: 0 additions & 1 deletion config/auth_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (

func TestErrCannotConfigureAuth(t *testing.T) {
env.CleanupEnvironment(t)

w := databricks.Must(databricks.NewWorkspaceClient())
_, err := w.CurrentUser.Me(context.Background())
assert.True(t, errors.Is(err, config.ErrCannotConfigureAuth))
Expand Down

0 comments on commit b9d7273

Please sign in to comment.