Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🏗 Cache node_modules/ in between CircleCI jobs #39812

Merged
merged 1 commit into from
Feb 12, 2024

Conversation

danielrozenberg
Copy link
Member

@danielrozenberg danielrozenberg commented Feb 9, 2024

I've noticed that a lot of times jobs fail because of the Install NPM packages step due to random network hiccups. We run this step on each CircleCI job (so a total of ~30 times per PR!) - this isn't really necessary because we can just run npm ci once during the init job, cache the resulting node_modules/ directory, and restore that cache at the start of every subsequent job. For PRs that don't change package-lock.json (which is most of the human-written PRs), we can skip the installation step entirely and just restore the cache.

This means that any PR that changes package-lock.json will take about 50 seconds longer to go through the initializing step, but then all PRs (whether they change package-lock.json or not) shortens every other job by about 40 seconds! That shortens the the total wall time of a CircleCI workflow in either case - woohoo!

And of course, instead of having a chance to fail in a later job during the Install NPM packages, this can only happen once at the beginning (faster to notice and restart the job) and then only for PRs that change package-lock.json to begin with.

@danielrozenberg danielrozenberg force-pushed the cache-node-modules branch 12 times, most recently from c853043 to ba7cae2 Compare February 9, 2024 20:37
@danielrozenberg danielrozenberg marked this pull request as ready for review February 9, 2024 20:54
@danielrozenberg danielrozenberg changed the title 🏗 Cache node_modules/ in between CircleCI jobs 🏗 Cache node_modules/ in between CircleCI jobs [DO NOT MERGE] (see note in PR description) Feb 12, 2024
@danielrozenberg danielrozenberg changed the title 🏗 Cache node_modules/ in between CircleCI jobs [DO NOT MERGE] (see note in PR description) [DO NOT MERGE] (see note in PR description) 🏗 Cache node_modules/ in between CircleCI jobs Feb 12, 2024
@danielrozenberg danielrozenberg changed the title [DO NOT MERGE] (see note in PR description) 🏗 Cache node_modules/ in between CircleCI jobs 🏗 Cache node_modules/ in between CircleCI jobs Feb 12, 2024
@danielrozenberg danielrozenberg enabled auto-merge (squash) February 12, 2024 22:54
@danielrozenberg danielrozenberg merged commit 64c5fc9 into ampproject:main Feb 12, 2024
43 checks passed
@danielrozenberg danielrozenberg deleted the cache-node-modules branch February 13, 2024 00:52
eszponder pushed a commit to krzysztofequativ/amphtml that referenced this pull request Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants