Skip to content

Commit

Permalink
test.yml: try to unify caches on make and go test
Browse files Browse the repository at this point in the history
Signed-off-by: Norio Nomura <[email protected]>
  • Loading branch information
norio-nomura committed Sep 13, 2024
1 parent 8902dab commit 8cd0d22
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 72 deletions.
55 changes: 0 additions & 55 deletions .github/workflows/build.yml

This file was deleted.

70 changes: 70 additions & 0 deletions .github/workflows/build_lima_and_fill_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: build lima and fill cache
run-name: build lima and fill cache 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: true
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.make-artifacts.outputs.artifact }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: ./.github/actions/setup_go_with_cache
with:
go-version: ${{ inputs.go-version }}
runs-on: ${{ inputs.runs-on }}
- name: Install gcc for cross-compilation on Linux
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu gcc-x86-64-linux-gnu
- name: go test to filling cache
run: go test ./... --run=nope
shell: bash
- name: make artifacts to filling cache
id: make-artifacts
run: |
case "${RUNNER_OS}" in
Linux)
make artifacts-linux VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Linux-$(uname -m).tar.gz
;;
macOS)
make artifacts-darwin VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Darwin-$(uname -m).tar.gz
;;
Windows)
make artifacts-windows VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Windows-x86_64.tar.gz
;;
*)
echo "Unsupported OS: ${RUNNER_OS}"
exit 1 ;;
esac
echo "artifact=${artifact}" >> $GITHUB_OUTPUT
env:
RUNS_ON: ${{ inputs.runs-on }}
- name: upload archive
uses: actions/upload-artifact@v4
with:
name: ${{ steps.make-artifacts.outputs.artifact }}
path: _artifacts/${{ steps.make-artifacts.outputs.artifact }}
37 changes: 20 additions & 17 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ jobs:

unit:
name: "Unit tests"
needs: build-lima-and-fill-cache-on-ubuntu
runs-on: ubuntu-24.04
timeout-minutes: 30
strategy:
Expand All @@ -84,7 +85,6 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/setup_go_with_cache
with:
additional-gocache-key: unit
go-version: ${{ matrix.go-version }}
runs-on: ubuntu-24.04
- name: Unit tests
Expand Down Expand Up @@ -130,7 +130,6 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/setup_go_with_cache
with:
additional-gocache-key: windows
go-version: 1.23.x
runs-on: windows-2022-8-cores
- name: Unit tests
Expand All @@ -151,15 +150,17 @@ jobs:
if: always()
run: type C:\Users\runneradmin\.lima\wsl2\ha.stderr.log

build-on-macos-12:
build-lima-and-fill-cache-on-macos-12:
name: "Build on macOS 12"
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/build_lima_and_fill_cache.yml
with:
go-version: 1.23.x
runs-on: macos-12

integration:
name: Integration tests
# on macOS 12, the default vmType is QEMU
needs: build-lima-and-fill-cache-on-macos-12
runs-on: macos-12
timeout-minutes: 120
steps:
Expand All @@ -168,7 +169,6 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/setup_go_with_cache
with:
additional-gocache-key: integration
go-version: 1.23.x
runs-on: macos-12
- name: Unit tests
Expand Down Expand Up @@ -215,17 +215,18 @@ jobs:
if: always()
run: ./hack/debug-cache.sh

build-on-ubuntu:
build-lima-and-fill-cache-on-ubuntu:
name: "Build on Ubuntu"
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/build_lima_and_fill_cache.yml
with:
go-version: 1.23.x
runs-on: ubuntu-24.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
needs: build-lima-and-fill-cache-on-ubuntu
runs-on: ubuntu-24.04
timeout-minutes: 120
strategy:
Expand All @@ -248,7 +249,7 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/install_lima_from_artifact
with:
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
- name: Cache image used by templates/${{ matrix.template }}
uses: ./.github/actions/setup_cache_for_template
with:
Expand Down Expand Up @@ -282,7 +283,7 @@ jobs:

colima:
name: Colima
needs: build-on-ubuntu
needs: build-lima-and-fill-cache-on-ubuntu
runs-on: ubuntu-24.04
timeout-minutes: 120
strategy:
Expand All @@ -300,7 +301,7 @@ jobs:
key: ${{ runner.os }}-colima-${{ matrix.colima-version }}
- uses: ./.github/actions/install_lima_from_artifact
with:
artifact: ${{ needs.build-on-ubuntu.outputs.artifact }}
artifact: ${{ needs.build-lima-and-fill-cache-on-ubuntu.outputs.artifact }}
- name: Checkout colima
uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -338,7 +339,7 @@ jobs:

vmnet:
name: "VMNet test"
needs: build-on-macos-12
needs: build-lima-and-fill-cache-on-macos-12
runs-on: macos-12
timeout-minutes: 120
steps:
Expand All @@ -347,7 +348,7 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/install_lima_from_artifact
with:
artifact: ${{ needs.build-on-macos-12.outputs.artifact }}
artifact: ${{ needs.build-lima-and-fill-cache-on-macos-12.outputs.artifact }}
- name: "Inject `no_timer_check` to kernel cmdline"
# workaround to https://github.com/lima-vm/lima/issues/84
run: ./hack/inject-cmdline-to-template.sh templates/vmnet.yaml no_timer_check
Expand Down Expand Up @@ -391,6 +392,7 @@ jobs:

upgrade:
name: "Upgrade test"
needs: build-lima-and-fill-cache-on-macos-12
runs-on: macos-12
timeout-minutes: 120
strategy:
Expand Down Expand Up @@ -420,15 +422,16 @@ jobs:
- if: always()
uses: ./.github/actions/upload_failure_logs_if_exists

build-on-macos-13:
build-lima-and-fill-cache-on-macos-13:
name: "Build on macOS 13"
uses: ./.github/workflows/build.yml
uses: ./.github/workflows/build_lima_and_fill_cache.yml
with:
go-version: 1.23.x
runs-on: macos-13

vz:
name: "vz"
needs: build-on-macos-13
needs: build-lima-and-fill-cache-on-macos-13
# on macOS 13, the default vmType is VZ
runs-on: macos-13
timeout-minutes: 120
Expand All @@ -444,7 +447,7 @@ jobs:
fetch-depth: 1
- uses: ./.github/actions/install_lima_from_artifact
with:
artifact: ${{ needs.build-on-macos-13.outputs.artifact }}
artifact: ${{ needs.build-lima-and-fill-cache-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 8cd0d22

Please sign in to comment.