Skip to content

Commit 9c34a9c

Browse files
committed
Add advanced Go use cases
1 parent 93397be commit 9c34a9c

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

docs/adrs/0000-caching-dependencies.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ We don't pursue the goal to provide wide customization of caching in scope of `a
2828

2929
# Example of real use-cases
3030

31-
- With cache
31+
## With cache
3232

3333
```yml
3434
steps:
@@ -63,6 +63,56 @@ steps:
6363
**/go.mod
6464
```
6565
66+
```yml
67+
steps:
68+
- uses: actions/checkout@v3
69+
- uses: actions/setup-go@v3
70+
with:
71+
go-version: '18'
72+
cache: true
73+
cache-dependency-path: **/go.sum
74+
```
75+
76+
## Multi-target builds
77+
```yaml
78+
env:
79+
GOOS: ...
80+
GOARCH: ...
81+
82+
steps:
83+
- run: echo "$GOOS $GOARCH"> /tmp/env
84+
85+
- uses: actions/setup-go@v4
86+
with:
87+
cache-dependency-path: go.sum /tmp/env
88+
```
89+
90+
## Invalidate cache if source code changes
91+
```yaml
92+
- uses: actions/setup-go@v4
93+
with:
94+
go-version: '1.20'
95+
cache-dependency-path: go.sum **/*.go
96+
```
97+
98+
## Restore-only caches
99+
If there are several builds on the same repo it might make sense to create a cache in one build and use it in the
100+
others. The action [actions/cache/restore](https://github.com/actions/cache/blob/main/restore/README.md#only-restore-cache)
101+
should be used in this case.
102+
103+
## Include or exclude cached paths
104+
This advanced use case requires the use of
105+
[actions/cache](https://github.com/actions/cache/blob/main/examples.md#automatically-detect-cached-paths)
106+
107+
## Generate different caches
108+
This advanced use case assumes manual definition of cache key and requires the use of
109+
[actions/cache](https://github.com/actions/cache/blob/main/examples.md#go---modules)
110+
111+
## Parallel builds
112+
To avoid race conditions during the parallel builds they should either
113+
[generate their own caches](#generate-different-caches), or create the cache
114+
for only one build and [restore](#restore-only-caches) that cache in the other builds.
115+
66116
# Release process
67117
68118
As soon as functionality is implemented, we will release minor update of action. No need to bump major version since there are no breaking changes for existing users.

0 commit comments

Comments
 (0)