Skip to content

Commit c2a1041

Browse files
committed
test.yml: try to unify caches on make and go test
Signed-off-by: Norio Nomura <[email protected]>
1 parent b130698 commit c2a1041

File tree

3 files changed

+90
-72
lines changed

3 files changed

+90
-72
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 55 deletions
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
name: build lima and fill cache
2+
run-name: build lima and fill cache on ${{ inputs.runs-on }} using go ${{ inputs.go-version }}
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
go-version:
8+
type: string
9+
description: 'The version of Go to use'
10+
required: true
11+
runs-on:
12+
type: string
13+
description: 'The type of runner to use'
14+
required: true
15+
outputs:
16+
artifact:
17+
description: 'The name of the artifact'
18+
value: ${{ jobs.build.outputs.artifact }}
19+
20+
jobs:
21+
build:
22+
name: "Build on ${{ inputs.runs-on }} using go ${{ inputs.go-version }}"
23+
runs-on: ${{ inputs.runs-on }}
24+
timeout-minutes: 30
25+
outputs:
26+
artifact: ${{ steps.make-artifacts.outputs.artifact }}
27+
steps:
28+
- uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
- uses: ./.github/actions/setup_go_with_cache
32+
with:
33+
go-version: ${{ inputs.go-version }}
34+
runs-on: ${{ inputs.runs-on }}
35+
- name: Install gcc for cross-compilation on Linux
36+
if: runner.os == 'Linux'
37+
run: |
38+
sudo apt-get update
39+
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
40+
- name: go test to filling cache
41+
run: go test ./... --run=nope
42+
shell: bash
43+
- name: make artifacts to filling cache
44+
id: make-artifacts
45+
run: |
46+
case "${RUNNER_OS}" in
47+
Linux)
48+
make artifacts-linux VERSION_TRIMMED="${RUNS_ON}"
49+
artifact=lima-${RUNS_ON}-Linux-$(uname -m).tar.gz
50+
;;
51+
macOS)
52+
make artifacts-darwin VERSION_TRIMMED="${RUNS_ON}"
53+
artifact=lima-${RUNS_ON}-Darwin-$(uname -m).tar.gz
54+
;;
55+
Windows)
56+
make artifacts-windows VERSION_TRIMMED="${RUNS_ON}"
57+
artifact=lima-${RUNS_ON}-Windows-x86_64.tar.gz
58+
;;
59+
*)
60+
echo "Unsupported OS: ${RUNNER_OS}"
61+
exit 1 ;;
62+
esac
63+
echo "artifact=${artifact}" >> $GITHUB_OUTPUT
64+
env:
65+
RUNS_ON: ${{ inputs.runs-on }}
66+
- name: upload archive
67+
uses: actions/upload-artifact@v4
68+
with:
69+
name: ${{ steps.make-artifacts.outputs.artifact }}
70+
path: _artifacts/${{ steps.make-artifacts.outputs.artifact }}

.github/workflows/test.yml

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ jobs:
6868

6969
unit:
7070
name: "Unit tests"
71+
needs: build-lima-and-fill-cache-on-ubuntu
7172
runs-on: ubuntu-24.04
7273
timeout-minutes: 30
7374
strategy:
@@ -85,7 +86,6 @@ jobs:
8586
fetch-depth: 1
8687
- uses: ./.github/actions/setup_go_with_cache
8788
with:
88-
additional-gocache-key: unit
8989
go-version: ${{ matrix.go-version }}
9090
runs-on: ubuntu-24.04
9191
- name: Unit tests
@@ -135,7 +135,6 @@ jobs:
135135
fetch-depth: 1
136136
- uses: ./.github/actions/setup_go_with_cache
137137
with:
138-
additional-gocache-key: windows
139138
go-version: 1.23.x
140139
runs-on: windows-2022-8-cores
141140
- name: Unit tests
@@ -156,15 +155,17 @@ jobs:
156155
if: always()
157156
run: type C:\Users\runneradmin\.lima\wsl2\ha.stderr.log
158157

159-
build-on-macos-12:
158+
build-lima-and-fill-cache-on-macos-12:
160159
name: "Build on macOS 12"
161-
uses: ./.github/workflows/build.yml
160+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
162161
with:
162+
go-version: 1.23.x
163163
runs-on: macos-12
164164

165165
integration:
166166
name: Integration tests
167167
# on macOS 12, the default vmType is QEMU
168+
needs: build-lima-and-fill-cache-on-macos-12
168169
runs-on: macos-12
169170
timeout-minutes: 120
170171
steps:
@@ -174,7 +175,6 @@ jobs:
174175
fetch-depth: 0
175176
- uses: ./.github/actions/setup_go_with_cache
176177
with:
177-
additional-gocache-key: integration
178178
go-version: 1.23.x
179179
runs-on: macos-12
180180
- name: Unit tests
@@ -221,17 +221,18 @@ jobs:
221221
if: always()
222222
run: ./hack/debug-cache.sh
223223

224-
build-on-ubuntu:
224+
build-lima-and-fill-cache-on-ubuntu:
225225
name: "Build on Ubuntu"
226-
uses: ./.github/workflows/build.yml
226+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
227227
with:
228+
go-version: 1.23.x
228229
runs-on: ubuntu-24.04
229230

230231
# Non-default templates are tested on Linux instances of GHA,
231232
# as they seem more stable than macOS instances.
232233
integration-linux:
233234
name: Integration tests (on Linux)
234-
needs: build-on-ubuntu
235+
needs: build-lima-and-fill-cache-on-ubuntu
235236
runs-on: ubuntu-24.04
236237
timeout-minutes: 120
237238
strategy:
@@ -254,7 +255,7 @@ jobs:
254255
fetch-depth: 1
255256
- uses: ./.github/actions/install_lima_from_artifact
256257
with:
257-
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
258+
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
258259
- name: Cache image used by templates/${{ matrix.template }}
259260
uses: ./.github/actions/setup_cache_for_template
260261
with:
@@ -288,7 +289,7 @@ jobs:
288289

289290
colima:
290291
name: Colima
291-
needs: build-on-ubuntu
292+
needs: build-lima-and-fill-cache-on-ubuntu
292293
runs-on: ubuntu-24.04
293294
timeout-minutes: 120
294295
strategy:
@@ -306,7 +307,7 @@ jobs:
306307
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
307308
- uses: ./.github/actions/install_lima_from_artifact
308309
with:
309-
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
310+
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
310311
- name: Checkout colima
311312
uses: actions/checkout@v4
312313
with:
@@ -344,7 +345,7 @@ jobs:
344345

345346
vmnet:
346347
name: "VMNet test"
347-
needs: build-on-macos-12
348+
needs: build-lima-and-fill-cache-on-macos-12
348349
runs-on: macos-12
349350
timeout-minutes: 120
350351
steps:
@@ -353,7 +354,7 @@ jobs:
353354
fetch-depth: 1
354355
- uses: ./.github/actions/install_lima_from_artifact
355356
with:
356-
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
357+
artifact: ${{ needs.build-lima-and-fill-cache-on-macos-12.outputs.artifact }}
357358
- name: "Inject `no_timer_check` to kernel cmdline"
358359
# workaround to https://github.com/lima-vm/lima/issues/84
359360
run: ./hack/inject-cmdline-to-template.sh templates/vmnet.yaml no_timer_check
@@ -397,6 +398,7 @@ jobs:
397398

398399
upgrade:
399400
name: "Upgrade test"
401+
needs: build-lima-and-fill-cache-on-macos-12
400402
runs-on: macos-12
401403
timeout-minutes: 120
402404
strategy:
@@ -438,15 +440,16 @@ jobs:
438440
- if: always()
439441
uses: ./.github/actions/upload_failure_logs_if_exists
440442

441-
build-on-macos-13:
443+
build-lima-and-fill-cache-on-macos-13:
442444
name: "Build on macOS 13"
443-
uses: ./.github/workflows/build.yml
445+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
444446
with:
447+
go-version: 1.23.x
445448
runs-on: macos-13
446449

447450
vz:
448451
name: "vz"
449-
needs: build-on-macos-13
452+
needs: build-lima-and-fill-cache-on-macos-13
450453
# on macOS 13, the default vmType is VZ
451454
runs-on: macos-13
452455
timeout-minutes: 120
@@ -462,7 +465,7 @@ jobs:
462465
fetch-depth: 1
463466
- uses: ./.github/actions/install_lima_from_artifact
464467
with:
465-
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
468+
artifact: ${{ needs.build-lima-and-fill-cache-on-macos-13.outputs.artifact }}
466469
- name: Cache image used by templates/${{ matrix.template }}
467470
uses: ./.github/actions/setup_cache_for_template
468471
with:

0 commit comments

Comments
 (0)