Calculate and use sha for CI config variables cache
What does this MR do and why?
Related to #381233 (closed)
Today, we are receiving "ref" from a client and calculating config variables according to it. We also use this "ref" to decide the cache key. However, "ref" is not a good candidate for a cache key because the name is static but that branch can be changed.
In this MR, we are starting to calculate and use "sha" of the "ref" for the cache key.
Here, we are also renaming the "sha" parameter to "ref" because we are actually receiving "ref" from client.
As a follow-up, we should deprecate the parameter name sha
and introduce ref
instead in both app/controllers/projects/pipelines_controller.rb
and app/graphql/types/project_type.rb
. #389065 (closed)
Screenshots or screen recordings
Before this MR
Let's say we have this config initially;
test-job:
script: exit 0
- When we open the "Run pipeline" page, the config-variables endpoint returns
null
initially;
It means that the reactive cache is empty and it's being calculated.
- When we refresh the page again, we'll see that the endpoint returns
[]
;
(we won't have to refresh the page after the frontend part of #381233 (closed) is implemented)
- Let's update the config YAML with this;
variables:
VAR1:
description: Hello VAR1
test-job:
script: exit 0
- When we refresh the "Run pipeline" page again, we'll see that the endpoint still returns
[]
;
That's because the cache is calculated with the branch name.
After this MR
Let's say we have this config initially;
test-job:
script: exit 0
- When we open the "Run pipeline" page, the config-variables endpoint returns
null
initially;
It means that the reactive cache is empty and it's being calculated.
- When we refresh the page again, we'll see that the endpoint returns
[]
;
(we won't have to refresh the page after the frontend part of #381233 (closed) is implemented)
- Let's update the config YAML with this;
variables:
VAR1:
description: Hello VAR1
test-job:
script: exit 0
- When we refresh the "Run pipeline" page again, we'll see that the endpoint returns
null
;
It means that the reactive cache is empty and it's being calculated.
- When we refresh the page again, we'll see that the endpoint returns prefill variables as expected;
(we won't have to refresh the page after the frontend part of #381233 (closed) is implemented)
That's because the cache is calculated with sha
.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.