Skip to content

Commit

Permalink
test.yml: separate the job for building lima from the matrix test j…
Browse files Browse the repository at this point in the history
…obs to avoid duplicate builds under the same conditions.

Signed-off-by: Norio Nomura <[email protected]>
  • Loading branch information
norio-nomura committed Aug 7, 2024
1 parent c82e6ce commit fcbb5a7
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 22 deletions.
25 changes: 25 additions & 0 deletions .github/actions/install_lima_from_artifact/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: install lima from artifact
description: install lima from artifact
inputs:
artifact:
description: artifact to install
required: true
runs:
using: "composite"
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact }}
path: _artifacts
- name: Install lima from downloaded archive on Linux
if: runner.os == 'Linux'
run: |
sudo make uninstall
sudo tar -C /usr/local -xvf _artifacts/${{ inputs.artifact }} --no-same-owner
shell: bash
- name: Install lima from downloaded archive on macOS
if: runner.os == 'macOS'
run: |
make uninstall || true
tar -C /usr/local -xvmf _artifacts/${{ inputs.artifact }} --no-same-owner
shell: bash
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: build lima
run-name: build lima on ${{ inputs.runs-on }} using go ${{ inputs.go-version }}

on:
workflow_call:
inputs:
go-version:
type: string
description: 'The version of Go to use'
required: false
default: '1.22.x'
runs-on:
type: string
description: 'The type of runner to use'
required: true
outputs:
artifact:
description: 'The name of the artifact'
value: ${{ jobs.build.outputs.artifact }}

jobs:
build:
name: "Build on ${{ inputs.runs-on }} using go ${{ inputs.go-version }}"
runs-on: ${{ inputs.runs-on }}
timeout-minutes: 30
outputs:
artifact: ${{ steps.set-output.outputs.artifact }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: ${{ inputs.go-version }}
- name: Make
run: make
- name: Make install on Linux
if: runner.os == 'Linux'
run: sudo make install
- name: Make install on macOS
if: runner.os == 'macOS'
run: make install
- name: set output
id: set-output
run: echo "artifact=lima-${{ inputs.runs-on }}.tar.gz" >> $GITHUB_OUTPUT
- name: create archive
run: |
mkdir -p _artifacts
tar -C _output/ -czvf _artifacts/${{ steps.set-output.outputs.artifact }} ./
- name: upload archive
uses: actions/upload-artifact@v4
with:
name: ${{ steps.set-output.outputs.artifact }}
path: _artifacts/${{ steps.set-output.outputs.artifact }}
53 changes: 31 additions & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ jobs:
if: always()
run: type C:\Users\runneradmin\.lima\wsl2\ha.stderr.log

build-on-macos-12:
name: "Build on macOS 12"
uses: ./.github/workflows/build.yml
with:
runs-on: macos-12

integration:
name: Integration tests
runs-on: macos-12
Expand Down Expand Up @@ -198,10 +204,17 @@ jobs:
if: always()
run: ./hack/debug-cache.sh

build-on-ubuntu:
name: "Build on Ubuntu"
uses: ./.github/workflows/build.yml
with:
runs-on: ubuntu-22.04

# Non-default templates are tested on Linux instances of GHA,
# as they seem more stable than macOS instances.
integration-linux:
name: Integration tests (on Linux)
needs: build-on-ubuntu
runs-on: ubuntu-22.04
timeout-minutes: 120
strategy:
Expand All @@ -222,13 +235,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
- uses: ./.github/actions/install_lima_from_artifact
with:
go-version: 1.22.x
- name: Make
run: make
- name: Install
run: sudo make install
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
- name: Cache image used by templates/${{ matrix.template }}
uses: ./.github/actions/setup_cache_for_template
with:
Expand Down Expand Up @@ -262,6 +271,7 @@ jobs:

colima:
name: Colima
needs: build-on-ubuntu
runs-on: ubuntu-22.04
timeout-minutes: 120
strategy:
Expand All @@ -280,10 +290,9 @@ jobs:
with:
path: ~/.cache/lima/download
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
- name: Make
run: make
- name: Install
run: sudo make install
- uses: ./.github/actions/install_lima_from_artifact
with:
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
- name: Install colima
run: |
git clone https://github.com/abiosoft/colima
Expand Down Expand Up @@ -312,19 +321,16 @@ jobs:

vmnet:
name: "VMNet test"
needs: build-on-macos-12
runs-on: macos-12
timeout-minutes: 120
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
- uses: ./.github/actions/install_lima_from_artifact
with:
go-version: 1.22.x
- name: Make
run: make
- name: Install
run: make install
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
- name: Cache image used by vmnet.yaml
uses: ./.github/actions/setup_cache_for_template
with:
Expand Down Expand Up @@ -388,8 +394,15 @@ jobs:
- if: always()
uses: ./.github/actions/upload_failure_logs_if_exists

build-on-macos-13:
name: "Build on macOS 13"
uses: ./.github/workflows/build.yml
with:
runs-on: macos-13

vz:
name: "vz"
needs: build-on-macos-13
runs-on: macos-13
timeout-minutes: 120
strategy:
Expand All @@ -402,13 +415,9 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-go@v5
- uses: ./.github/actions/install_lima_from_artifact
with:
go-version: 1.22.x
- name: Make
run: make
- name: Install
run: make install
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
- name: Cache image used by templates/${{ matrix.template }}
uses: ./.github/actions/setup_cache_for_template
with:
Expand Down

0 comments on commit fcbb5a7

Please sign in to comment.