Repository navigation
654 lines (627 loc) · 32.6 KB
/
Copy pathtrigger-integration-tests.yml
File metadata and controls
654 lines (627 loc) · 32.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
# Copyright (c) 2026 Databricks, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Cross-repo integration-test trigger.
#
# This workflow does not run the tests. Tests live in
# databricks/databricks-driver-test (the internal repo) and run against
# the workspace credentials + mitmproxy infrastructure that lives there.
# This workflow only fires a repository_dispatch event into that repo
# and reports the result back as the "Kernel Integration Tests" check
# on the kernel PR.
#
# Modeled on adbc-drivers/databricks's `trigger-integration-tests.yml`
# (the C# ADBC equivalent). Differences:
# - Single language (Rust) — no per-language path-filter fan-out.
# - Source paths are kernel-relative: src/**, adbc/**, napi/**, pyo3/**,
# Cargo.{toml,lock}, .github/workflows/**.
# - Dispatched event-type is `kernel-pr-test`.
# - Check-run name is "Kernel Integration Tests" — must match the
# name created by databricks-sql-kernel-integration-tests.yml in
# the internal repo, and must match what branch-protection lists
# as the required status check.
#
# Security model is identical to the C# version: only maintainers can
# add the `integration-test` label; the label is auto-removed on new
# commits so each push gets re-reviewed before tests run against the
# internal workspace.
#
# ------------------------------------------------------------------
# GitHub App permissions — TWO-SIDED requirement
# ------------------------------------------------------------------
# The integration-test GitHub App (whose ID + private key live in
# `INTEGRATION_TEST_APP_ID` / `INTEGRATION_TEST_PRIVATE_KEY` repo
# secrets) MUST be installed on BOTH repositories with the
# permissions enumerated below. Misconfiguration on either side
# produces silent failure modes that are hard to spot in CI.
#
# 1. databricks/databricks-driver-test (the receiver)
# - Contents: write → required for `repository_dispatch`
# (this workflow narrows the minted token to
# `permission-contents: write` defence-in-depth).
# A missing or read-only install here makes
# `peter-evans/repository-dispatch` fail with 403. The
# label-trigger path's `if: failure()` posts a failing check;
# the merge-queue path's `if: failure()` does the same.
#
# 2. databricks/databricks-sql-kernel (this repo, the reporter)
# - Checks: write → required so the RECEIVER (running inside
# `databricks-driver-test`) can `POST /repos/databricks/
# databricks-sql-kernel/check-runs` to report back the
# Kernel Integration Tests result.
# A missing install here means the dispatch succeeds, the
# receiver runs the tests, then 403s when posting the check
# back — so the required `Kernel Integration Tests` check is
# never created and branch protection blocks merge (fail-closed),
# but operators have to know to investigate the App install, not
# the test result. The receiver is the SOLE poster of that check
# (this workflow posts no placeholder — see the notes on the
# dispatch jobs below).
#
# The receiver-side timeout must be ≥ the longest realistic test
# run + reasonable slack, and the merge-queue branch-protection
# "Require status checks to pass" timeout must be ≥ that.
# Otherwise the merge queue cancels the merge while tests are
# still legitimately running.
name: Trigger Integration Tests
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
merge_group:
# Concurrency model:
# - Dispatch-side jobs (`skip-integration-tests-pr`,
# `trigger-tests-pr`, `merge-queue-kernel`) coalesce per PR / merge
# group / branch so push-spam and label cycles don't burn through
# the GitHub App rate limit. `cancel-in-progress: true` lets a
# newer push supersede a stale dispatch.
# - The label-cleanup job (`remove-label-on-new-commit`) runs in its
# own group with `cancel-in-progress: false` — cancelling
# mid-flight could leave the label attached after a push, which
# would defeat the "re-review on each push" security contract.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.merge_group.head_sha || github.ref }}
cancel-in-progress: true
jobs:
# =============================================================================
# Security: auto-remove `integration-test` label on new commits so each
# push to a PR gets re-reviewed before tests run against the internal
# workspace.
# =============================================================================
remove-label-on-new-commit:
name: Reset integration-test label on push
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
# Own concurrency group with `cancel-in-progress: false` — see the
# workflow-level comment above. The label-cleanup is a
# security-critical action; it MUST run to completion on every
# push regardless of how quickly subsequent pushes arrive.
concurrency:
group: ${{ github.workflow }}-label-cleanup-${{ github.event.pull_request.number }}
cancel-in-progress: false
# Use the protected runner group — App private-key material is
# the crown jewel of this workflow surface; per the
# hardened-GHA convention every sibling workflow already uses it.
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Check if integration-test label exists
id: check-label
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const labels = context.payload.pull_request.labels.map(l => l.name);
const hasLabel = labels.includes('integration-test');
console.log(`integration-test label exists: ${hasLabel}`);
return hasLabel;
- name: Remove integration-test label
if: steps.check-label.outputs.result == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
try {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'integration-test'
});
console.log('Removed integration-test label');
} catch (error) {
if (error.status === 404) {
console.log('Label already removed or does not exist');
} else {
throw error;
}
}
- name: Comment on PR about label removal
if: steps.check-label.outputs.result == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const pr = context.payload.pull_request;
const isFromFork = pr.head.repo.full_name !== pr.base.repo.full_name;
const repoType = isFromFork ? '**fork PR**' : 'PR';
const body = [
'Integration test approval reset',
'',
`New commits were pushed to this ${repoType}. The \`integration-test\` label has been automatically removed for security.`,
'',
'**A maintainer must re-review the changes and re-add the label to trigger tests again.**',
'',
`**Latest commit**: ${pr.head.sha.substring(0, 7)}`
].join('\n');
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
# =============================================================================
# On non-label PR events, auto-pass the "Kernel Integration Tests" check
# so it doesn't block merging. The real run happens in the merge queue
# (or earlier, when a maintainer adds the label).
# =============================================================================
# CRITICAL: the required `Kernel Integration Tests` check is pinned in the main
# ruleset to the driver-test app's integration id (driver-integration-test).
# A `github.token` (github-actions) check of the same name is a DIFFERENT check
# context and does NOT satisfy the pinned gate — so it must be posted AS that
# app, or the required check sits "waiting for status" and PRs stay blocked.
#
# Internal PRs post the placeholder HERE (self-guarded to head repo == base
# repo): they can mint the app token inline, and posting here means it works
# from the PR branch immediately. FORK PRs are handled by the companion
# `skip-checks-reporter.yml` (workflow_run) — a fork's pull_request run has a
# read-only token and no secrets, so it can neither mint the app token nor post
# any check inline. The two guards are mutually exclusive (no double-post).
skip-integration-tests-pr:
name: Integration tests (auto-pass on PR)
if: |
github.event_name == 'pull_request' &&
github.event.action != 'labeled' &&
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
# The check is posted with the App token (see below), so GITHUB_TOKEN needs
# no scopes. Pin an explicit empty block for least-privilege rather than
# inheriting the repo/org default permission set.
permissions: {}
steps:
- name: Generate GitHub App token (this repo)
id: app-token
uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: databricks
repositories: databricks-sql-kernel
- name: Skip Kernel Integration Tests
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Kernel Integration Tests',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
output: {
title: 'Skipped on PR - runs in merge queue',
summary: 'Integration tests are skipped on PRs and run as a required gate in the merge queue. A maintainer can run them earlier by adding the `integration-test` label.'
}
});
# =============================================================================
# Label-triggered dispatch: maintainer added `integration-test` -> fire
# tests in the internal repo for this PR's head SHA.
# =============================================================================
# =============================================================================
# Rollout-window visibility: if a maintainer adds the
# `integration-test` label while `INTEGRATION_TESTS_ENABLED` is
# still off, `trigger-tests-pr` is gated off — without this
# mini-job the labeling would silently produce zero workflow
# jobs and the maintainer would assume the gate ran. Post a
# sticky comment to make the no-op visible.
# =============================================================================
label-noop-during-rollout:
name: Integration-test label (rollout no-op notice)
if: |
github.event_name == 'pull_request' &&
github.event.action == 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'integration-test') &&
vars.INTEGRATION_TESTS_ENABLED != 'true'
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Sticky comment about rollout gate
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
# Distinct marker from the dispatch-side comment so the
# two stickies coexist without colliding.
body-includes: '<!-- kernel-integration-tests-rollout-noop -->'
edit-mode: replace
body: |
<!-- kernel-integration-tests-rollout-noop -->
**Integration-test label is a no-op right now.**
The `INTEGRATION_TESTS_ENABLED` repo variable is not set, which is the pre-rollout state: the receiving workflow in `databricks-driver-test` (PR #375) has not yet shipped. Labelling does not dispatch tests until that variable is flipped on.
Once the variable is set, re-add the label (or push) to trigger a real run.
trigger-tests-pr:
name: Dispatch integration tests (labeled PR)
# Companion-PR ordering gate: only fire dispatches once the
# internal repo's receiving workflow (databricks-driver-test#375
# — see the PR description) has landed. Until then,
# `vars.INTEGRATION_TESTS_ENABLED` is unset / not `"true"` and
# the dispatch becomes a no-op. This way labeling a PR before
# the companion ships doesn't fire into the void / produce a
# broken workflow-run link, and branch protection — if enabled
# prematurely — won't strand merges. Flip the variable on after
# the companion merges. The `label-noop-during-rollout` job
# above surfaces the gate-off state as a sticky PR comment so
# maintainers don't think the label silently dispatched.
if: |
github.event_name == 'pull_request' &&
github.event.action == 'labeled' &&
contains(github.event.pull_request.labels.*.name, 'integration-test') &&
vars.INTEGRATION_TESTS_ENABLED == 'true'
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
permissions:
# `checks: write` is intentionally NOT granted here: the only
# `checks.create` call in this job (the `if: failure()` handler
# below) posts under the app token, since the required
# `Kernel Integration Tests` check is app-pinned. issues /
# pull-requests:write remain for the sticky-comment step.
issues: write
pull-requests: write
steps:
- name: Generate GitHub App Token (internal repo)
id: app-token
uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: databricks
# create-github-app-token mints ONE installation token whose permission
# set applies to EVERY listed repo — it cannot scope a permission to a
# single repo, so we request the union needed across both:
# - contents:write drives repository_dispatch into databricks-driver-test;
# - checks:write lets the failure handler below post the required
# `Kernel Integration Tests` check on databricks-sql-kernel — it must
# be this app, since that check is app-pinned in the ruleset.
# The effective grant on each repo is still bounded by what the app is
# actually installed with there.
repositories: |
databricks-driver-test
databricks-sql-kernel
permission-contents: write
permission-checks: write
# NOTE: no kernel-side `in_progress` placeholder is posted here.
# The receiver (databricks-sql-kernel-integration-tests.yml in
# databricks-driver-test) is the SOLE creator of the real
# "Kernel Integration Tests" check, posting in_progress ->
# completed under the integration-test GitHub App. The required check is
# PINNED to that app's integration_id in the ruleset, so only a check
# posted by it satisfies the gate — a `github.token` (github-actions)
# placeholder is a different context that would neither satisfy the gate
# nor be updatable by the receiver's App, orphaning as a permanent
# in_progress and hanging the queue. Fail-closed on a silent dispatch drop
# is preserved by the `if: failure()` step below (now posted as the app so
# it actually fails the pinned check) plus branch protection treating a
# missing required check as blocking.
- name: Build payload (PR-title-safe via JSON.stringify)
id: payload
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
env:
PR_REPO: ${{ github.repository }}
with:
# `JSON.stringify` on every interpolated string eliminates
# the PR-title-injection class entirely — no regex
# filtering against U+0000-001F control codes (U+000B,
# U+000C, U+0008, etc.) needed, and no risk that a
# crafted title closes the outer JSON literal.
script: |
const pr = context.payload.pull_request;
const title = (pr.title || '').substring(0, 200);
const payload = {
pr_number: String(pr.number),
commit_sha: pr.head.sha,
pr_repo: process.env.PR_REPO,
pr_url: pr.html_url,
pr_title: title,
pr_author: pr.user.login,
// REPLAY-only PR gate: serve committed recordings against the driver
// built at this commit — deterministic, credential-free, no live
// Dogfood. Overrides the receiver's passthrough default so a PR is
// never gated on a slow/fragile live run.
proxy_mode: 'replay',
};
core.setOutput('json', JSON.stringify(payload));
- name: Dispatch kernel tests to internal repo
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
with:
token: ${{ steps.app-token.outputs.token }}
repository: databricks/databricks-driver-test
event-type: kernel-pr-test
client-payload: ${{ steps.payload.outputs.json }}
- name: Comment on PR (sticky)
uses: peter-evans/create-or-update-comment@e8674b075228eee787fea43ef493e45ece1004c9 # v5.0.0
with:
issue-number: ${{ github.event.pull_request.number }}
# Body is a single sticky comment edited in place — avoids
# the comment-spam that fires every label-toggle / push
# cycle when each event creates a fresh comment.
#
# The "View status" link points at the Kernel Integration
# Tests check on this PR's head SHA. The receiver creates
# that check (in_progress -> completed) under the
# integration-test App and supplies its own `details_url`
# (the actual workflow run on `databricks-driver-test`).
# Linking to the check directly — rather than the receiver
# workflow's run-list — means the comment doesn't go stale
# across re-runs.
body: |
<!-- kernel-integration-tests-comment -->
Kernel integration tests triggered. [View status](https://github.com/${{ github.repository }}/pull/${{ github.event.pull_request.number }}/checks?check_name=Kernel+Integration+Tests). Results post back here as the "Kernel Integration Tests" check.
# `edit-mode: replace` so each new dispatch overwrites the
# previous status rather than appending — the comment
# tracks the latest run only.
edit-mode: replace
# Match by the HTML comment marker above so the sticky
# comment survives across pushes / label re-adds.
body-includes: '<!-- kernel-integration-tests-comment -->'
# Parity with the merge-queue path's "Fail check on dispatch
# error" step. Without this, a dispatch failure on the
# label-trigger path would leave the PR with no Kernel
# Integration Tests check at all (since this is the path that
# creates it for the labeled-PR scenario).
- name: Fail check on dispatch error
if: failure()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
# App token — the required check is app-pinned, so a github.token
# failure check lands on a different context and wouldn't fail the gate.
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Kernel Integration Tests',
head_sha: context.payload.pull_request.head.sha,
status: 'completed',
conclusion: 'failure',
completed_at: new Date().toISOString(),
output: {
title: 'Failed - error dispatching tests',
summary: 'An error occurred while dispatching kernel integration tests from the label-trigger path. Check the workflow run logs.'
}
});
# =============================================================================
# Merge-queue gate: tests are a required status check before merge. If
# nothing under the kernel-source path filter changed, auto-pass.
# Otherwise dispatch and let the internal repo report the result.
# =============================================================================
merge-queue-kernel:
name: Dispatch integration tests (merge queue)
if: github.event_name == 'merge_group'
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
permissions:
# `contents: read` is REQUIRED: this job checks out the repo to
# diff the merge group. Declaring any `permissions:` block sets
# every unlisted scope to `none`, so without this line
# actions/checkout gets a token that can't read the repo and
# fails with "Repository not found" (exit 128) — which only
# surfaces in the merge queue, the one path that checks out code.
#
# `checks: write` is intentionally NOT granted: all three
# `checks.create` calls in this job (auto-pass, companion-not-
# enabled, dispatch-failure) post under the app token, since the
# required `Kernel Integration Tests` check is app-pinned.
contents: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
# Mint the driver-test App token UNCONDITIONALLY and early. The required
# `Kernel Integration Tests` check is pinned to this app's integration id,
# so EVERY check this job posts (auto-pass, dispatch-failure) must be
# attributed to it — a github.token check lands on a different context and
# never satisfies the pinned gate, hanging the queue. create-github-app-token
# mints ONE installation token whose permission set applies to EVERY listed
# repo; it cannot scope a permission to a single repo. We therefore request
# the union of what's needed across both: checks:write to post the
# `Kernel Integration Tests` check on databricks-sql-kernel, and
# contents:write to repository_dispatch into databricks-driver-test. The
# effective grant on each repo is still bounded by what the app is actually
# installed with there. merge_group runs on the base repo with full secret
# access.
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@d72941d797fd3113feb6b93fd0dec494b13a2547 # v1.12.0
with:
app-id: ${{ secrets.INTEGRATION_TEST_APP_ID }}
private-key: ${{ secrets.INTEGRATION_TEST_PRIVATE_KEY }}
owner: databricks
repositories: |
databricks-sql-kernel
databricks-driver-test
permission-checks: write
permission-contents: write
- name: Check if kernel source files changed
id: changed
run: |
CHANGED=$(git diff --name-only \
"${{ github.event.merge_group.base_sha }}" \
"${{ github.event.merge_group.head_sha }}")
# Edge case: a merge-group event where `base_sha ==
# head_sha` (or the diff is genuinely empty) yields a
# blank `$CHANGED`. The `grep -qE` below would then
# return non-zero ("no match"), which we'd interpret as
# auto-pass — semantically correct, but worth being
# explicit so a future reader doesn't have to reason
# about empty-string grep semantics.
if [[ -z "$CHANGED" ]]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "no files changed in merge group (base_sha == head_sha?)"
exit 0
fi
# Path set mirrors the in-repo rust-e2e.yml's source filter
# (src/**, tests/**, Cargo.toml, Cargo.lock, workflow files)
# plus adbc/, napi/, and pyo3/ wrappers. `tests/` is included because a
# test-only change can still break kernel-protocol invariants
# that integration tests catch.
if echo "$CHANGED" | grep -qE "^(src/|tests/|adbc/|napi/|pyo3/|Cargo\.toml|Cargo\.lock|\.github/workflows/)"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "kernel source files changed"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "no kernel source files changed"
fi
- name: Auto-pass (no kernel source changes)
if: steps.changed.outputs.changed != 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
# App token — the pinned required check is only satisfied by a check
# posted BY the driver-test app.
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Kernel Integration Tests',
head_sha: '${{ github.event.merge_group.head_sha }}',
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
output: {
title: 'Skipped - no kernel source changes',
summary: 'No kernel source files changed in this merge group.'
}
});
# Companion-PR ordering gate (mirror of the label-trigger
# path). Until `vars.INTEGRATION_TESTS_ENABLED` is `"true"`
# — flipped on after databricks-driver-test#375 lands —
# auto-pass the required check so branch protection doesn't
# strand merges. The variable is unset by default, so this
# PR can land before the companion without breaking the
# merge queue.
- name: Auto-pass (companion workflow not yet enabled)
if: steps.changed.outputs.changed == 'true' && vars.INTEGRATION_TESTS_ENABLED != 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
# App token — pinned required check (see the early mint step).
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Kernel Integration Tests',
head_sha: '${{ github.event.merge_group.head_sha }}',
status: 'completed',
conclusion: 'success',
completed_at: new Date().toISOString(),
output: {
title: 'Skipped - integration-test workflow not yet enabled',
summary: 'The `INTEGRATION_TESTS_ENABLED` repo variable is not set. This is the pre-rollout state: the companion workflow in databricks-driver-test has not yet shipped. Auto-passing so branch protection does not strand merges.'
}
});
- name: Extract PR number
if: steps.changed.outputs.changed == 'true' && vars.INTEGRATION_TESTS_ENABLED == 'true'
id: extract-pr
run: |
REF="${{ github.event.merge_group.head_ref }}"
# Fully anchor to GitHub's documented merge-queue head_ref
# shape: `refs/heads/gh-readonly-queue/<base>/pr-<N>-<sha>`.
# `<base>` can contain slashes (`release/v1`, `feature/foo`,
# etc.); a stricter `[^/]+` would reject slashed bases and
# the step would `exit 1`, taking the `if: failure()` path
# — bricking the merge queue for those PRs once it's
# enabled. Greedy `.+` plus the strict `/pr-N-hex$` tail
# is unambiguous: the final `/pr-N-<sha>$` anchor pins
# the PR-number capture to the right segment regardless of
# how many slashes the base contains. Today the kernel
# only merges into `main` so this is latent, but cheap to
# fix now.
# The trailing `[0-9a-f]+` matches GitHub's hex commit SHA
# suffix; tolerating any length covers both short and
# full-length forms.
if [[ $REF =~ ^refs/heads/gh-readonly-queue/(.+)/pr-([0-9]+)-[0-9a-f]+$ ]]; then
echo "pr_number=${BASH_REMATCH[2]}" >> "$GITHUB_OUTPUT"
else
echo "Error: merge-group ref does not match the documented gh-readonly-queue shape: '$REF'" >&2
exit 1
fi
# NOTE: no kernel-side `in_progress` placeholder here either —
# see the matching note on the label-trigger path above. The
# receiver owns the real "Kernel Integration Tests" check; a
# placeholder posted under the github-actions app would orphan
# (the receiver's App can't update another app's check-run) and
# hang the queue past `check_response_timeout_minutes`. This was
# the actual cause of the first queued PR stalling. The
# `if: failure()` step below still fails the check closed on a
# dispatch error.
- name: Dispatch kernel tests
if: steps.changed.outputs.changed == 'true' && vars.INTEGRATION_TESTS_ENABLED == 'true'
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
with:
token: ${{ steps.app-token.outputs.token }}
repository: databricks/databricks-driver-test
event-type: kernel-pr-test
client-payload: |
{
"pr_number": "${{ steps.extract-pr.outputs.pr_number }}",
"commit_sha": "${{ github.event.merge_group.head_sha }}",
"pr_repo": "${{ github.repository }}",
"pr_url": "https://github.com/${{ github.repository }}/pull/${{ steps.extract-pr.outputs.pr_number }}",
"pr_title": "Merge queue validation",
"pr_author": "merge-queue",
"proxy_mode": "replay"
}
- name: Fail check on dispatch error
if: failure() && steps.changed.outputs.changed == 'true' && vars.INTEGRATION_TESTS_ENABLED == 'true'
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
# App token — a github.token failure check lands on a different context
# than the pinned gate, so it would neither fail nor satisfy it (queue
# hangs). Posting as the app fails the required check fast. If the mint
# itself failed this step can't run, but that case is fail-closed: the
# queue's check_response_timeout evicts an entry whose required check
# never reports.
github-token: ${{ steps.app-token.outputs.token }}
script: |
await github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Kernel Integration Tests',
head_sha: '${{ github.event.merge_group.head_sha }}',
status: 'completed',
conclusion: 'failure',
completed_at: new Date().toISOString(),
output: {
title: 'Failed - error dispatching tests',
summary: 'An error occurred while dispatching kernel integration tests. Check the workflow run logs.'
}
});