Skip to content

Commit

Permalink
setup_go_with_cache: migrate from actions/setup-go
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 2, 2024
1 parent 7cfcddd commit 5cf1f26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 36 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 4 additions & 24 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ./...
Expand Down Expand Up @@ -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 ./...
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5cf1f26

Please sign in to comment.