Cast artifact sizes to numbers before adding them
What does this MR do and why?
This MR fixes the artifacts size calculation for jobs on the artifacts page by casting each size to a Number
before adding them together so that they actually get added and not concatenated as strings
This seems to be a side effect of the artifacts's size
's change in data type from Int
to BigInt
(!121662 (merged))
Cast artifact sizes to numbers before adding them
Add test for the util to check that the total size is right
Changelog: fixed
Screenshots or screen recordings
An example from the gitlab-docs
project:
Currently, the sizes of artifacts are being concatenated as strings, i.e. "21370" + "215" + "7116" + "156303" + "22527" = "21370215711615630322527", then this is interpreted as a number of bytes to get 19902564316630 GiB.
This MR casts the string values to numbers, i.e. 21370 + 215 + 7116 + 156303 + 22527 = 207531 bytes or 202.67 KiB.
How to set up and validate locally
- find/make a project that generates artifacts and run a few pipelines in the project to generate some artifacts
- navigate to the project, and in the sidebar choose
CI/CD
=>Artifacts
(orBuild
=>Artifacts
in the new sidebar) - verify that the total artifacts size for the job is the sum of all of the individual artifact sizes
to run tests
yarn install && yarn jest ci/artifacts
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.