From 5cf1f26bf87db74dbb89ca35b6a597e37acfabc8 Mon Sep 17 00:00:00 2001 From: Norio Nomura Date: Mon, 2 Sep 2024 18:17:02 +0900 Subject: [PATCH] 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 ddbfe376fcbb..ee45389a2459 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 2db23fd73690..7576f9d92e17 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 969e534ad070..e59367283457 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -81,14 +81,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 ./... @@ -167,14 +162,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: 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 ./... @@ -312,14 +302,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 @@ -405,14 +390,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: 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