Skip to content

Commit 6d7f15f

Browse files
ci: add label-gated proxy-test dispatch workflow
Wires this repo into the proxy-based integration test infrastructure in databricks/databricks-driver-test. Mirrors the pattern used by databricks-odbc#55 and the ADBC drivers (C# / Rust). How it works: 1. A maintainer reviews a PR and adds the `integration-test` label. 2. This workflow dispatches a `python-pr-test` event to databricks/databricks-driver-test with the PR number + head SHA. 3. The driver-test repo runs the Python proxy test suite (databricks/databricks-driver-test#329, tests/python/, ~59 tests in Phase 1) at the dispatched commit and posts a check run back to this PR. Security: - Label-gated: only maintainers can apply `integration-test`. - Auto-removed on `synchronize`: pushing new commits clears the label, forcing maintainer re-review before tests re-run. - Merge queue: trusted at that point — dispatches automatically. One-time setup (outside this PR): create the `integration-test` label in this repo. Co-authored-by: Isaac Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>
1 parent 0c10d7b commit 6d7f15f

1 file changed

Lines changed: 157 additions & 0 deletions

File tree

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
name: Trigger Integration Tests
2+
3+
# Dispatches the proxy-based integration test suite in
4+
# databricks/databricks-driver-test to run against this PR's commit.
5+
#
6+
# Mirrors the pattern used by databricks-odbc (see
7+
# databricks/databricks-odbc#55) and the ADBC drivers' C#/Rust setups.
8+
# Label-gated for security: only maintainers can trigger by adding
9+
# the `integration-test` label. New commits auto-remove the label
10+
# so re-review is required before tests run again.
11+
12+
on:
13+
pull_request:
14+
types: [labeled, synchronize]
15+
merge_group:
16+
17+
jobs:
18+
# -------------------------------------------------------------------
19+
# Security: Auto-remove label when new commits are pushed.
20+
# Forces a maintainer re-review before the next test run.
21+
# -------------------------------------------------------------------
22+
remove-label-on-new-commit:
23+
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
24+
runs-on:
25+
group: databricks-protected-runner-group
26+
labels: linux-ubuntu-latest
27+
permissions:
28+
pull-requests: write
29+
issues: write
30+
steps:
31+
- name: Check if integration-test label exists
32+
id: check-label
33+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
34+
with:
35+
script: |
36+
const labels = context.payload.pull_request.labels.map(l => l.name);
37+
const hasLabel = labels.includes('integration-test');
38+
return hasLabel;
39+
40+
- name: Remove integration-test label
41+
if: steps.check-label.outputs.result == 'true'
42+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
43+
with:
44+
script: |
45+
try {
46+
await github.rest.issues.removeLabel({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
issue_number: context.issue.number,
50+
name: 'integration-test'
51+
});
52+
} catch (error) {
53+
if (error.status !== 404) throw error;
54+
}
55+
56+
- name: Comment on PR about label removal
57+
if: steps.check-label.outputs.result == 'true'
58+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
59+
with:
60+
script: |
61+
const pr = context.payload.pull_request;
62+
const isFromFork = pr.head.repo.full_name !== pr.base.repo.full_name;
63+
const repoType = isFromFork ? '**fork PR**' : 'PR';
64+
65+
await github.rest.issues.createComment({
66+
owner: context.repo.owner,
67+
repo: context.repo.repo,
68+
issue_number: context.issue.number,
69+
body: `Integration test approval reset.
70+
71+
New commits were pushed to this ${repoType}. The \`integration-test\` label has been automatically removed for security.
72+
73+
**A maintainer must re-review the changes and re-add the label to trigger tests again.**
74+
75+
**Latest commit**: ${pr.head.sha.substring(0, 7)}`
76+
});
77+
78+
# -------------------------------------------------------------------
79+
# Trigger tests when label is added by a maintainer.
80+
# -------------------------------------------------------------------
81+
trigger-tests-pr:
82+
if: |
83+
github.event_name == 'pull_request' &&
84+
github.event.action == 'labeled' &&
85+
contains(github.event.pull_request.labels.*.name, 'integration-test')
86+
runs-on:
87+
group: databricks-protected-runner-group
88+
labels: linux-ubuntu-latest
89+
permissions:
90+
issues: write
91+
pull-requests: write
92+
steps:
93+
- name: Generate GitHub App Token
94+
id: app-token
95+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
96+
with:
97+
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
98+
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
99+
owner: databricks
100+
repositories: databricks-driver-test
101+
102+
- name: Dispatch tests to internal repo
103+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
104+
with:
105+
token: ${{ steps.app-token.outputs.token }}
106+
repository: databricks/databricks-driver-test
107+
event-type: python-pr-test
108+
client-payload: |
109+
{
110+
"pr_number": "${{ github.event.pull_request.number }}",
111+
"commit_sha": "${{ github.event.pull_request.head.sha }}",
112+
"pr_repo": "${{ github.repository }}",
113+
"pr_url": "${{ github.event.pull_request.html_url }}",
114+
"pr_title": "${{ github.event.pull_request.title }}",
115+
"pr_author": "${{ github.event.pull_request.user.login }}"
116+
}
117+
118+
- name: Comment on PR
119+
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7.1.0
120+
with:
121+
script: |
122+
await github.rest.issues.createComment({
123+
owner: context.repo.owner,
124+
repo: context.repo.repo,
125+
issue_number: context.issue.number,
126+
body: 'Integration tests triggered! [View workflow run](https://github.com/databricks/databricks-driver-test/actions/workflows/python-proxy-tests.yml)'
127+
});
128+
129+
# -------------------------------------------------------------------
130+
# Trigger tests from merge queue (trusted at this point).
131+
# -------------------------------------------------------------------
132+
trigger-tests-merge-queue:
133+
if: github.event_name == 'merge_group'
134+
runs-on:
135+
group: databricks-protected-runner-group
136+
labels: linux-ubuntu-latest
137+
steps:
138+
- name: Generate GitHub App Token
139+
id: app-token
140+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
141+
with:
142+
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
143+
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
144+
owner: databricks
145+
repositories: databricks-driver-test
146+
147+
- name: Dispatch tests to internal repo
148+
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
149+
with:
150+
token: ${{ steps.app-token.outputs.token }}
151+
repository: databricks/databricks-driver-test
152+
event-type: python-pr-test
153+
client-payload: |
154+
{
155+
"commit_sha": "${{ github.event.merge_group.head_sha }}",
156+
"pr_repo": "${{ github.repository }}"
157+
}

0 commit comments

Comments
 (0)