Repository navigation
120 lines (113 loc) · 5.88 KB
/
Copy pathtrigger-coverage-fanout.yml
File metadata and controls
120 lines (113 loc) · 5.88 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
# 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.
# After merge: trigger the multi-language coverage fan-out.
#
# Fires when a PR lands on main (merge queue or direct merge) and touched
# driver source. Dispatches `coverage-fanout` to databricks-driver-test, whose
# coverage-fanout-tracker.yml opens a tracking issue and runs the
# language-agnostic fan-out (a spec authored from THIS PR's diff, conformed as
# tests across every driver) as peco-engineer-bot.
#
# ------------------------------------------------------------------
# Why this lives in its OWN workflow file (not trigger-integration-tests.yml)
# ------------------------------------------------------------------
# This dispatch is fire-and-forget: no check is posted and there is no
# `if: failure()` fallback, so a cancellation silently drops the coverage
# fan-out. trigger-integration-tests.yml carries a workflow-level
# concurrency group keyed on PR number with `cancel-in-progress: true`.
# Workflow-level and job-level concurrency operate independently: a
# job-level group CANNOT exempt a job from a workflow-run-level
# cancellation. So while this job lived in that workflow, a stray
# post-merge `pull_request` event on the same PR number — e.g. a bot
# label action landing during the token-mint + dispatch window (`labeled`
# is in that workflow's trigger `types`) — would start a new run in the
# shared PR-number group and cancel the entire prior run, including this
# dispatch. Isolating it in its own workflow file removes it from that
# shared group entirely; its own concurrency group below (keyed on the
# merge commit, `cancel-in-progress: false`) then lets the dispatch always
# run to completion.
#
# ------------------------------------------------------------------
# Fork-merge assumption (why the fire-and-forget dispatch is safe here)
# ------------------------------------------------------------------
# This workflow assumes all merges into `main` originate from INTERNAL
# branches, never from forks. That assumption matters because the
# `pull_request` event withholds repository secrets from runs triggered by
# fork PRs (only a read-only `GITHUB_TOKEN` is passed). If a fork PR were
# merged while touching `src/`, `secrets.INTEGRATION_TEST_APP_ID` /
# `INTEGRATION_TEST_PRIVATE_KEY` would be empty, the token-mint step would
# fail, and — since the dispatch is fire-and-forget (no check, no
# `if: failure()`) — the coverage fan-out would be silently dropped. The
# kernel takes contributions on internal branches only, so this path is not
# exercised; the sibling adbc flow relies on the same internal-branch-only
# assumption. Revisit this if external/fork contributions are ever accepted.
name: Trigger Coverage Fanout
on:
pull_request:
types: [closed]
# Own concurrency group keyed on the merge commit with
# `cancel-in-progress: false` so the fire-and-forget dispatch always runs
# to completion. Because this is a standalone workflow, there is no shared
# workflow-level group that a stray same-PR-number event could cancel.
concurrency:
group: coverage-fanout-${{ github.event.pull_request.merge_commit_sha || github.event.pull_request.number }}
cancel-in-progress: false
jobs:
trigger-coverage-fanout:
if: |
github.event.action == 'closed' &&
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main'
runs-on:
group: databricks-protected-runner-group
labels: linux-ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Check if driver source changed
id: changed
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const files = await github.paginate(github.rest.pulls.listFiles, {
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
});
// The whole repo IS the driver. Count a merge as source-affecting when it changes a file under src/.
// Docs/CI/test-only merges do not warrant a full multi-language fan-out.
const isSource = (f) => f.startsWith('src/');
const srcChanged = files.some((f) => isSource(f.filename));
console.log(`driver source changed: ${srcChanged}`);
core.setOutput('source', srcChanged.toString());
- name: Generate GitHub App token (databricks-driver-test)
if: steps.changed.outputs.source == 'true'
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-driver-test
permission-contents: write
- name: Dispatch coverage-fanout
if: steps.changed.outputs.source == 'true'
uses: peter-evans/repository-dispatch@ff45666b9427631e3450c54a1bcbee4d9ff4d7c0 # v3.0.0
with:
token: ${{ steps.app-token.outputs.token }}
repository: databricks/databricks-driver-test
event-type: coverage-fanout
client-payload: '{"reference_repo": "${{ github.repository }}", "pr_number": "${{ github.event.pull_request.number }}", "pr_url": "${{ github.event.pull_request.html_url }}"}'