Skip to content

Commit

Permalink
Improve caching for go actions, add go build cache (#2519)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Feb 24, 2021
1 parent 4ab3625 commit 5c1c1ce
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 31 deletions.
74 changes: 44 additions & 30 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
shell: bash
- name: Cache Go Modules
- name: Cache Go
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: \Users\runneradmin\go\pkg\mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
\Users\runneradmin\go\pkg\mod
%LocalAppData%\go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod', '**/go.sum') }}
- name: Run Unit tests
run: go test ./...
- name: GitHub Issue Generator
Expand All @@ -51,17 +53,21 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod') }}
- name: Download dependencies
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Install dependencies
if: steps.module-cache.outputs.cache-hit != 'true'
run: go mod download
run: |
make gomoddownload
make gotestinstall
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -90,13 +96,16 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -129,13 +138,16 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -170,13 +182,16 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -211,13 +226,16 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -267,13 +285,16 @@ jobs:
run: |
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
- name: Cache Go Modules
- name: Cache Go
id: module-cache
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: /home/runner/go/pkg/mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
path: |
/home/runner/go/pkg/mod
/home/runner/.cache/go-build
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
- name: Cache Tools
id: tool-cache
uses: actions/cache@v2
Expand Down Expand Up @@ -365,13 +386,6 @@ jobs:
echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV
echo "$(go env GOPATH)/bin" >> $GITHUB_PATH
mkdir bin/
- name: Cache Go Modules
uses: actions/cache@v2
env:
cache-name: cache-go-modules
with:
path: \Users\runneradmin\go\pkg\mod
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('./go.mod') }}
- name: Download Binaries
uses: actions/download-artifact@v1
with:
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ testbed-list-correctness-metrics:
testbed-correctness-metrics: otelcol
cd ./testbed/correctness/metrics && ./runtests.sh

.PHONY: gomoddownload
gomoddownload:
@$(MAKE) for-all CMD="go mod download"

.PHONY: gotestinstall
gotestinstall:
@$(MAKE) for-all CMD="make test GOTEST_OPT=\"-i\""

.PHONY: gotest
gotest:
@$(MAKE) for-all CMD="make test"
Expand Down
1 change: 0 additions & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ all-license-srcs:

.PHONY: test
test:
@echo "running go unit test ./... in `pwd`"
@echo $(ALL_PKGS) | xargs -n 10 $(GOTEST) $(GOTEST_OPT)

.PHONY: benchmark
Expand Down

0 comments on commit 5c1c1ce

Please sign in to comment.