lnd/.github/actions/setup-go/action.yml
Oliver Gugger dc64ea97a2
GitHub: remove duplicate caching
Turns out that actions/setup-go starting with @v4 also adds caching.
With that, our cache size on disk has almost doubled, leading to the
GitHub runner running out of space in certain situation.
We fix that by disabling the automated caching since we already have our
own, custom-tailored version.
2025-02-20 18:14:29 +01:00

61 lines
2.2 KiB
YAML

name: "Setup Golang environment"
description: "A reusable workflow that's used to set up the Go environment and cache."
inputs:
go-version:
description: "The version of Golang to set up"
required: true
key-prefix:
description: "A prefix to use for the cache key, to separate cache entries from other workflows"
required: false
use-build-cache:
description: "Whether to use the build cache"
required: false
# Boolean values aren't supported in the workflow syntax, so we use a
# string. To not confuse the value with true/false, we use 'yes' and 'no'.
default: 'yes'
runs:
using: "composite"
steps:
- name: setup go ${{ inputs.go-version }}
uses: actions/setup-go@v5
with:
go-version: '${{ inputs.go-version }}'
cache: 'false'
- name: go cache
if: ${{ inputs.use-build-cache == 'yes' }}
uses: actions/cache@v4
with:
# In order:
# * Module download cache
# * Build cache (Linux)
# * Build cache (Mac)
# * Build cache (Windows)
path: |
~/go/pkg/mod
~/.cache/go-build
~/Library/Caches/go-build
~\AppData\Local\go-build
key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-${{ github.job }}-
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-
- name: go module cache
if: ${{ inputs.use-build-cache == 'no' }}
uses: actions/cache@v4
with:
# Just the module download cache.
path: |
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-${{ github.job }}-
${{ runner.os }}-go-${{ inputs.go-version }}-${{ inputs.key-prefix }}-no-build-cache-
- name: set GOPATH
shell: bash
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV