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

chore: separate go cache per job #4551

Merged
merged 1 commit into from
Feb 3, 2025
Merged

Conversation

techfg
Copy link
Collaborator

@techfg techfg commented Feb 3, 2025

What does this PR do?

After splitting out the CI jobs (build/check/typecheck), the build times increased by ~30-45secs.

The reason for this is that the build & check steps each use go and rely on the default caching of go dependencies from actions/setup-go. Unfortunately, the action does not contemplate that multiple jobs may result in different modules being downloaded (e.g., build will get everything but fmt only obtains a portion of the modules) and if the inputs are the same (which they are) across jobs, the first job to "save the cache" will win. In our case, the check job finishes first so the cache only contains the modules of what was required for go fmt. This results in go build needing to download modules every time since some modules aren't in the cache.

Unfortunately, actions/setup-go does not support a "cache prefix/key" in its options and doesn't appear that it is going to be added any time soon (if ever). See actions/setup-go#358 for full details.

This PR resolves the issue by including a job specific text file in the dependency graph to ensure that the cache key is different for each job.

Testing

Manual testing of CI build confirms that each job is getting its own cache and once the cache is built for a given set of input, job times are back to previous duration levels.

@techfg techfg merged commit 145c1ab into main Feb 3, 2025
9 checks passed
@techfg techfg deleted the chore/separate-go-cache-per-job branch February 3, 2025 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant