attempt local action for cache control (#1003)
## Description Attempting to fix cache control. ## Type of change - [x] 💻 CI/Deployment ## Issue(s) * #790 ## Test Plan - [x] 💪 Manual
This commit is contained in:
parent
c6a9d2feb6
commit
af12fba0c7
61
.github/actions/go-setup-cache/action.yml
vendored
Normal file
61
.github/actions/go-setup-cache/action.yml
vendored
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
name: Setup and Cache Golang
|
||||||
|
|
||||||
|
# clone of: https://github.com/magnetikonline/action-golang-cache/blob/main/action.yaml
|
||||||
|
#
|
||||||
|
# action-golang-cache runs an optimistic restore key prefix `${{runner.os}}-golang`.
|
||||||
|
# This causes the cache@v3 to restore from any preexisting module cache in the main
|
||||||
|
# branch, whether or not that the go.sum in that cache differs from the current branch's
|
||||||
|
# go.sum. IE: once a cache exists for the main branch, we will always re-use it.
|
||||||
|
#
|
||||||
|
# Problem is, the cache identifies that as a 'cache hit', and as a result it refuses to
|
||||||
|
# store any differences we downloaded or removed using the current go.sum. IE: once
|
||||||
|
# established, it always re-uses the old cache, and never updates it.
|
||||||
|
#
|
||||||
|
# This version will only match on exact caches, and will run `go mod download` on any
|
||||||
|
# cache miss. In a workflow with chained jobs, this action should be run prior to any
|
||||||
|
# jobs that build binaries (testing, linting, etc). Downstream jobs should still use
|
||||||
|
# the magnetikonline action, since some cache restoration is better than none.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
go-version:
|
||||||
|
description: Desired Golang version to use.
|
||||||
|
go-version-file:
|
||||||
|
description: Path to go.mod file, determines Golang version to use. Used in place of `go-version` input.
|
||||||
|
cache-key-suffix:
|
||||||
|
description: Optional cache key suffix.
|
||||||
|
default:
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- name: Setup Golang
|
||||||
|
uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: ${{ inputs.go-version }}
|
||||||
|
go-version-file: ${{ inputs.go-version-file }}
|
||||||
|
|
||||||
|
- name: Determine Golang cache paths
|
||||||
|
id: golang-path
|
||||||
|
run: |
|
||||||
|
echo "::set-output name=build::$(go env GOCACHE)"
|
||||||
|
echo "::set-output name=module::$(go env GOMODCACHE)"
|
||||||
|
shell: bash
|
||||||
|
|
||||||
|
- name: Setup Golang cache
|
||||||
|
id: cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
${{ steps.golang-path.outputs.build }}
|
||||||
|
${{ steps.golang-path.outputs.module }}
|
||||||
|
key: ${{ runner.os }}-golang${{ inputs.cache-key-suffix }}-${{ hashFiles('src/go.sum') }}
|
||||||
|
|
||||||
|
- name: Module Download and Test Compilation, for future caching
|
||||||
|
working-directory: src
|
||||||
|
if: steps.cache.outputs.cache-hit != 'true'
|
||||||
|
# cover all the bases, just to be make sure we loaded everything we'll use
|
||||||
|
run: |
|
||||||
|
go mod download -v
|
||||||
|
go build -o compile
|
||||||
|
go test -v -c -o compile_test
|
||||||
|
shell: bash
|
||||||
6
.github/workflows/ci.yml
vendored
6
.github/workflows/ci.yml
vendored
@ -33,12 +33,10 @@ jobs:
|
|||||||
working-directory: src
|
working-directory: src
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
# single setup and sum cache handling here.
|
|
||||||
# the results will cascade onto both testing and linting.
|
|
||||||
- name: Setup Golang with cache
|
- name: Setup Golang with cache
|
||||||
if: needs.precheck.outputs.fileschanged == 'true'
|
if: needs.precheck.outputs.fileschanged == 'true'
|
||||||
uses: magnetikonline/action-golang-cache@v3
|
uses: ./.github/actions/go-setup-cache
|
||||||
with:
|
with:
|
||||||
go-version-file: src/go.mod
|
go-version-file: src/go.mod
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user