Skip to content
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

Properly save and restore the Go build cache in our CI #552

Merged
merged 2 commits into from Nov 9, 2023

Conversation

jgiannuzzi
Copy link
Member

This PR is the second in a series to address #328.

It introduces a composite action to setup Go with caching. It centralizes the logic and creates a different prefixed key per job for the Go build cache. This cache is fairly small once compressed (under 100MB currently) and saves a lot of computation time. We explicitly omit the Go module cache as it is big (~1GB compressed currently) and network-bound, which means that it would raise our cache quota without any benefits compared to downloading again from the Go proxy.

The various Go tools get cached based on the Makefile install-tools target content. Only the built binaries are cached (under 40MB currently) and we explicitly omit the Go build and module caches that are comparatively huge and unnecessary.

The integration tests run within Docker containers and thus saving and restoring the Go build cache is a bit more complex. The high-level logic is however the same as with the other Go-based jobs.

Caches for golangci-lint, the Docker images, and the Python tests will be improved in subsequent PRs.

@jgiannuzzi jgiannuzzi changed the title Go cache Properly save and restore the Go build cache in our CI Nov 4, 2023
@jgiannuzzi jgiannuzzi self-assigned this Nov 4, 2023
@jgiannuzzi jgiannuzzi added the ci CI related label Nov 4, 2023
@jgiannuzzi jgiannuzzi marked this pull request as ready for review November 5, 2023 15:19
@jgiannuzzi jgiannuzzi merged commit 7a4f3b1 into G-Research:main Nov 9, 2023
18 checks passed
@jgiannuzzi jgiannuzzi deleted the go-cache branch November 9, 2023 20:06
@jgiannuzzi jgiannuzzi linked an issue Nov 10, 2023 that may be closed by this pull request
- id: setup-go
uses: actions/setup-go@v4
with:
go-version: "1.21"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can parametrize the go version and keep this as a default.

  go-version:
    description: "Go version to install"
    required: false
    default: "1.21"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but I don't want to have to change it in multiple places, which is why I "hard-coded" it here 😄

@@ -187,9 +227,9 @@ jobs:
fetch-depth: 0

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need all git data in this job?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do in order to compute the version (we need tags + amount of commits since the tag)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aha, I missed that part

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci CI related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve Go caching in CI
3 participants