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 yarn global package data in CI #12581

Merged
merged 1 commit into from
Jun 19, 2024

Conversation

dacook
Copy link
Member

@dacook dacook commented Jun 18, 2024

I set out to cache the node_modules folder, but came across this easy fix first: https://github.com/actions/setup-node?tab=readme-ov-file#caching-global-packages-data
I don't know what this actually does, because it doesn't install the dependencies, that still needs to happen next.
But it saves about 6 seconds (see results below), so I think it's worth adding.

What should we test?

  • green specs
  • spec time slightly reduced

Next up

We could probably save a further 6 seconds by caching node_modules. This guide looks straightforward. But why is this not built-in to an official action??
https://github.com/actions/cache/blob/main/examples.md#node---yarn

I don't know what this actually does, because it doesn't install the dependencies, that still needs to happen next.
But surely any cache is a good thing?
@dacook
Copy link
Member Author

dacook commented Jun 18, 2024

I checked and this saves about 6 seconds, so I think it's worth adding.

Before (last build on master) - 19s

Screenshot 2024-06-18 at 2 05 39 pm

First time - 22s

Screenshot 2024-06-18 at 2 10 20 pm
Run actions/setup-node@v3:

/usr/local/bin/yarn --version
1.22.22
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
/usr/local/bin/yarn config get enableGlobalCache
undefined
yarn cache is not found

Subsequent - 13s

Screenshot 2024-06-18 at 2 04 34 pm

Run actions/setup-node@v3:

/usr/local/bin/yarn --version
1.22.22
/usr/local/bin/yarn cache dir
/home/runner/.cache/yarn/v6
/usr/local/bin/yarn config get enableGlobalCache
undefined
Cache Size: ~61 MB (64041350 B)
/usr/bin/tar -xf /home/runner/work/_temp/46850132-e5ba-4cb4-8a8c-c3e49a8e9c1c/cache.tzst -P -C /home/runner/work/openfoodnetwork/openfoodnetwork --use-compress-program unzstd
Received 64041350 of 64041350 (100.0%), 61.0 MBs/sec
Cache restored successfully
Cache restored from key: node-cache-Linux-yarn-e[27](https://github.com/dacook/openfoodnetwork/actions/runs/9558250039/job/26347954244#step:7:29)235ce2c8781[28](https://github.com/dacook/openfoodnetwork/actions/runs/9558250039/job/26347954244#step:7:30)9663c75b62dc60a2001f09009fbbdc89361a70596f9ddfbd

https://github.com/dacook/openfoodnetwork/actions/runs/9558250039/job/26347954244

@dacook dacook marked this pull request as ready for review June 18, 2024 04:15
@dacook dacook added the technical changes only These pull requests do not contain user facing changes and are grouped in release notes label Jun 18, 2024
@dacook dacook self-assigned this Jun 18, 2024
@dacook dacook changed the title Cache yarn dependencies Cache yarn global package data Jun 18, 2024
@dacook dacook changed the title Cache yarn global package data Cache yarn global package data in CI Jun 18, 2024
@rioug
Copy link
Collaborator

rioug commented Jun 18, 2024

I don't know what this actually does, because it doesn't install the dependencies, that still needs to happen next.

Presumably it caches the downloaded dependencies, which are then installed from the cache, see :
https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data

Copy link
Collaborator

@rioug rioug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find !

Copy link
Member

@mkllnk mkllnk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@mkllnk mkllnk merged commit f933ae8 into openfoodfoundation:master Jun 19, 2024
52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
technical changes only These pull requests do not contain user facing changes and are grouped in release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants