From 992bd4e0de18377a6501cac10a1043486dff6c00 Mon Sep 17 00:00:00 2001 From: Anne-Marie <102995847+am-stead@users.noreply.github.com> Date: Thu, 23 Mar 2023 09:36:41 +0100 Subject: [PATCH] [2023-03-30]: Setup-go Action now enabled with caching by default - [GA] #9131 (#35001) Co-authored-by: Lucas Costi --- .../building-and-testing-go.md | 17 ++++++++++++++++- .../actions-setup-go-default-cache-enabled.yml | 7 +++++++ data/reusables/actions/action-setup-go.md | 2 +- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 data/features/actions-setup-go-default-cache-enabled.yml diff --git a/content/actions/automating-builds-and-tests/building-and-testing-go.md b/content/actions/automating-builds-and-tests/building-and-testing-go.md index 9fc2ca6e598e..ea21771159e9 100644 --- a/content/actions/automating-builds-and-tests/building-and-testing-go.md +++ b/content/actions/automating-builds-and-tests/building-and-testing-go.md @@ -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. @@ -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)." diff --git a/data/features/actions-setup-go-default-cache-enabled.yml b/data/features/actions-setup-go-default-cache-enabled.yml new file mode 100644 index 000000000000..3fe39d08de4a --- /dev/null +++ b/data/features/actions-setup-go-default-cache-enabled.yml @@ -0,0 +1,7 @@ +# Reference: #9131 +# Setup-Go Action now enabled with caching by default +versions: + fpt: '*' + ghec: '*' + ghes: '>=3.9' + ghae: '>=3.9' diff --git a/data/reusables/actions/action-setup-go.md b/data/reusables/actions/action-setup-go.md index 9080cc8ba91f..f365f52c6041 100644 --- a/data/reusables/actions/action-setup-go.md +++ b/data/reusables/actions/action-setup-go.md @@ -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 %}