Skip to content

Commit

Permalink
Merge cache for go mod and tools. go mod cache already got invalidate…
Browse files Browse the repository at this point in the history
…d when tools changed (#5329)

Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed May 10, 2022
1 parent 79911de commit e436314
Showing 1 changed file with 32 additions and 56 deletions.
88 changes: 32 additions & 56 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,18 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Install dependencies
if: steps.module-cache.outputs.cache-hit != 'true'
if: steps.go-cache.outputs.cache-hit != 'true'
run: make gomoddownload
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
- name: Install Tools
if: steps.tool-cache.outputs.cache-hit != 'true'
if: steps.go-cache.outputs.cache-hit != 'true'
run: make install-tools
lint:
runs-on: ubuntu-latest
Expand All @@ -53,17 +49,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: golint
run: make -j2 golint
- name: goimpi
Expand All @@ -84,17 +76,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: checklicense
run: make checklicense
- name: misspell
Expand Down Expand Up @@ -141,17 +129,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Build
uses: actions/cache@v3
with:
Expand All @@ -174,17 +158,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Build
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -237,17 +217,13 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go
id: module-cache
uses: actions/cache@v3
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Cache Tools
id: tool-cache
id: go-cache
uses: actions/cache@v3
with:
path: /home/runner/go/bin
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
path: |
/home/runner/go/bin
/home/runner/go/pkg/mod
key: go-cache-${{ runner.os }}-${{ hashFiles('**/go.sum') }}
- name: Build
env:
GOOS: ${{matrix.goos}}
Expand Down

0 comments on commit e436314

Please sign in to comment.