Fixes files: keyword and adds a fallback files_commits
What does this MR do and why?
This fixes the files keyword, which currently uses commit sha as the cache key, when it should be using the file content (checksum).
It also adds a new files_commit cache that uses the commit sha, in case this behavior is still desired.
NOTE: I will be adding instrumentation in a follow-up.
References
How to set up and validate locally
These instructions are for testing in the UI :)
- Add a
package.jsonto any project and commit tomaster. - Add this
.gitlab-ci.yml
files_commit_job:
script: echo "test"
cache:
key:
files_commit:
- package.json
paths:
- package.json
files_job:
script: echo "test"
cache:
key:
files:
- package.json
paths:
- package.json-
Run a pipeline on
master. Check out the the job logs, which will mentionCreating cache ....:In my example:
files_job:0-8fe3111278da...files_commit_job0_package-ed0767d8a321b6..
-
Create another branch. On this branch, cherry-pick the changes from step 1 by going to the commit and selecting
cherry-pick: -
Run pipeline again on that branch. You should now see that:
files_commit_job: has a different cache keys (uses commit SHA) :( <- this is the wayfileswas buggy, but we are providing this just in casefiles_job: Same cache key (uses file content hash)✅ 0-8fe3111278da...<- this is the fix!
For extra verification - you can do steps 1-5 on master. You will see that files_job will have a different cache key.
Edited by Laura Montemayor
