Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test.yml: separate the job for building lima from the matrix test jobs to avoid duplicate builds under the same conditions. #2532

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
82 changes: 82 additions & 0 deletions .github/actions/setup_go_with_cache/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: setup go with cache
description: setup go with cache. export GOMODCACHE environment variable
inputs:
additional-gocache-key:
description: additional cache key for GOCACHE
required: false
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
working-directory:
description: working directory
default: '.'
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
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
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
run: |
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:
path: .gomodcache
key: ${{ steps.base-key.outputs.gomodcache-key }}-${{ steps.setup-go.outputs.go-version }}-${{ hashFiles(steps.go-env.outputs.GOMOD) }}
restore-keys: |
${{ 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: ${{ steps.base-key.outputs.gocache-key }}-${{ hashFiles(steps.go-env.outputs.GOSUM) }}
restore-keys: |
${{ 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 }}
65 changes: 65 additions & 0 deletions .github/workflows/build_lima_and_fill_cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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: 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 artifact-linux-$(uname -m) VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Linux-$(uname -m).tar.gz
;;
macOS)
make artifact-darwin-$(uname -m) VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Darwin-$(uname -m).tar.gz
;;
Windows)
make artifact-windows-$(uname -m) VERSION_TRIMMED="${RUNS_ON}"
artifact=lima-${RUNS_ON}-Windows-$(uname -m).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 }}
8 changes: 6 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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-gocache-key: release
go-version: 1.23.x
runs-on: macos-12
- name: Make darwin artifacts
run: make artifacts-darwin
- name: "Upload artifacts"
Expand All @@ -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-gocache-key: release
go-version: 1.23.x
runs-on: ubuntu-20.04
- name: Install gcc-x86-64-linux-gnu
run: |
sudo apt-get update
Expand Down
Loading
Loading