Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): use composite actions for Go build cache #213

Merged
merged 1 commit into from May 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/actions/setup-go-with-cache/action.yml
@@ -0,0 +1,30 @@
name: 'Set up Go'
description: 'Install Go and set up cache'
inputs:
cache-key-prefix:
description: 'Cache key prefix'
required: false
default: setup-go-with-cache-${{ github.workflow }}-${{ github.job }}
runs:
using: composite
steps:
- name: Install Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
- name: Get Go cache paths
id: go-cache
shell: bash
run: |
echo "::set-output name=cache::$(go env GOCACHE)"
echo "::set-output name=modcache::$(go env GOMODCACHE)"
- name: Set up Go cache
uses: actions/cache@v3.0.2
with:
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ inputs.cache-key-prefix }}-${{ runner.os }}-${{ github.run_id }}-
${{ inputs.cache-key-prefix }}-${{ runner.os }}-
path: |
${{ steps.go-cache.outputs.cache }}
${{ steps.go-cache.outputs.modcache }}
27 changes: 27 additions & 0 deletions .github/actions/setup-golangci-lint/action.yml
@@ -0,0 +1,27 @@
name: 'Set up golangci-lint'
description: 'Install golangci-lint and set up cache'
inputs:
cache-key-prefix:
description: 'Cache key prefix'
required: false
default: setup-golangci-lint-${{ github.workflow }}-${{ github.job }}
runs:
using: composite
steps:
- name: Install golangci-lint
shell: bash
run: |
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
- name: Get golangci-lint cache path
id: golangci-lint-cache-status
shell: bash
run: |
echo "::set-output name=dir::$(golangci-lint cache status | head -1 | sed 's/^Dir: //')"
- name: Set up golangci-lint cache
uses: actions/cache@v3.0.2
with:
key: ${{ inputs.cache-key-prefix }}-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }}
restore-keys: |
${{ inputs.cache-key-prefix }}-${{ runner.os }}-${{ github.run_id }}-
${{ inputs.cache-key-prefix }}-${{ runner.os }}-
path: ${{ steps.golangci-lint-cache-status.outputs.dir }}
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Expand Up @@ -5,6 +5,16 @@ updates:
schedule:
interval: daily

# See https://github.com/dependabot/dependabot-core/issues/4178#issuecomment-1118492006
- package-ecosystem: github-actions
directory: "/.github/actions/setup-go-with-cache"
schedule:
interval: daily
- package-ecosystem: github-actions
directory: "/.github/actions/setup-golangci-lint"
schedule:
interval: daily

# find . -name go.mod | sort | sed 's/^\.\(.*\)\/go.mod$/ - package-ecosystem: gomod\n directory: "\1"\n schedule:\n interval: daily/'
- package-ecosystem: gomod
directory: "/awsenv"
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Expand Up @@ -18,10 +18,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.0.2
- name: Set up Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
cache: true
cache-dependency-path: '**/go.sum'
uses: ./.github/actions/setup-go-with-cache
- name: Run tests
run: go test -race go.pact.im/x/...
6 changes: 1 addition & 5 deletions .github/workflows/deps.yml
Expand Up @@ -21,11 +21,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.0.2
- name: Set up Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
cache: true
cache-dependency-path: '**/go.sum'
uses: ./.github/actions/setup-go-with-cache
- name: Update dependencies
run: |
goget() {
Expand Down
20 changes: 3 additions & 17 deletions .github/workflows/lint.yml
Expand Up @@ -11,23 +11,9 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.0.2
- name: Set up Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
cache: true
cache-dependency-path: '**/go.sum'
- name: Install golangci-lint
run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.46.2
- name: Get golangci-lint cache path
id: golangci-lint-cache-status
run: |
echo "::set-output name=dir::$(golangci-lint cache status | head -1 | sed 's/^Dir: //')"
- name: Set up golangci-lint cache
uses: actions/cache@v3.0.2
with:
key: golangci-lint-${{ runner.os }}-golangci-lint-${{ hashFiles('**/go.mod') }}
restore-keys: golangci-lint-${{ runner.os }}-golangci-lint-
path: ${{ steps.golangci-lint-cache-status.outputs.dir }}
uses: ./.github/actions/setup-go-with-cache
- name: Set up golangci-lint
uses: ./.github/actions/setup-golangci-lint
- name: Run golangci-lint
run: |
golangci-lint run --out-format=github-actions -- \
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/pages.yml
Expand Up @@ -15,11 +15,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.0.2
- name: Set up Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
cache: true
cache-dependency-path: '**/go.sum'
uses: ./.github/actions/setup-go-with-cache
- name: Install vangen
run: go install 4d63.com/vangen@v1.2.0
- name: Install golds
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/tidy.yml
Expand Up @@ -11,11 +11,7 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3.0.2
- name: Set up Go
uses: actions/setup-go@v3.2.0
with:
go-version-file: .go-version
cache: true
cache-dependency-path: '**/go.sum'
uses: ./.github/actions/setup-go-with-cache
- name: Install mockgen
run: go install github.com/golang/mock/mockgen@v1.6.0
- name: Run go mod tidy
Expand Down