-
Notifications
You must be signed in to change notification settings - Fork 534
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create ADR for integrating cache functionality to setup-go action #217
Merged
dmitry-shibanov
merged 7 commits into
actions:main
from
dmitry-shibanov:v-dmshib/add-adr-caching
Apr 26, 2022
Merged
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
323a4a0
add ADR about caching
dmitry-shibanov d0fcad0
work on resolving comments
dmitry-shibanov 38571be
fixing ADR with new input
dmitry-shibanov 7c48ba4
change status and date
dmitry-shibanov b87d451
change versions
dmitry-shibanov e4b4f39
add path
dmitry-shibanov d9a56b0
change status
dmitry-shibanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# 0. Caching dependencies | ||
Date: 2022-04-13 | ||
|
||
Status: Proposed | ||
|
||
# Context | ||
`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. | ||
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 | ||
- Simplify YAML pipelines because there will be no need for additional steps to enable caching | ||
- 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 | ||
- `false`- disable caching for go dependencies. This value will be set as default value | ||
- 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 | ||
- Action will try to search a go.sum files in the repository and throw error in the scenario that it was not found | ||
- 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) | ||
- The following key cache will be used `${{ runner.os }}-go${{ go-version }}-${{ hashFiles('<go.sum-path>') }}` | ||
- Action will cache global cache from the `go env GOMODCACHE` and `go env GOCACHE` commands. | ||
- Add a `cache-dependency-path` input parameter to `actions/setup-go`. The new input will accept an array or regex of dependency files. The field will accept a path (relative to the repository root) to dependency files. If the provided path contains wildcards, the action will search all matching files and calculate a common hash like the ${{ hashFiles('**/go.sum') }} YAML construction does. | ||
|
||
# Example of real use-cases | ||
|
||
- With cache | ||
|
||
```yml | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '18' | ||
cache: true | ||
``` | ||
|
||
- With cache-dependency-path | ||
|
||
```yml | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '18' | ||
cache: true | ||
cache-dependency-path: **/go.sum | ||
``` | ||
|
||
```yml | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-go@v3 | ||
with: | ||
go-version: '18' | ||
cache: true | ||
cache-dependency-path: | | ||
**/go.sum | ||
**/go.mod | ||
``` | ||
|
||
# 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) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What happens if you set
cache-dependency-path
without settingcache
? Does it implycache
? I suppose there's precedent here from the othersetup-
actions, but just wanted to clarify hereThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cache-dependency-path input only works with enabled cache. The cache-dependency-path will override file from which cache is generated.