Skip to content

Commit 5abd73a

Browse files
authored
Move cache/go-build in a different cache to allow unittest/coverage to use it (#4289)
Signed-off-by: Bogdan Drutu <[email protected]>
1 parent 72e4e3f commit 5abd73a

File tree

1 file changed

+15
-33
lines changed

1 file changed

+15
-33
lines changed

.github/workflows/build-and-test.yml

+15-33
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,15 @@ jobs:
2727
- name: Cache Go
2828
id: module-cache
2929
uses: actions/cache@v2
30-
env:
31-
cache-name: cache-go-modules
3230
with:
33-
path: |
34-
/home/runner/go/pkg/mod
35-
/home/runner/.cache/go-build
31+
path: /home/runner/go/pkg/mod
3632
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
3733
- name: Install dependencies
3834
if: steps.module-cache.outputs.cache-hit != 'true'
3935
run: make gomoddownload
4036
- name: Cache Tools
4137
id: tool-cache
4238
uses: actions/cache@v2
43-
env:
44-
cache-name: cache-tool-binaries
4539
with:
4640
path: /home/runner/go/bin
4741
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
@@ -65,18 +59,12 @@ jobs:
6559
- name: Cache Go
6660
id: module-cache
6761
uses: actions/cache@v2
68-
env:
69-
cache-name: cache-go-modules
7062
with:
71-
path: |
72-
/home/runner/go/pkg/mod
73-
/home/runner/.cache/go-build
63+
path: /home/runner/go/pkg/mod
7464
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
7565
- name: Cache Tools
7666
id: tool-cache
7767
uses: actions/cache@v2
78-
env:
79-
cache-name: cache-tool-binaries
8068
with:
8169
path: /home/runner/go/bin
8270
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
@@ -113,21 +101,20 @@ jobs:
113101
- name: Cache Go
114102
id: module-cache
115103
uses: actions/cache@v2
116-
env:
117-
cache-name: cache-go-modules
118104
with:
119-
path: |
120-
/home/runner/go/pkg/mod
121-
/home/runner/.cache/go-build
105+
path: /home/runner/go/pkg/mod
122106
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
123107
- name: Cache Tools
124108
id: tool-cache
125109
uses: actions/cache@v2
126-
env:
127-
cache-name: cache-tool-binaries
128110
with:
129111
path: /home/runner/go/bin
130112
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
113+
- name: Cache Build
114+
uses: actions/cache@v2
115+
with:
116+
path: /home/runner/.cache/go-build
117+
key: go-build-unittest-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
131118
- name: Run Unit Tests
132119
run: make gotest
133120
test-coverage:
@@ -147,21 +134,20 @@ jobs:
147134
- name: Cache Go
148135
id: module-cache
149136
uses: actions/cache@v2
150-
env:
151-
cache-name: cache-go-modules
152137
with:
153-
path: |
154-
/home/runner/go/pkg/mod
155-
/home/runner/.cache/go-build
138+
path: /home/runner/go/pkg/mod
156139
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
157140
- name: Cache Tools
158141
id: tool-cache
159142
uses: actions/cache@v2
160-
env:
161-
cache-name: cache-tool-binaries
162143
with:
163144
path: /home/runner/go/bin
164145
key: tools-${{ runner.os }}-${{ hashFiles('./internal/tools/go.mod', './cmd/mdatagen/go.mod', './cmd/mdatagen/*.go') }}
146+
- name: Cache Build
147+
uses: actions/cache@v2
148+
with:
149+
path: /home/runner/.cache/go-build
150+
key: go-build-coverage-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
165151
- name: Run Unit Tests With Coverage
166152
run: make gotest-with-cover
167153
- name: Upload coverage report
@@ -187,12 +173,8 @@ jobs:
187173
- name: Cache Go
188174
id: module-cache
189175
uses: actions/cache@v2
190-
env:
191-
cache-name: cache-go-modules
192176
with:
193-
path: |
194-
/home/runner/go/pkg/mod
195-
/home/runner/.cache/go-build
177+
path: /home/runner/go/pkg/mod
196178
key: go-pkg-mod-${{ runner.os }}-${{ hashFiles('**/go.mod', '**/go.sum') }}
197179
- name: Build Collector for All Architectures
198180
run: make binaries-all-sys

0 commit comments

Comments
 (0)