Skip to content

Commit

Permalink
[2023-03-30]: Setup-go Action now enabled with caching by default - […
Browse files Browse the repository at this point in the history
…GA] #9131 (#35001)

Co-authored-by: Lucas Costi <[email protected]>
  • Loading branch information
am-stead and lucascosti authored Mar 23, 2023
1 parent d966f6c commit 992bd4e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,21 @@ You can use `go get` to install dependencies:

### Caching dependencies

You can cache and restore the dependencies using the [`setup-go` action](https://github.com/actions/setup-go). By default, caching is disabled, but you can set the `cache` parameter to `true` to enable it.
You can cache and restore dependencies using the [`setup-go` action](https://github.com/actions/setup-go). By default, caching is {% ifversion actions-setup-go-default-cache-enabled %}enabled when using the `setup-go` action.{% else %}disabled, but you can set the `cache` parameter to `true` to enable it.{% endif %}

{% ifversion actions-setup-go-default-cache-enabled %}
The `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.

You can use the `cache-dependency-path` parameter for cases when multiple dependency files are used, or when they are located in different subdirectories.

```yaml{:copy}
- name: Setup Go
- uses: {% data reusables.actions.action-setup-go %}
with:
go-version: '1.17'
cache-dependency-path: subdir/go.sum
```
{% else %}

When caching is enabled, the `setup-go` action searches for the dependency file, `go.sum`, in the repository root and uses the hash of the dependency file as a part of the cache key.

Expand All @@ -149,6 +163,7 @@ Alternatively, you can use the `cache-dependency-path` parameter for cases when
cache: true
cache-dependency-path: subdir/go.sum
```
{% endif %}

If you have a custom requirement or need finer controls for caching, you can use the [`cache` action](https://github.com/marketplace/actions/cache). For more information, see "[AUTOTITLE](/actions/using-workflows/caching-dependencies-to-speed-up-workflows)."

Expand Down
7 changes: 7 additions & 0 deletions data/features/actions-setup-go-default-cache-enabled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Reference: #9131
# Setup-Go Action now enabled with caching by default
versions:
fpt: '*'
ghec: '*'
ghes: '>=3.9'
ghae: '>=3.9'
2 changes: 1 addition & 1 deletion data/reusables/actions/action-setup-go.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
actions/setup-go@{% ifversion actions-node16-action %}v3{% else %}v2{% endif %}
actions/setup-go@{% ifversion actions-setup-go-default-cache-enabled %}v4{% elsif actions-node16-action %}v3{% else %}v2{% endif %}

0 comments on commit 992bd4e

Please sign in to comment.