Skip to content

Commit 9d94a6c

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 f44b3f9 commit 9d94a6c

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
runs-on: macos-12
@@ -201,10 +207,17 @@ jobs:
201207
if: always()
202208
run: ./hack/debug-cache.sh
203209

210+
build-on-ubuntu:
211+
name: "Build on Ubuntu"
212+
uses: ./.github/workflows/build.yml
213+
with:
214+
runs-on: ubuntu-24.04
215+
204216
# Non-default templates are tested on Linux instances of GHA,
205217
# as they seem more stable than macOS instances.
206218
integration-linux:
207219
name: Integration tests (on Linux)
220+
needs: build-on-ubuntu
208221
runs-on: ubuntu-24.04
209222
timeout-minutes: 120
210223
strategy:
@@ -225,13 +238,9 @@ jobs:
225238
- uses: actions/checkout@v4
226239
with:
227240
fetch-depth: 1
228-
- uses: actions/setup-go@v5
241+
- uses: ./.github/actions/install_lima_from_artifact
229242
with:
230-
go-version: 1.23.x
231-
- name: Make
232-
run: make
233-
- name: Install
234-
run: sudo make install
243+
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
235244
- name: Cache image used by templates/${{ matrix.template }}
236245
uses: ./.github/actions/setup_cache_for_template
237246
with:
@@ -265,6 +274,7 @@ jobs:
265274

266275
colima:
267276
name: Colima
277+
needs: build-on-ubuntu
268278
runs-on: ubuntu-24.04
269279
timeout-minutes: 120
270280
strategy:
@@ -283,10 +293,9 @@ jobs:
283293
with:
284294
path: ~/.cache/lima/download
285295
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
286-
- name: Make
287-
run: make
288-
- name: Install
289-
run: sudo make install
296+
- uses: ./.github/actions/install_lima_from_artifact
297+
with:
298+
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
290299
- name: Install colima
291300
run: |
292301
git clone https://github.com/abiosoft/colima
@@ -315,22 +324,20 @@ jobs:
315324

316325
vmnet:
317326
name: "VMNet test"
327+
needs: build-on-macos-12
318328
runs-on: macos-12
319329
timeout-minutes: 120
320330
steps:
321331
- uses: actions/checkout@v4
322332
with:
323333
fetch-depth: 1
324-
- uses: actions/setup-go@v5
334+
- uses: ./.github/actions/install_lima_from_artifact
325335
with:
326-
go-version: 1.23.x
327-
- name: Make
328-
run: make
329-
- name: Install
330-
run: make install
336+
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
331337
- name: "Inject `no_timer_check` to kernel cmdline"
332338
# workaround to https://github.com/lima-vm/lima/issues/84
333339
run: ./hack/inject-cmdline-to-template.sh templates/vmnet.yaml no_timer_check
340+
334341
- name: Cache image used by vmnet.yaml
335342
uses: ./.github/actions/setup_cache_for_template
336343
with:
@@ -393,8 +400,15 @@ jobs:
393400
- if: always()
394401
uses: ./.github/actions/upload_failure_logs_if_exists
395402

403+
build-on-macos-13:
404+
name: "Build on macOS 13"
405+
uses: ./.github/workflows/build.yml
406+
with:
407+
runs-on: macos-13
408+
396409
vz:
397410
name: "vz"
411+
needs: build-on-macos-13
398412
runs-on: macos-13
399413
timeout-minutes: 120
400414
strategy:
@@ -407,13 +421,9 @@ jobs:
407421
- uses: actions/checkout@v4
408422
with:
409423
fetch-depth: 1
410-
- uses: actions/setup-go@v5
424+
- uses: ./.github/actions/install_lima_from_artifact
411425
with:
412-
go-version: 1.23.x
413-
- name: Make
414-
run: make
415-
- name: Install
416-
run: make install
426+
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
417427
- name: Cache image used by templates/${{ matrix.template }}
418428
uses: ./.github/actions/setup_cache_for_template
419429
with:

0 commit comments

Comments
 (0)