From ac79161b8d1c8f37ca406b41f4c8c0eaf372b1c1 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 6 Aug 2024 14:41:19 +0900 Subject: [PATCH 01/14] 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 --- .../install_lima_from_artifact/action.yml | 25 +++++++++ .github/workflows/build.yml | 54 +++++++++++++++++++ .github/workflows/test.yml | 54 +++++++++++-------- 3 files changed, 111 insertions(+), 22 deletions(-) create mode 100644 .github/actions/install_lima_from_artifact/action.yml create mode 100644 .github/workflows/build.yml diff --git a/.github/actions/install_lima_from_artifact/action.yml b/.github/actions/install_lima_from_artifact/action.yml new file mode 100644 index 00000000000..349b4d7271a --- /dev/null +++ b/.github/actions/install_lima_from_artifact/action.yml @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 00000000000..543a941d34d --- /dev/null +++ b/.github/workflows/build.yml @@ -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.23.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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e861d09a79f..54ad949e1bd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -151,6 +151,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 # on macOS 12, the default vmType is QEMU @@ -208,10 +214,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-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 runs-on: ubuntu-24.04 timeout-minutes: 120 strategy: @@ -232,13 +245,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.23.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: @@ -272,6 +281,7 @@ jobs: colima: name: Colima + needs: build-on-ubuntu runs-on: ubuntu-24.04 timeout-minutes: 120 strategy: @@ -290,10 +300,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 @@ -322,22 +331,20 @@ 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.23.x - - name: Make - run: make - - name: Install - run: make install + artifact: ${{ needs.build-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 + - name: Cache image used by vmnet.yaml uses: ./.github/actions/setup_cache_for_template with: @@ -412,8 +419,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 # on macOS 13, the default vmType is VZ runs-on: macos-13 timeout-minutes: 120 @@ -427,13 +441,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.23.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: From 85fa72ada871f70427e95e12ae31d1e7f6b12c2d Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 2 Sep 2024 17:46:55 +0900 Subject: [PATCH 02/14] ci: avoid using default caching feature of `actions/setup-go` `actions/setup-go` configures the cache under the assumption that a single module will be built with one setup. Signed-off-by: Norio Nomura --- .github/actions/setup_cache_for_go/action.yml | 47 +++++++++++++++++++ .github/workflows/build.yml | 8 +++- .github/workflows/test.yml | 47 +++++++++++++++---- 3 files changed, 92 insertions(+), 10 deletions(-) create mode 100644 .github/actions/setup_cache_for_go/action.yml diff --git a/.github/actions/setup_cache_for_go/action.yml b/.github/actions/setup_cache_for_go/action.yml new file mode 100644 index 00000000000..ddbfe376fcb --- /dev/null +++ b/.github/actions/setup_cache_for_go/action.yml @@ -0,0 +1,47 @@ +name: setup cache for go +description: setup cache for go. export GOMODCACHE environment variable +inputs: + go-version: + description: go version + required: true + runs-on: + description: runs on + required: true + working-directory: + description: working directory + default: '.' +runs: + using: "composite" + steps: + - name: Set GOMODCACHE environment variable + run: echo "GOMODCACHE=$(pwd)/.gomodcache" >> $GITHUB_ENV + shell: bash + - id: go-env + run: | + echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT + echo "GOMOD=$(go env GOMOD)" >> $GITHUB_OUTPUT + echo "GOSUM=$(realpath go.sum)" >> $GITHUB_OUTPUT + shell: bash + working-directory: ${{ inputs.working-directory }} + - name: Cache go modules + uses: actions/cache@v4 + with: + path: .gomodcache + key: go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }} + restore-keys: | + go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}- + go-modcache-${{ inputs.working-directory }}- + enableCrossOsArchive: true + - name: Cache go build cache + uses: actions/cache@v4 + with: + path: ${{ steps.go-env.outputs.GOCACHE }} + key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} + restore-keys: | + go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}- + go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}- + go-cache-${{ inputs.working-directory }}- + - name: Download dependencies + run: go mod download -x + shell: bash + working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 543a941d34d..2db23fd7369 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,9 +29,15 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/setup-go@v5 + - id: setup-go + uses: actions/setup-go@v5 with: + cache: false go-version: ${{ inputs.go-version }} + - uses: ./.github/actions/setup_cache_for_go + with: + go-version: ${{ steps.setup-go.outputs.go-version }} + runs-on: ${{ inputs.runs-on }} - name: Make run: make - name: Make install on Linux diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 54ad949e1bd..c368d116f8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,9 +82,15 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - uses: actions/setup-go@v5 + - id: setup-go + uses: actions/setup-go@v5 with: + cache: false go-version: ${{ matrix.go-version }} + - uses: ./.github/actions/setup_cache_for_go + with: + go-version: ${{ steps.setup-go.outputs.go-version }} + runs-on: ubuntu-24.04 - name: Unit tests run: go test -v ./... - name: Make @@ -167,9 +173,15 @@ jobs: with: # To avoid "failed to load YAML file \"templates/experimental/riscv64.yaml\": can't parse builtin Lima version \"3f3a6f6\": 3f3a6f6 is not in dotted-tri format" fetch-depth: 0 - - uses: actions/setup-go@v5 + - id: setup-go + uses: actions/setup-go@v5 with: + cache: false go-version: 1.23.x + - uses: ./.github/actions/setup_cache_for_go + with: + go-version: ${{ steps.setup-go.outputs.go-version }} + runs-on: macos-12 - name: Unit tests run: go test -v ./... - name: Make @@ -293,9 +305,6 @@ jobs: # fetch-depth is set to 0 to let `limactl --version` print semver-ish version fetch-depth: 0 ref: ${{ github.event.pull_request.head.sha }} - - uses: actions/setup-go@v5 - with: - go-version: 1.23.x - uses: actions/cache@v4 with: path: ~/.cache/lima/download @@ -303,13 +312,27 @@ jobs: - uses: ./.github/actions/install_lima_from_artifact with: artifact: ${{ needs.build-on-ubuntu.outputs.artifact }} + - name: Checkout colima + uses: actions/checkout@v4 + with: + repository: abiosoft/colima + ref: ${{ matrix.colima-version }} + path: colima + - id: setup-go + uses: actions/setup-go@v5 + with: + cache: false + go-version: 1.23.x + - uses: ./.github/actions/setup_cache_for_go + with: + go-version: ${{ steps.setup-go.outputs.go-version }} + runs-on: macos-12 + working-directory: ./colima - name: Install colima run: | - git clone https://github.com/abiosoft/colima - cd colima - git checkout ${{ matrix.colima-version }} make sudo make install + working-directory: ./colima - name: Install test dependencies run: | sudo apt-get update @@ -396,9 +419,15 @@ jobs: path: homebrew-core fetch-depth: 0 filter: tree:0 - - uses: actions/setup-go@v5 + - id: setup-go + uses: actions/setup-go@v5 with: + cache: false go-version: 1.23.x + - uses: ./.github/actions/setup_cache_for_go + with: + go-version: ${{ steps.setup-go.outputs.go-version }} + runs-on: macos-12 - name: Cache image used by ${{ matrix.oldver }}/examples/ubuntu-lts.yaml uses: ./.github/actions/setup_cache_for_template with: From a076e6b9815486494b0bd365f664e6a51b090d93 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 2 Sep 2024 18:17:02 +0900 Subject: [PATCH 03/14] setup_go_with_cache: migrate from `actions/setup-go` Signed-off-by: Norio Nomura --- .../action.yml | 17 +++++++---- .github/workflows/build.yml | 7 +---- .github/workflows/test.yml | 28 +++---------------- 3 files changed, 16 insertions(+), 36 deletions(-) rename .github/actions/{setup_cache_for_go => setup_go_with_cache}/action.yml (69%) diff --git a/.github/actions/setup_cache_for_go/action.yml b/.github/actions/setup_go_with_cache/action.yml similarity index 69% rename from .github/actions/setup_cache_for_go/action.yml rename to .github/actions/setup_go_with_cache/action.yml index ddbfe376fcb..ee45389a245 100644 --- a/.github/actions/setup_cache_for_go/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -1,5 +1,5 @@ -name: setup cache for go -description: setup cache for go. export GOMODCACHE environment variable +name: setup go with cache +description: setup go with cache. export GOMODCACHE environment variable inputs: go-version: description: go version @@ -13,6 +13,11 @@ inputs: runs: using: "composite" steps: + - id: setup-go + uses: actions/setup-go@v5 + with: + cache: false + go-version: ${{ inputs.go-version }} - name: Set GOMODCACHE environment variable run: echo "GOMODCACHE=$(pwd)/.gomodcache" >> $GITHUB_ENV shell: bash @@ -27,18 +32,18 @@ runs: uses: actions/cache@v4 with: path: .gomodcache - key: go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }} + key: go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }} restore-keys: | - go-modcache-${{ inputs.working-directory }}-${{ inputs.go-version }}- + go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}- go-modcache-${{ inputs.working-directory }}- enableCrossOsArchive: true - name: Cache go build cache uses: actions/cache@v4 with: path: ${{ steps.go-env.outputs.GOCACHE }} - key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} + key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} restore-keys: | - go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.go-version }}- + go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}- go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}- go-cache-${{ inputs.working-directory }}- - name: Download dependencies diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2db23fd7369..7576f9d92e1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -29,14 +29,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - id: setup-go - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: - cache: false go-version: ${{ inputs.go-version }} - - uses: ./.github/actions/setup_cache_for_go - with: - go-version: ${{ steps.setup-go.outputs.go-version }} runs-on: ${{ inputs.runs-on }} - name: Make run: make diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c368d116f8e..fd767279098 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -82,14 +82,9 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - id: setup-go - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: - cache: false go-version: ${{ matrix.go-version }} - - uses: ./.github/actions/setup_cache_for_go - with: - go-version: ${{ steps.setup-go.outputs.go-version }} runs-on: ubuntu-24.04 - name: Unit tests run: go test -v ./... @@ -173,14 +168,9 @@ jobs: with: # To avoid "failed to load YAML file \"templates/experimental/riscv64.yaml\": can't parse builtin Lima version \"3f3a6f6\": 3f3a6f6 is not in dotted-tri format" fetch-depth: 0 - - id: setup-go - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: - cache: false go-version: 1.23.x - - uses: ./.github/actions/setup_cache_for_go - with: - go-version: ${{ steps.setup-go.outputs.go-version }} runs-on: macos-12 - name: Unit tests run: go test -v ./... @@ -318,14 +308,9 @@ jobs: repository: abiosoft/colima ref: ${{ matrix.colima-version }} path: colima - - id: setup-go - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: - cache: false go-version: 1.23.x - - uses: ./.github/actions/setup_cache_for_go - with: - go-version: ${{ steps.setup-go.outputs.go-version }} runs-on: macos-12 working-directory: ./colima - name: Install colima @@ -419,14 +404,9 @@ jobs: path: homebrew-core fetch-depth: 0 filter: tree:0 - - id: setup-go - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: - cache: false go-version: 1.23.x - - uses: ./.github/actions/setup_cache_for_go - with: - go-version: ${{ steps.setup-go.outputs.go-version }} runs-on: macos-12 - name: Cache image used by ${{ matrix.oldver }}/examples/ubuntu-lts.yaml uses: ./.github/actions/setup_cache_for_template From 20ff23586087deea4613c8189b33479cbe394078 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 2 Sep 2024 19:55:42 +0900 Subject: [PATCH 04/14] setup_go_with_cache: change from `realpath go.sum` Because macos-12 does not have `realpath`. Signed-off-by: Norio Nomura --- .github/actions/setup_go_with_cache/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index ee45389a245..428c4405156 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -25,7 +25,7 @@ runs: run: | echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT echo "GOMOD=$(go env GOMOD)" >> $GITHUB_OUTPUT - echo "GOSUM=$(realpath go.sum)" >> $GITHUB_OUTPUT + echo "GOSUM=$(go env GOMOD|sed 's/\.mod$/.sum/')" >> $GITHUB_OUTPUT shell: bash working-directory: ${{ inputs.working-directory }} - name: Cache go modules From 92dfa09c5802292e280776a3e89b3689aa856cbb Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 3 Sep 2024 11:40:16 +0900 Subject: [PATCH 05/14] setup_go_with_cache: support windows Signed-off-by: Norio Nomura --- .github/actions/setup_go_with_cache/action.yml | 5 +++++ .github/workflows/test.yml | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index 428c4405156..88cc14ba6e4 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -19,8 +19,13 @@ runs: cache: false go-version: ${{ inputs.go-version }} - name: Set GOMODCACHE environment variable + if: runner.os != 'Windows' run: echo "GOMODCACHE=$(pwd)/.gomodcache" >> $GITHUB_ENV shell: bash + - name: Set GOMODCACHE environment variable on Windows + if: runner.os == 'Windows' + run: echo "GOMODCACHE=$(cygpath -w $(pwd)/.gomodcache)" >> $GITHUB_ENV + shell: bash - id: go-env run: | echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fd767279098..e63dcea9963 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,9 +131,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: go-version: 1.23.x + runs-on: windows-2022-8-cores - name: Unit tests run: go test -v ./... - name: Make From 83bbca64808b36370ca129a07a2fc6b0a2e9e057 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 3 Sep 2024 11:47:43 +0900 Subject: [PATCH 06/14] setup_go_with_cache: add `additional-cache-key` option to support variation of build Signed-off-by: Norio Nomura --- .../actions/setup_go_with_cache/action.yml | 21 ++++++++++++------- .github/workflows/release.yml | 8 +++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index 88cc14ba6e4..6455d3df29c 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -1,6 +1,9 @@ name: setup go with cache description: setup go with cache. export GOMODCACHE environment variable inputs: + additional-cache-key: + description: additional cache key + required: false go-version: description: go version required: true @@ -33,24 +36,28 @@ runs: echo "GOSUM=$(go env GOMOD|sed 's/\.mod$/.sum/')" >> $GITHUB_OUTPUT shell: bash working-directory: ${{ inputs.working-directory }} + - id: base-key + run: | + echo "gomodcache-key=go-modcache-${{ inputs.working-directory }}-${{ inputs.additional-cache-key }}" >> $GITHUB_OUTPUT + echo "gocache-key=go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.additional-cache-key }}" >> $GITHUB_OUTPUT + shell: bash - name: Cache go modules uses: actions/cache@v4 with: path: .gomodcache - key: go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }} + key: ${{ steps.base-key.outputs.gomodcache-key }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }} restore-keys: | - go-modcache-${{ inputs.working-directory }}-${{ steps.setup-go.outputs.go-version }}- - go-modcache-${{ inputs.working-directory }}- + ${{ steps.base-key.outputs.gomodcache-key }}-${{ steps.setup-go.outputs.go-version }}- + ${{ steps.base-key.outputs.gomodcache-key }}- enableCrossOsArchive: true - name: Cache go build cache uses: actions/cache@v4 with: path: ${{ steps.go-env.outputs.GOCACHE }} - key: go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} + key: ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} restore-keys: | - go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ steps.setup-go.outputs.go-version }}- - go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}- - go-cache-${{ inputs.working-directory }}- + ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}- + ${{ steps.base-key.outputs.gocache-key }}- - name: Download dependencies run: go mod download -x shell: bash diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2bc463a296f..2f5e11732c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,9 +28,11 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 1 - - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: release go-version: 1.23.x + runs-on: macos-12 - name: Make darwin artifacts run: make artifacts-darwin - name: "Upload artifacts" @@ -55,9 +57,11 @@ jobs: with: name: artifacts-darwin path: _artifacts/ - - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: release go-version: 1.23.x + runs-on: ubuntu-20.04 - name: Install gcc-x86-64-linux-gnu run: | sudo apt-get update From b0a2df2d8147b66d40feff12277592dca1b54ad1 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 3 Sep 2024 11:49:14 +0900 Subject: [PATCH 07/14] setup_go_with_cache: add `ignore-go-mod-and-go-sum` option to support job that does not use `go.mod` and `go.sum` Signed-off-by: Norio Nomura --- .github/actions/setup_go_with_cache/action.yml | 18 ++++++++++++++++-- .github/workflows/test.yml | 5 ++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index 6455d3df29c..2ab81a3c677 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -7,6 +7,9 @@ inputs: go-version: description: go version required: true + ignore-go-mod-and-go-sum: + description: ignore go.mod and go.sum if true + required: false runs-on: description: runs on required: true @@ -32,8 +35,18 @@ runs: - id: go-env run: | echo "GOCACHE=$(go env GOCACHE)" >> $GITHUB_OUTPUT - echo "GOMOD=$(go env GOMOD)" >> $GITHUB_OUTPUT - echo "GOSUM=$(go env GOMOD|sed 's/\.mod$/.sum/')" >> $GITHUB_OUTPUT + if [[ "${{ inputs.ignore-go-mod-and-go-sum }}" == "true" ]]; then + echo "GOMOD=" >> $GITHUB_OUTPUT + echo "GOSUM=" >> $GITHUB_OUTPUT + else + GOMOD=$(go env GOMOD) + case $GOMOD in + /dev/null|NUL) GOMOD= ;; + esac + GOSUM=${GOMOD/%.mod/.sum} + echo "GOMOD=${GOMOD}" >> $GITHUB_OUTPUT + echo "GOSUM=${GOSUM}" >> $GITHUB_OUTPUT + fi shell: bash working-directory: ${{ inputs.working-directory }} - id: base-key @@ -59,6 +72,7 @@ runs: ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}- ${{ steps.base-key.outputs.gocache-key }}- - name: Download dependencies + if: inputs.ignore-go-mod-and-go-sum != 'true' run: go mod download -x shell: bash working-directory: ${{ inputs.working-directory }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e63dcea9963..e3b2099f5fe 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,9 +27,12 @@ jobs: with: # To avoid "failed to load YAML file \"templates/experimental/riscv64.yaml\": can't parse builtin Lima version \"3f3a6f6\": 3f3a6f6 is not in dotted-tri format" fetch-depth: 0 - - uses: actions/setup-go@v5 + - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: lints go-version: 1.23.x + ignore-go-mod-and-go-sum: true + runs-on: ubuntu-24.04 - name: Install protoc run: | sudo apt-get update From 92be5cab9107dc58fa28435961e663d33493192e Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Tue, 3 Sep 2024 12:17:19 +0900 Subject: [PATCH 08/14] test.yml: stop using `setup_go_with_cache` on `lints` job to avoid linters detect from `.gomodcache` Signed-off-by: Norio Nomura --- .github/workflows/test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e3b2099f5fe..4b758c3a664 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,12 +27,10 @@ jobs: with: # To avoid "failed to load YAML file \"templates/experimental/riscv64.yaml\": can't parse builtin Lima version \"3f3a6f6\": 3f3a6f6 is not in dotted-tri format" fetch-depth: 0 - - uses: ./.github/actions/setup_go_with_cache + - uses: actions/setup-go@v5 with: - additional-cache-key: lints + cache-dependency-path: "" # disable using hash for cache key go-version: 1.23.x - ignore-go-mod-and-go-sum: true - runs-on: ubuntu-24.04 - name: Install protoc run: | sudo apt-get update From 7ee0addabece40a4698201a2ecea244f13e4ed49 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Sun, 8 Sep 2024 19:42:32 +0900 Subject: [PATCH 09/14] test.yml: use `setup_go_with_cache` on `vmnet` test Signed-off-by: Norio Nomura --- .github/workflows/test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4b758c3a664..1b3a566a826 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -374,6 +374,11 @@ jobs: sudo make PREFIX=/opt/socket_vmnet install ) limactl sudoers | sudo tee /etc/sudoers.d/lima + - uses: ./.github/actions/setup_go_with_cache + with: + additional-cache-key: vmnet + go-version: 1.23.x + runs-on: macos-12 - name: Unit test (pkg/networks) with socket_vmnet # Set -count=1 to disable cache run: go test -v -count=1 ./pkg/networks/... From 583334d2852112777a46abd9078ca9851a8865fb Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Sun, 8 Sep 2024 20:17:33 +0900 Subject: [PATCH 10/14] test.yml: set `additional-cache-key` to jobs executing `go test` Signed-off-by: Norio Nomura --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b3a566a826..d476fc6e5b4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,6 +85,7 @@ jobs: fetch-depth: 1 - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: unit go-version: ${{ matrix.go-version }} runs-on: ubuntu-24.04 - name: Unit tests @@ -134,6 +135,7 @@ jobs: fetch-depth: 1 - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: windows go-version: 1.23.x runs-on: windows-2022-8-cores - name: Unit tests @@ -172,6 +174,7 @@ jobs: fetch-depth: 0 - uses: ./.github/actions/setup_go_with_cache with: + additional-cache-key: integration go-version: 1.23.x runs-on: macos-12 - name: Unit tests From b130698487c510f543c517c3729e1f93ab73ccd0 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 9 Sep 2024 12:44:15 +0900 Subject: [PATCH 11/14] setup_go_with_cache: change `additional-cache-key` to `additional-gocache-key` and remove additional cache key from `gomodcache-key` Signed-off-by: Norio Nomura --- .github/actions/setup_go_with_cache/action.yml | 8 ++++---- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index 2ab81a3c677..1f96337362e 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -1,8 +1,8 @@ name: setup go with cache description: setup go with cache. export GOMODCACHE environment variable inputs: - additional-cache-key: - description: additional cache key + additional-gocache-key: + description: additional cache key for GOCACHE required: false go-version: description: go version @@ -51,8 +51,8 @@ runs: working-directory: ${{ inputs.working-directory }} - id: base-key run: | - echo "gomodcache-key=go-modcache-${{ inputs.working-directory }}-${{ inputs.additional-cache-key }}" >> $GITHUB_OUTPUT - echo "gocache-key=go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.additional-cache-key }}" >> $GITHUB_OUTPUT + echo "gomodcache-key=go-modcache-${{ inputs.working-directory }}" >> $GITHUB_OUTPUT + echo "gocache-key=go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.additional-gocache-key }}" >> $GITHUB_OUTPUT shell: bash - name: Cache go modules uses: actions/cache@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2f5e11732c2..5549b711132 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -30,7 +30,7 @@ jobs: fetch-depth: 1 - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: release + additional-gocache-key: release go-version: 1.23.x runs-on: macos-12 - name: Make darwin artifacts @@ -59,7 +59,7 @@ jobs: path: _artifacts/ - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: release + additional-gocache-key: release go-version: 1.23.x runs-on: ubuntu-20.04 - name: Install gcc-x86-64-linux-gnu diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d476fc6e5b4..6879321abb1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -85,7 +85,7 @@ jobs: fetch-depth: 1 - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: unit + additional-gocache-key: unit go-version: ${{ matrix.go-version }} runs-on: ubuntu-24.04 - name: Unit tests @@ -135,7 +135,7 @@ jobs: fetch-depth: 1 - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: windows + additional-gocache-key: windows go-version: 1.23.x runs-on: windows-2022-8-cores - name: Unit tests @@ -174,7 +174,7 @@ jobs: fetch-depth: 0 - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: integration + additional-gocache-key: integration go-version: 1.23.x runs-on: macos-12 - name: Unit tests @@ -379,7 +379,7 @@ jobs: limactl sudoers | sudo tee /etc/sudoers.d/lima - uses: ./.github/actions/setup_go_with_cache with: - additional-cache-key: vmnet + additional-gocache-key: vmnet go-version: 1.23.x runs-on: macos-12 - name: Unit test (pkg/networks) with socket_vmnet From c2a104165c5c560225ea0c7bf01fa2a330236ae7 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Wed, 11 Sep 2024 10:44:48 +0900 Subject: [PATCH 12/14] test.yml: try to unify caches on `make` and `go test` Signed-off-by: Norio Nomura --- .github/workflows/build.yml | 55 --------------- .../workflows/build_lima_and_fill_cache.yml | 70 +++++++++++++++++++ .github/workflows/test.yml | 37 +++++----- 3 files changed, 90 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/build_lima_and_fill_cache.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 7576f9d92e1..00000000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,55 +0,0 @@ -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.23.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: ./.github/actions/setup_go_with_cache - with: - go-version: ${{ inputs.go-version }} - runs-on: ${{ inputs.runs-on }} - - 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 }} diff --git a/.github/workflows/build_lima_and_fill_cache.yml b/.github/workflows/build_lima_and_fill_cache.yml new file mode 100644 index 00000000000..c23f5dde0f7 --- /dev/null +++ b/.github/workflows/build_lima_and_fill_cache.yml @@ -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 }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6879321abb1..7d610ed74a0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -68,6 +68,7 @@ jobs: unit: name: "Unit tests" + needs: build-lima-and-fill-cache-on-ubuntu runs-on: ubuntu-24.04 timeout-minutes: 30 strategy: @@ -85,7 +86,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 @@ -135,7 +135,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 @@ -156,15 +155,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: @@ -174,7 +175,6 @@ jobs: fetch-depth: 0 - uses: ./.github/actions/setup_go_with_cache with: - additional-gocache-key: integration go-version: 1.23.x runs-on: macos-12 - name: Unit tests @@ -221,17 +221,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: @@ -254,7 +255,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: @@ -288,7 +289,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: @@ -306,7 +307,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: @@ -344,7 +345,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: @@ -353,7 +354,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 @@ -397,6 +398,7 @@ jobs: upgrade: name: "Upgrade test" + needs: build-lima-and-fill-cache-on-macos-12 runs-on: macos-12 timeout-minutes: 120 strategy: @@ -438,15 +440,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 @@ -462,7 +465,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: From 96d5f7ae0c5cfaba31f7638352e87f4f3b76e870 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Wed, 11 Sep 2024 11:06:08 +0900 Subject: [PATCH 13/14] setup_go_with_cache: change `restore-keys` for `go build cache` to include `go-version` restoring cache from different go version seems not efficient. Signed-off-by: Norio Nomura --- .github/actions/setup_go_with_cache/action.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/actions/setup_go_with_cache/action.yml b/.github/actions/setup_go_with_cache/action.yml index 1f96337362e..a00172a73cf 100644 --- a/.github/actions/setup_go_with_cache/action.yml +++ b/.github/actions/setup_go_with_cache/action.yml @@ -51,9 +51,14 @@ runs: working-directory: ${{ inputs.working-directory }} - id: base-key run: | - echo "gomodcache-key=go-modcache-${{ inputs.working-directory }}" >> $GITHUB_OUTPUT - echo "gocache-key=go-cache-${{ inputs.working-directory }}-${{ inputs.runs-on }}-${{ inputs.additional-gocache-key }}" >> $GITHUB_OUTPUT + echo "gomodcache-key=go-modcache-${WORKING_DIRECTORY}" >> $GITHUB_OUTPUT + echo "gocache-key=go-cache-${WORKING_DIRECTORY}-${RUNS_ON}-${ADDITIONAL_GOCACHE_KEY}-${GO_VERSION}" >> $GITHUB_OUTPUT shell: bash + env: + ADDITIONAL_GOCACHE_KEY: ${{ inputs.additional-gocache-key }} + GO_VERSION: ${{ steps.setup-go.outputs.go-version }} + RUNS_ON: ${{ inputs.runs-on }} + WORKING_DIRECTORY: ${{ inputs.working-directory }} - name: Cache go modules uses: actions/cache@v4 with: @@ -67,9 +72,8 @@ runs: uses: actions/cache@v4 with: path: ${{ steps.go-env.outputs.GOCACHE }} - key: ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} + key: ${{ steps.base-key.outputs.gocache-key }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }} restore-keys: | - ${{ steps.base-key.outputs.gocache-key }}-${{ steps.setup-go.outputs.go-version }}- ${{ steps.base-key.outputs.gocache-key }}- - name: Download dependencies if: inputs.ignore-go-mod-and-go-sum != 'true' From 5212030dfd4cf9a52bee7e7d979a2662c8677dea Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 16 Sep 2024 13:30:46 +0900 Subject: [PATCH 14/14] build_lima_and_fill_cache.yml: use architecture variation of artifacts target on make Signed-off-by: Norio Nomura --- .github/workflows/build_lima_and_fill_cache.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_lima_and_fill_cache.yml b/.github/workflows/build_lima_and_fill_cache.yml index c23f5dde0f7..d7c33346184 100644 --- a/.github/workflows/build_lima_and_fill_cache.yml +++ b/.github/workflows/build_lima_and_fill_cache.yml @@ -32,11 +32,6 @@ jobs: 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 @@ -45,16 +40,16 @@ jobs: run: | case "${RUNNER_OS}" in Linux) - make artifacts-linux VERSION_TRIMMED="${RUNS_ON}" + make artifact-linux-$(uname -m) VERSION_TRIMMED="${RUNS_ON}" artifact=lima-${RUNS_ON}-Linux-$(uname -m).tar.gz ;; macOS) - make artifacts-darwin VERSION_TRIMMED="${RUNS_ON}" + make artifact-darwin-$(uname -m) 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 + make artifact-windows-$(uname -m) VERSION_TRIMMED="${RUNS_ON}" + artifact=lima-${RUNS_ON}-Windows-$(uname -m).tar.gz ;; *) echo "Unsupported OS: ${RUNNER_OS}"