File tree Expand file tree Collapse file tree 5 files changed +46
-6
lines changed Expand file tree Collapse file tree 5 files changed +46
-6
lines changed Original file line number Diff line number Diff line change 17
17
- name : Test
18
18
run : go test ./...
19
19
20
- test-gopath :
21
- env :
22
- GOPATH : ${{ github.workspace }}
23
- GO111MODULE : off
20
+ test-cache :
24
21
runs-on : ubuntu-latest
25
22
steps :
26
23
- name : Install Go
29
26
go-version : 1.15.x
30
27
- name : Checkout code
31
28
uses : actions/checkout@v2
29
+ - uses : actions/cache@v2
32
30
with :
33
- path : ./src/github.com/${{ github.repository }}
31
+ path : |
32
+ ~/go/pkg/mod # Module download cache
33
+ ~/.cache/go-build # Build cache (Linux)
34
+ ~/Library/Caches/go-build # Build cache (Mac)
35
+ '%LocalAppData%\go-build' # Build cache (Windows)
36
+ key : ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
37
+ restore-keys : |
38
+ ${{ runner.os }}-go-
34
39
- name : Test
35
40
run : go test ./...
Original file line number Diff line number Diff line change @@ -87,6 +87,26 @@ downloaded modules:
87
87
${{ runner.os }}-go-
88
88
` ` `
89
89
90
+ You can also include Go's build cache, to improve incremental builds :
91
+
92
+ ` ` ` yaml
93
+ - uses: actions/cache@v2
94
+ with:
95
+ path: |
96
+ ~/go/pkg/mod # Module download cache
97
+ ~/.cache/go-build # Build cache (Linux)
98
+ ~/Library/Caches/go-build # Build cache (Mac)
99
+ '%LocalAppData%\g o-build' # Build cache (Windows)
100
+ key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
101
+ restore-keys: |
102
+ ${{ runner.os }}-go-
103
+ ` ` `
104
+
105
+ This is demonstrated via the `test-cache` job [in this very repository](https://github.com/mvdan/github-actions-golang/actions).
106
+
107
+ See [this guide](https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows)
108
+ for more details.
109
+
90
110
# ### How do I run a step conditionally?
91
111
92
112
You can use `if` conditionals, using their [custom expression
@@ -168,11 +188,14 @@ jobs:
168
188
env:
169
189
GOPATH: ${{ github.workspace }}
170
190
GO111MODULE: off
191
+ defaults:
192
+ run:
193
+ working-directory: ${{ env.GOPATH }}/src/github.com/${{ github.repository }}
171
194
steps:
172
195
- name: Checkout code
173
196
uses: actions/checkout@v2
174
197
with:
175
- path: . /src/github.com/${{ github.repository }}
198
+ path: ${{ env.GOPATH }} /src/github.com/${{ github.repository }}
176
199
` ` `
177
200
178
201
# # Quick links
Original file line number Diff line number Diff line change @@ -6,10 +6,14 @@ package actions
6
6
import (
7
7
"fmt"
8
8
"runtime"
9
+
10
+ "rsc.io/quote"
9
11
)
10
12
11
13
func Demo () {
12
14
fmt .Printf ("Go version: %s\n " , runtime .Version ())
13
15
fmt .Printf ("GOOS: %s\n " , runtime .GOOS )
14
16
fmt .Printf ("GOARCH: %s\n " , runtime .GOARCH )
17
+
18
+ fmt .Println (quote .Go ())
15
19
}
Original file line number Diff line number Diff line change 1
1
module dummy.module/actions
2
2
3
3
go 1.14
4
+
5
+ require rsc.io/quote v1.5.2
Original file line number Diff line number Diff line change
1
+ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c h1:qgOY6WgZOaTkIIMiVjBQcw93ERBE4m30iBm00nkL0i8 =
2
+ golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c /go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ =
3
+ rsc.io/quote v1.5.2 h1:w5fcysjrx7yqtD/aO+QwRjYZOKnaM9Uh2b40tElTs3Y =
4
+ rsc.io/quote v1.5.2 /go.mod h1:LzX7hefJvL54yjefDEDHNONDjII0t9xZLPXsUe+TKr0 =
5
+ rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4 =
6
+ rsc.io/sampler v1.3.0 /go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA =
You can’t perform that action at this time.
0 commit comments