Skip to content

Commit dc36df8

Browse files
committed
test.yml: separate the job for building lima from the matrix test jobs to avoid duplicate builds under the same conditions.
Signed-off-by: Norio Nomura <[email protected]>
1 parent 2dcd64a commit dc36df8

File tree

3 files changed

+111
-22
lines changed

3 files changed

+111
-22
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: install lima from artifact
2+
description: install lima from artifact
3+
inputs:
4+
artifact:
5+
description: artifact to install
6+
required: true
7+
runs:
8+
using: "composite"
9+
steps:
10+
- uses: actions/download-artifact@v4
11+
with:
12+
name: ${{ inputs.artifact }}
13+
path: _artifacts
14+
- name: Install lima from downloaded archive on Linux
15+
if: runner.os == 'Linux'
16+
run: |
17+
sudo make uninstall
18+
sudo tar -C /usr/local -xvf _artifacts/${{ inputs.artifact }} --no-same-owner
19+
shell: bash
20+
- name: Install lima from downloaded archive on macOS
21+
if: runner.os == 'macOS'
22+
run: |
23+
make uninstall || true
24+
tar -C /usr/local -xvmf _artifacts/${{ inputs.artifact }} --no-same-owner
25+
shell: bash

.github/workflows/build.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: build lima
2+
run-name: build lima 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: false
11+
default: '1.23.x'
12+
runs-on:
13+
type: string
14+
description: 'The type of runner to use'
15+
required: true
16+
outputs:
17+
artifact:
18+
description: 'The name of the artifact'
19+
value: ${{ jobs.build.outputs.artifact }}
20+
21+
jobs:
22+
build:
23+
name: "Build on ${{ inputs.runs-on }} using go ${{ inputs.go-version }}"
24+
runs-on: ${{ inputs.runs-on }}
25+
timeout-minutes: 30
26+
outputs:
27+
artifact: ${{ steps.set-output.outputs.artifact }}
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
- uses: actions/setup-go@v5
33+
with:
34+
go-version: ${{ inputs.go-version }}
35+
- name: Make
36+
run: make
37+
- name: Make install on Linux
38+
if: runner.os == 'Linux'
39+
run: sudo make install
40+
- name: Make install on macOS
41+
if: runner.os == 'macOS'
42+
run: make install
43+
- name: set output
44+
id: set-output
45+
run: echo "artifact=lima-${{ inputs.runs-on }}.tar.gz" >> $GITHUB_OUTPUT
46+
- name: create archive
47+
run: |
48+
mkdir -p _artifacts
49+
tar -C _output/ -czvf _artifacts/${{ steps.set-output.outputs.artifact }} ./
50+
- name: upload archive
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: ${{ steps.set-output.outputs.artifact }}
54+
path: _artifacts/${{ steps.set-output.outputs.artifact }}

.github/workflows/test.yml

+32-22
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,12 @@ jobs:
146146
if: always()
147147
run: type C:\Users\runneradmin\.lima\wsl2\ha.stderr.log
148148

149+
build-on-macos-12:
150+
name: "Build on macOS 12"
151+
uses: ./.github/workflows/build.yml
152+
with:
153+
runs-on: macos-12
154+
149155
integration:
150156
name: Integration tests
151157
# on macOS 12, the default vmType is QEMU
@@ -202,10 +208,17 @@ jobs:
202208
if: always()
203209
run: ./hack/debug-cache.sh
204210

211+
build-on-ubuntu:
212+
name: "Build on Ubuntu"
213+
uses: ./.github/workflows/build.yml
214+
with:
215+
runs-on: ubuntu-24.04
216+
205217
# Non-default templates are tested on Linux instances of GHA,
206218
# as they seem more stable than macOS instances.
207219
integration-linux:
208220
name: Integration tests (on Linux)
221+
needs: build-on-ubuntu
209222
runs-on: ubuntu-24.04
210223
timeout-minutes: 120
211224
strategy:
@@ -226,13 +239,9 @@ jobs:
226239
- uses: actions/checkout@v4
227240
with:
228241
fetch-depth: 1
229-
- uses: actions/setup-go@v5
242+
- uses: ./.github/actions/install_lima_from_artifact
230243
with:
231-
go-version: 1.23.x
232-
- name: Make
233-
run: make
234-
- name: Install
235-
run: sudo make install
244+
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
236245
- name: Cache image used by templates/${{ matrix.template }}
237246
uses: ./.github/actions/setup_cache_for_template
238247
with:
@@ -266,6 +275,7 @@ jobs:
266275

267276
colima:
268277
name: Colima
278+
needs: build-on-ubuntu
269279
runs-on: ubuntu-24.04
270280
timeout-minutes: 120
271281
strategy:
@@ -284,10 +294,9 @@ jobs:
284294
with:
285295
path: ~/.cache/lima/download
286296
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
287-
- name: Make
288-
run: make
289-
- name: Install
290-
run: sudo make install
297+
- uses: ./.github/actions/install_lima_from_artifact
298+
with:
299+
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
291300
- name: Install colima
292301
run: |
293302
git clone https://github.com/abiosoft/colima
@@ -316,22 +325,20 @@ jobs:
316325

317326
vmnet:
318327
name: "VMNet test"
328+
needs: build-on-macos-12
319329
runs-on: macos-12
320330
timeout-minutes: 120
321331
steps:
322332
- uses: actions/checkout@v4
323333
with:
324334
fetch-depth: 1
325-
- uses: actions/setup-go@v5
335+
- uses: ./.github/actions/install_lima_from_artifact
326336
with:
327-
go-version: 1.23.x
328-
- name: Make
329-
run: make
330-
- name: Install
331-
run: make install
337+
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
332338
- name: "Inject `no_timer_check` to kernel cmdline"
333339
# workaround to https://github.com/lima-vm/lima/issues/84
334340
run: ./hack/inject-cmdline-to-template.sh templates/vmnet.yaml no_timer_check
341+
335342
- name: Cache image used by vmnet.yaml
336343
uses: ./.github/actions/setup_cache_for_template
337344
with:
@@ -394,8 +401,15 @@ jobs:
394401
- if: always()
395402
uses: ./.github/actions/upload_failure_logs_if_exists
396403

404+
build-on-macos-13:
405+
name: "Build on macOS 13"
406+
uses: ./.github/workflows/build.yml
407+
with:
408+
runs-on: macos-13
409+
397410
vz:
398411
name: "vz"
412+
needs: build-on-macos-13
399413
# on macOS 13, the default vmType is VZ
400414
runs-on: macos-13
401415
timeout-minutes: 120
@@ -409,13 +423,9 @@ jobs:
409423
- uses: actions/checkout@v4
410424
with:
411425
fetch-depth: 1
412-
- uses: actions/setup-go@v5
426+
- uses: ./.github/actions/install_lima_from_artifact
413427
with:
414-
go-version: 1.23.x
415-
- name: Make
416-
run: make
417-
- name: Install
418-
run: make install
428+
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
419429
- name: Cache image used by templates/${{ matrix.template }}
420430
uses: ./.github/actions/setup_cache_for_template
421431
with:

0 commit comments

Comments
 (0)