Skip to content

Commit bd96785

Browse files
committed
migrate to Checks API for integration tests
1 parent ad941ec commit bd96785

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

.github/workflows/integration-tests.yml

Lines changed: 50 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ jobs:
2020
outputs:
2121
has_token: ${{ steps.set-token-status.outputs.has_token }}
2222
steps:
23-
- name: Check if DECO_WORKFLOW_TRIGGER_APP_ID is set
23+
- name: Check if required secrets are set
2424
id: set-token-status
2525
run: |
26-
if [ -z "${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}" ]; then
27-
echo "DECO_WORKFLOW_TRIGGER_APP_ID is empty. User has no access to secrets."
26+
if [ -z "${{ secrets.DECO_WORKFLOW_TRIGGER_APP_ID }}" ] || [ -z "${{ secrets.DECO_TEST_APPROVAL_APP_ID }}" ]; then
27+
echo "Required secrets are missing. User has no access to secrets."
2828
echo "::set-output name=has_token::false"
2929
else
30-
echo "DECO_WORKFLOW_TRIGGER_APP_ID is set. User has access to secrets."
30+
echo "All required secrets are set. User has access to secrets."
3131
echo "::set-output name=has_token::true"
3232
fi
3333
@@ -45,7 +45,31 @@ jobs:
4545
steps:
4646
- uses: actions/checkout@v3
4747

48-
- name: Generate GitHub App Token
48+
- name: Generate GitHub App Token for Check Updates
49+
id: generate-check-token
50+
uses: actions/create-github-app-token@v1
51+
with:
52+
app-id: ${{ secrets.DECO_TEST_APPROVAL_APP_ID }}
53+
private-key: ${{ secrets.DECO_TEST_APPROVAL_PRIVATE_KEY }}
54+
owner: databricks
55+
56+
- name: Create Check Run
57+
id: create-check
58+
env:
59+
GH_TOKEN: ${{ steps.generate-check-token.outputs.token }}
60+
run: |
61+
response=$(gh api -X POST \
62+
/repos/${{ github.repository }}/check-runs \
63+
-f name="Integration Tests" \
64+
-f head_sha="${{ github.event.pull_request.head.sha }}" \
65+
-f status="queued" \
66+
-f output[title]="Integration Tests" \
67+
-f output[summary]="Tests queued and will be triggered shortly...")
68+
69+
check_run_id=$(echo "$response" | jq -r .id)
70+
echo "check_run_id=$check_run_id" >> $GITHUB_OUTPUT
71+
72+
- name: Generate GitHub App Token for Workflow Trigger
4973
id: generate-token
5074
uses: actions/create-github-app-token@v1
5175
with:
@@ -61,7 +85,8 @@ jobs:
6185
gh workflow run sdk-py-isolated-pr.yml -R ${{ secrets.ORG_NAME }}/${{secrets.REPO_NAME}} \
6286
--ref main \
6387
-f pull_request_number=${{ github.event.pull_request.number }} \
64-
-f commit_sha=${{ github.event.pull_request.head.sha }}
88+
-f commit_sha=${{ github.event.pull_request.head.sha }} \
89+
-f check_run_id=${{ steps.create-check.outputs.check_run_id }}
6590
6691
# Statuses and checks apply to specific commits (by hash).
6792
# Enforcement of required checks is done both at the PR level and the merge queue level.
@@ -77,14 +102,23 @@ jobs:
77102
group: databricks-deco-testing-runner-group
78103
labels: ubuntu-latest-deco
79104

105+
permissions:
106+
checks: write
107+
contents: read
108+
80109
steps:
81-
- name: Mark Check
82-
env:
83-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84-
shell: bash
85-
run: |
86-
gh api -X POST -H "Accept: application/vnd.github+json" \
87-
-H "X-GitHub-Api-Version: 2022-11-28" \
88-
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
89-
-f 'state=success' \
90-
-f 'context=Integration Tests Check'
110+
- name: Auto-approve Check for Merge Queue
111+
uses: actions/github-script@v7
112+
with:
113+
script: |
114+
await github.rest.checks.create({
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
name: 'Integration Tests',
118+
head_sha: context.sha,
119+
status: 'completed',
120+
conclusion: 'success',
121+
output: {
122+
summary: 'Auto-approved for merge queue (tests already passed on PR)'
123+
}
124+
});

0 commit comments

Comments
 (0)