refactor: add sharable action to setup go
Some checks failed
CI / test (pull_request) Failing after 3s

This commit is contained in:
2024-04-01 14:50:53 +02:00
parent ffa8e73d53
commit 07412bf6c6
2 changed files with 45 additions and 20 deletions

View File

@@ -0,0 +1,43 @@
# Re-Usable action that setups go from cache. Can be used in e.g. workflows/ci.yaml
# setups go from cache or installs go if not found in cache
# also updates the cache
name: setup_go_from_cache
description: 'Setup go from cache'
inputs:
go-version-file:
description: 'Path to go version file'
required: true
check-latest:
description: 'Check for latest go version'
required: false
default: 'true'
runs:
using: 'composite'
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: ${{ inputs.go-version-file }}
check-latest: ${{ inputs.check-latest }}
- name: Create cache key
id: hash-go
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
with:
patterns: |
go.mod
go.sum
- name: cache go
id: cache-go
uses: actions/cache@v4
with:
path: |
/go_path
/go_cache
key: go_path-${{ steps.hash-go.outputs.hash }}
restore-keys: |-
go_cache-${{ steps.hash-go.outputs.hash }}

View File

@@ -14,28 +14,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
- name: setup_go_from_cache
uses: ./.gitea/actions/setup_go_from_cache
with:
go-version-file: go.mod
check-latest: true
- name: Create cache key
uses: https://gitea.com/actions/go-hashfiles@v0.0.1
id: hash-go
with:
patterns: |
go.mod
go.sum
- name: cache go
id: cache-go
uses: actions/cache@v4
with:
path: |
/go_path
/go_cache
key: go_path-${{ steps.hash-go.outputs.hash }}
restore-keys: |-
go_cache-${{ steps.hash-go.outputs.hash }}
- name: build
run: make build
- name: test