Skip to content

Commit bb8b828

Browse files
authored
Make tests work on hardened runner (#4875)
## Summary - Configure JFrog Artifactory as Go module proxy via OIDC for Linux and Windows runners - Disable `run-local-node` acceptance test (needs npm registry access via JFrog) - Add setup-build-environment to testmask triggers so CI changes test all targets - Switch secondary test jobs (aitools, ssh, pipelines) to use custom runner groups ## Test plan - [x] Verify `make test` passes on Linux, Windows, macOS - [x] Verify `test-exp-aitools`, `test-exp-ssh`, `test-pipelines` are triggered and pass This pull request was AI-assisted by Isaac.
1 parent 7962f39 commit bb8b828

File tree

6 files changed

+95
-24
lines changed

6 files changed

+95
-24
lines changed

.github/actions/setup-build-environment/action.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ runs:
1212
- name: Checkout repository and submodules
1313
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
1414

15+
- name: Setup JFrog CLI with OIDC
16+
if: runner.os != 'macOS'
17+
uses: jfrog/setup-jfrog-cli@279b1f629f43dd5bc658d8361ac4802a7ef8d2d5 # v4.9.1
18+
env:
19+
JF_URL: https://databricks.jfrog.io
20+
with:
21+
oidc-provider-name: github-actions
22+
1523
- name: Create cache identifier
1624
run: echo "${{ inputs.cache-key }}" > cache.txt
1725
shell: bash
@@ -24,6 +32,14 @@ runs:
2432
go.sum
2533
cache.txt
2634
35+
- name: Download Go modules via JFrog
36+
if: runner.os != 'macOS'
37+
shell: bash
38+
run: |
39+
jf goc --repo-resolve=db-golang
40+
jf go mod download
41+
jf go mod download -modfile=tools/go.mod
42+
2743
- name: Setup Python
2844
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
2945
with:

.github/workflows/push.yml

Lines changed: 62 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ jobs:
8080
name: "make test (${{matrix.os.name}}, ${{matrix.deployment}})"
8181
runs-on: ${{ matrix.os.runner }}
8282

83+
permissions:
84+
id-token: write
85+
contents: read
86+
8387
strategy:
8488
fail-fast: false
8589
matrix:
@@ -160,17 +164,31 @@ jobs:
160164

161165
# Only run if the target is in the list of targets from testmask
162166
if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-exp-aitools') }}
163-
name: "make test-exp-aitools"
164-
runs-on: ${{ matrix.os }}
167+
name: "make test-exp-aitools (${{matrix.os.name}})"
168+
runs-on: ${{ matrix.os.runner }}
169+
170+
permissions:
171+
id-token: write
172+
contents: read
165173

166174
strategy:
167175
fail-fast: false
168176
matrix:
169177
os:
170-
- macos-latest
171-
- ubuntu-latest
172-
# The Windows tests are broken; see https://github.com/databricks/cli/pull/4024.
173-
# - windows-latest
178+
- name: linux
179+
runner:
180+
group: databricks-protected-runner-group-large
181+
labels: linux-ubuntu-latest-large
182+
183+
- name: macos
184+
runner:
185+
labels: macos-latest
186+
187+
# The Windows tests are broken; see https://github.com/databricks/cli/pull/4024.
188+
# - name: windows
189+
# runner:
190+
# group: databricks-protected-runner-group-large
191+
# labels: windows-server-latest-large
174192

175193
steps:
176194
- name: Checkout repository and submodules
@@ -192,16 +210,30 @@ jobs:
192210

193211
# Only run if the target is in the list of targets from testmask
194212
if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-exp-ssh') }}
195-
name: "make test-exp-ssh"
196-
runs-on: ${{ matrix.os }}
213+
name: "make test-exp-ssh (${{matrix.os.name}})"
214+
runs-on: ${{ matrix.os.runner }}
215+
216+
permissions:
217+
id-token: write
218+
contents: read
197219

198220
strategy:
199221
fail-fast: false
200222
matrix:
201223
os:
202-
- macos-latest
203-
- ubuntu-latest
204-
- windows-latest
224+
- name: linux
225+
runner:
226+
group: databricks-protected-runner-group-large
227+
labels: linux-ubuntu-latest-large
228+
229+
- name: windows
230+
runner:
231+
group: databricks-protected-runner-group-large
232+
labels: windows-server-latest-large
233+
234+
- name: macos
235+
runner:
236+
labels: macos-latest
205237

206238
steps:
207239
- name: Checkout repository and submodules
@@ -223,16 +255,30 @@ jobs:
223255

224256
# Only run if the target is in the list of targets from testmask
225257
if: ${{ contains(fromJSON(needs.testmask.outputs.targets), 'test-pipelines') }}
226-
name: "make test-pipelines"
227-
runs-on: ${{ matrix.os }}
258+
name: "make test-pipelines (${{matrix.os.name}})"
259+
runs-on: ${{ matrix.os.runner }}
260+
261+
permissions:
262+
id-token: write
263+
contents: read
228264

229265
strategy:
230266
fail-fast: false
231267
matrix:
232268
os:
233-
- macos-latest
234-
- ubuntu-latest
235-
- windows-latest
269+
- name: linux
270+
runner:
271+
group: databricks-protected-runner-group-large
272+
labels: linux-ubuntu-latest-large
273+
274+
- name: windows
275+
runner:
276+
group: databricks-protected-runner-group-large
277+
labels: windows-server-latest-large
278+
279+
- name: macos
280+
runner:
281+
labels: macos-latest
236282

237283
steps:
238284
- name: Checkout repository and submodules

acceptance/cmd/workspace/apps/run-local-node/out.test.toml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

acceptance/cmd/workspace/apps/run-local-node/test.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
Badness = "need to enable NPM registry access"
12
Cloud = false
2-
Local = true
3+
Local = false
34
RecordRequests = false
45
Timeout = '2m'
56
TimeoutWindows = '10m'

tools/testmask/targets.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,34 +11,35 @@ type targetMapping struct {
1111
target string
1212
}
1313

14-
// goTriggerPatterns lists patterns that trigger all Go-dependent targets.
15-
var goTriggerPatterns = []string{
14+
// commonTriggerPatterns lists patterns that trigger all test targets.
15+
var commonTriggerPatterns = []string{
1616
"go.mod",
1717
"go.sum",
18+
".github/actions/setup-build-environment/",
1819
}
1920

2021
var fileTargetMappings = []targetMapping{
2122
{
22-
prefixes: slices.Concat(goTriggerPatterns, []string{
23+
prefixes: slices.Concat(commonTriggerPatterns, []string{
2324
// Specify files that match targets below and should still trigger the "test" target.
2425
}),
2526
target: "test",
2627
},
2728
{
28-
prefixes: slices.Concat(goTriggerPatterns, []string{
29+
prefixes: slices.Concat(commonTriggerPatterns, []string{
2930
"experimental/aitools/",
3031
}),
3132
target: "test-exp-aitools",
3233
},
3334
{
34-
prefixes: slices.Concat(goTriggerPatterns, []string{
35+
prefixes: slices.Concat(commonTriggerPatterns, []string{
3536
"experimental/ssh/",
3637
"acceptance/ssh/",
3738
}),
3839
target: "test-exp-ssh",
3940
},
4041
{
41-
prefixes: slices.Concat(goTriggerPatterns, []string{
42+
prefixes: slices.Concat(commonTriggerPatterns, []string{
4243
"cmd/pipelines/",
4344
"acceptance/pipelines/",
4445
}),

tools/testmask/targets_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ func TestGetTargets(t *testing.T) {
6161
},
6262
targets: []string{"test", "test-exp-aitools", "test-exp-ssh", "test-pipelines"},
6363
},
64+
{
65+
name: "setup_build_environment_triggers_all",
66+
files: []string{
67+
".github/actions/setup-build-environment/action.yml",
68+
},
69+
targets: []string{"test", "test-exp-aitools", "test-exp-ssh", "test-pipelines"},
70+
},
6471
{
6572
name: "empty_files",
6673
files: []string{},

0 commit comments

Comments
 (0)