Skip to content

Commit 6ff2af1

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 3df02fc commit 6ff2af1

File tree

3 files changed

+107
-16
lines changed

3 files changed

+107
-16
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.22.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: 1
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

+28-16
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
@@ -198,10 +204,17 @@ jobs:
198204
if: always()
199205
run: ./hack/debug-cache.sh
200206

207+
build-on-ubuntu:
208+
name: "Build on Ubuntu"
209+
uses: ./.github/workflows/build.yml
210+
with:
211+
runs-on: ubuntu-22.04
212+
201213
# Non-default templates are tested on Linux instances of GHA,
202214
# as they seem more stable than macOS instances.
203215
integration-linux:
204216
name: Integration tests (on Linux)
217+
needs: build-on-ubuntu
205218
runs-on: ubuntu-22.04
206219
timeout-minutes: 120
207220
strategy:
@@ -222,13 +235,9 @@ jobs:
222235
- uses: actions/checkout@v4
223236
with:
224237
fetch-depth: 1
225-
- uses: actions/setup-go@v5
238+
- uses: ./.github/actions/install_lima_from_artifact
226239
with:
227-
go-version: 1.22.x
228-
- name: Make
229-
run: make
230-
- name: Install
231-
run: sudo make install
240+
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
232241
- name: Cache image used by templates/${{ matrix.template }}
233242
uses: ./.github/actions/setup_cache_for_template
234243
with:
@@ -312,6 +321,7 @@ jobs:
312321

313322
vmnet:
314323
name: "VMNet test"
324+
needs: build-on-macos-12
315325
runs-on: macos-12
316326
timeout-minutes: 120
317327
steps:
@@ -321,10 +331,9 @@ jobs:
321331
- uses: actions/setup-go@v5
322332
with:
323333
go-version: 1.22.x
324-
- name: Make
325-
run: make
326-
- name: Install
327-
run: make install
334+
- uses: ./.github/actions/install_lima_from_artifact
335+
with:
336+
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
328337
- name: Cache image used by vmnet.yaml
329338
uses: ./.github/actions/setup_cache_for_template
330339
with:
@@ -388,8 +397,15 @@ jobs:
388397
- if: always()
389398
uses: ./.github/actions/upload_failure_logs_if_exists
390399

400+
build-on-macos-13:
401+
name: "Build on macOS 13"
402+
uses: ./.github/workflows/build.yml
403+
with:
404+
runs-on: macos-13
405+
391406
vz:
392407
name: "vz"
408+
needs: build-on-macos-13
393409
runs-on: macos-13
394410
timeout-minutes: 120
395411
strategy:
@@ -402,13 +418,9 @@ jobs:
402418
- uses: actions/checkout@v4
403419
with:
404420
fetch-depth: 1
405-
- uses: actions/setup-go@v5
421+
- uses: ./.github/actions/install_lima_from_artifact
406422
with:
407-
go-version: 1.22.x
408-
- name: Make
409-
run: make
410-
- name: Install
411-
run: make install
423+
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
412424
- name: Cache image used by templates/${{ matrix.template }}
413425
uses: ./.github/actions/setup_cache_for_template
414426
with:

0 commit comments

Comments
 (0)