Adjust CI to enable cache sharing with forked PRs #2353
Merged
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.
So for a recent PR #2349 after merging #2343 , I noticed that it's cache restore step was not finding the matching cache key provide by the main branch:
Prior existing cache stored by main branch CI job
Later failed cache restore from forked PR CI job
This was because CircleCI does not share caches with forked repos, unless sharing of environment variables is enabled:
We can simply enable sharing of environment variables in the repo's circleci settings, but we currently have two secret tokens stored in the repo's circleci environment. The codecov token and the DockerHub build trigger token. Turns out codecov token should be unnecessary for public repos when using major CI's like CircleCI or GH actions, so we could delete that variable from the current CircleCI environment.
As for the DockerHub build trigger token, given GH actions has a slightly more nuance control for protecting repo secrets:
I've ported the cron job config from #2344 into a GH action workflow so we can move the DockerHub secret into GH actions. This also has the added benefit of allowing the use of GH action event triggers to rebuild the CI image if any of the
package.xml
or.repos
files are changed, given they're subsequently used to pre-install depencies in the CI image.