Cache Go dependencies and detect Go version in GitHub Action workflows (#52)

This commit is contained in:
Jonathan Ruckwood 2022-06-01 15:02:17 +01:00 committed by GitHub
parent 3b7018c581
commit ad648861b4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 19 deletions

View File

@ -13,12 +13,6 @@ on:
permissions: permissions:
contents: write contents: write
# Default values to simplify job configurations below.
env:
# Go language version to use for building. This value should also be updated
# in the testing workflow if changed.
GO_VERSION: '1.17'
jobs: jobs:
goreleaser: goreleaser:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -29,7 +23,8 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-go@v3 - uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version-file: 'go.mod'
cache: true
# This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your # This uses an action (hashicorp/ghaction-import-gpg) that assumes you set your
# private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE` # private key in the `GPG_PRIVATE_KEY` secret and passphrase in the `PASSPHRASE`
# secret. If you would rather own your own GPG handling, please fork this action # secret. If you would rather own your own GPG handling, please fork this action

View File

@ -15,12 +15,6 @@ on:
permissions: permissions:
contents: read contents: read
# Default values to simplify job configurations below.
env:
# Go language version to use for building. This value should also be updated
# in the release workflow if changed.
GO_VERSION: '1.17'
jobs: jobs:
# Ensure project builds before running testing matrix # Ensure project builds before running testing matrix
build: build:
@ -28,20 +22,22 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
timeout-minutes: 5 timeout-minutes: 5
steps: steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3 - uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version-file: 'go.mod'
- uses: actions/checkout@v3 cache: true
- run: go mod download - run: go mod download
- run: go build -v . - run: go build -v .
generate: generate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3 - uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version-file: 'go.mod'
- uses: actions/checkout@v3 cache: true
- run: go generate ./... - run: go generate ./...
- name: git diff - name: git diff
run: | run: |
@ -62,14 +58,15 @@ jobs:
- '1.0.*' - '1.0.*'
- '1.1.*' - '1.1.*'
steps: steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3 - uses: actions/setup-go@v3
with: with:
go-version: ${{ env.GO_VERSION }} go-version-file: 'go.mod'
cache: true
- uses: hashicorp/setup-terraform@v2 - uses: hashicorp/setup-terraform@v2
with: with:
terraform_version: ${{ matrix.terraform }} terraform_version: ${{ matrix.terraform }}
terraform_wrapper: false terraform_wrapper: false
- uses: actions/checkout@v3
- run: go mod download - run: go mod download
- env: - env:
TF_ACC: "1" TF_ACC: "1"