Skip to content

Warm up Jest cache before running tests

Mark Florian requested to merge prepare-jest-cache into master

What does this MR do and why?

Warm up Jest cache before running tests in CI

This is an attempt to reduce the frequency with which Jest jobs fail due to timeouts in CI.

Experiments conducted in !150196 (merged) show that Jest spec run time in CI is highly variable and inconsistent. This can also be seen in the latest Jest speed report: https://gitlab-org.gitlab.io/frontend/playground/jest-speed-reporter/. See also #457179 (closed).

One way to mitigate this is to reduce the amount of work Jest needs to do in each job by preparing an import cache for Jest and providing it to each job. This cache should prevent some unnecessary IO/compute on these jobs, mostly around transpilation of files, done by at least vue2-jest, babel, and our GraphQL transformer.

This seems to reduce the worst cases of slow specs, which should help reduce the frequency of timeouts. There doesn't appear to be much of a benefit for the majority/long tail of tests, however.

Related to #457179 (closed).

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

master This MR
master_1284836307 mr_1284816025

How to set up and validate locally

If you want to run jest-speed-reporter yourself locally:

  1. Clone the project
  2. Edit its index.js to target just the pipeline(s) you want to run it against
  3. Build it with GITLAB_TOKEN=your_token ./build.sh
  4. Open public/index.html

Otherwise, take a look at the pipeline(s) in this MR. Does anything look wrong with Jest jobs, timings or otherwise?

Edited by Mark Florian

Merge request reports

Loading