Skip to content

Commit 8cd0d22

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

File tree

3 files changed

+90
-72
lines changed

3 files changed

+90
-72
lines changed

.github/workflows/build.yml

-55
This file was deleted.
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

+20-17
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ jobs:
6767

6868
unit:
6969
name: "Unit tests"
70+
needs: build-lima-and-fill-cache-on-ubuntu
7071
runs-on: ubuntu-24.04
7172
timeout-minutes: 30
7273
strategy:
@@ -84,7 +85,6 @@ jobs:
8485
fetch-depth: 1
8586
- uses: ./.github/actions/setup_go_with_cache
8687
with:
87-
additional-gocache-key: unit
8888
go-version: ${{ matrix.go-version }}
8989
runs-on: ubuntu-24.04
9090
- name: Unit tests
@@ -130,7 +130,6 @@ jobs:
130130
fetch-depth: 1
131131
- uses: ./.github/actions/setup_go_with_cache
132132
with:
133-
additional-gocache-key: windows
134133
go-version: 1.23.x
135134
runs-on: windows-2022-8-cores
136135
- name: Unit tests
@@ -151,15 +150,17 @@ jobs:
151150
if: always()
152151
run: type C:\Users\runneradmin\.lima\wsl2\ha.stderr.log
153152

154-
build-on-macos-12:
153+
build-lima-and-fill-cache-on-macos-12:
155154
name: "Build on macOS 12"
156-
uses: ./.github/workflows/build.yml
155+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
157156
with:
157+
go-version: 1.23.x
158158
runs-on: macos-12
159159

160160
integration:
161161
name: Integration tests
162162
# on macOS 12, the default vmType is QEMU
163+
needs: build-lima-and-fill-cache-on-macos-12
163164
runs-on: macos-12
164165
timeout-minutes: 120
165166
steps:
@@ -168,7 +169,6 @@ jobs:
168169
fetch-depth: 1
169170
- uses: ./.github/actions/setup_go_with_cache
170171
with:
171-
additional-gocache-key: integration
172172
go-version: 1.23.x
173173
runs-on: macos-12
174174
- name: Unit tests
@@ -215,17 +215,18 @@ jobs:
215215
if: always()
216216
run: ./hack/debug-cache.sh
217217

218-
build-on-ubuntu:
218+
build-lima-and-fill-cache-on-ubuntu:
219219
name: "Build on Ubuntu"
220-
uses: ./.github/workflows/build.yml
220+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
221221
with:
222+
go-version: 1.23.x
222223
runs-on: ubuntu-24.04
223224

224225
# Non-default templates are tested on Linux instances of GHA,
225226
# as they seem more stable than macOS instances.
226227
integration-linux:
227228
name: Integration tests (on Linux)
228-
needs: build-on-ubuntu
229+
needs: build-lima-and-fill-cache-on-ubuntu
229230
runs-on: ubuntu-24.04
230231
timeout-minutes: 120
231232
strategy:
@@ -248,7 +249,7 @@ jobs:
248249
fetch-depth: 1
249250
- uses: ./.github/actions/install_lima_from_artifact
250251
with:
251-
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
252+
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
252253
- name: Cache image used by templates/${{ matrix.template }}
253254
uses: ./.github/actions/setup_cache_for_template
254255
with:
@@ -282,7 +283,7 @@ jobs:
282283

283284
colima:
284285
name: Colima
285-
needs: build-on-ubuntu
286+
needs: build-lima-and-fill-cache-on-ubuntu
286287
runs-on: ubuntu-24.04
287288
timeout-minutes: 120
288289
strategy:
@@ -300,7 +301,7 @@ jobs:
300301
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
301302
- uses: ./.github/actions/install_lima_from_artifact
302303
with:
303-
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
304+
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
304305
- name: Checkout colima
305306
uses: actions/checkout@v4
306307
with:
@@ -338,7 +339,7 @@ jobs:
338339

339340
vmnet:
340341
name: "VMNet test"
341-
needs: build-on-macos-12
342+
needs: build-lima-and-fill-cache-on-macos-12
342343
runs-on: macos-12
343344
timeout-minutes: 120
344345
steps:
@@ -347,7 +348,7 @@ jobs:
347348
fetch-depth: 1
348349
- uses: ./.github/actions/install_lima_from_artifact
349350
with:
350-
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
351+
artifact: ${{ needs.build-lima-and-fill-cache-on-macos-12.outputs.artifact }}
351352
- name: "Inject `no_timer_check` to kernel cmdline"
352353
# workaround to https://github.com/lima-vm/lima/issues/84
353354
run: ./hack/inject-cmdline-to-template.sh templates/vmnet.yaml no_timer_check
@@ -391,6 +392,7 @@ jobs:
391392

392393
upgrade:
393394
name: "Upgrade test"
395+
needs: build-lima-and-fill-cache-on-macos-12
394396
runs-on: macos-12
395397
timeout-minutes: 120
396398
strategy:
@@ -420,15 +422,16 @@ jobs:
420422
- if: always()
421423
uses: ./.github/actions/upload_failure_logs_if_exists
422424

423-
build-on-macos-13:
425+
build-lima-and-fill-cache-on-macos-13:
424426
name: "Build on macOS 13"
425-
uses: ./.github/workflows/build.yml
427+
uses: ./.github/workflows/build_lima_and_fill_cache.yml
426428
with:
429+
go-version: 1.23.x
427430
runs-on: macos-13
428431

429432
vz:
430433
name: "vz"
431-
needs: build-on-macos-13
434+
needs: build-lima-and-fill-cache-on-macos-13
432435
# on macOS 13, the default vmType is VZ
433436
runs-on: macos-13
434437
timeout-minutes: 120
@@ -444,7 +447,7 @@ jobs:
444447
fetch-depth: 1
445448
- uses: ./.github/actions/install_lima_from_artifact
446449
with:
447-
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
450+
artifact: ${{ needs.build-lima-and-fill-cache-on-macos-13.outputs.artifact }}
448451
- name: Cache image used by templates/${{ matrix.template }}
449452
uses: ./.github/actions/setup_cache_for_template
450453
with:

0 commit comments

Comments
 (0)