setup-go/docs/adrs/0000-caching-dependencies.md

43 lines
2.6 KiB
Markdown
Raw Normal View History

2022-03-29 17:50:30 +02:00
# 0. Caching dependencies
Date: 2022-03-29
Status: Accepted
# Context
2022-04-01 13:43:24 +02:00
`actions/setup-go` is the one of the most popular action related to Golang in GitHub Actions. Many customers use it in conjunction with [actions/cache](https://github.com/actions/cache) to speed up dependency installation process.
2022-03-29 17:50:30 +02:00
See more examples on proper usage in [actions/cache documentation](https://github.com/actions/cache/blob/main/examples.md#go---modules).
# Goals & Anti-Goals
Integration of caching functionality into `actions/setup-go` action will bring the following benefits for action users:
- Decrease the entry threshold for using the cache for Go dependencies and simplify initial configuration
2022-04-01 13:43:24 +02:00
- Simplify YAML pipelines because there will be no need for additional steps to enable caching
2022-03-29 17:50:30 +02:00
- More users will use cache for Go so more customers will have fast builds!
We don't pursue the goal to provide wide customization of caching in scope of `actions/setup-go` action. The purpose of this integration is covering ~90% of basic use-cases. If user needs flexible customization, we should advice them to use `actions/cache` directly.
# Decision
- Add `cache` input parameter to `actions/setup-go`. For now, input will accept the following values:
- `true` - enable caching for go dependencies
2022-04-01 13:43:24 +02:00
- `false` and `''` - disable caching for go dependencies. This value will be set as default value
We're planning to get these values as strings. That will enable us to extend the functionality in future much easier if we get proposals for it.
2022-03-29 17:50:30 +02:00
- Cache feature will be disabled by default to make sure that we don't break existing customers. We will consider enabling cache by default in next major releases
2022-04-01 13:43:24 +02:00
- Action will try to search a go.sum files in the repository and throw error in the scenario that it was not found
2022-03-29 17:50:30 +02:00
- The hash of found file will be used as cache key (the same approach like [actions/cache](https://github.com/actions/cache/blob/main/examples.md#go---modules) recommends)
2022-04-01 13:43:24 +02:00
- The following key cache will be used `${{ runner.os }}-go${{ go-version }}-${{ hashFiles('<go.sum-path>') }}`
2022-03-29 17:50:30 +02:00
- Action will cache global cache from the `go env GOCACHE` command
# Example of real use-cases
```yml
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
2022-04-01 13:43:24 +02:00
go-version: '16'
2022-03-29 17:50:30 +02:00
cache: true
```
# Release process
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.
After that, we will update [starter-workflows](https://github.com/actions/starter-workflows/blob/main/ci/go.yml)