Це відео не доступне.
Перепрошуємо.
Caching Dependencies to SPEED UP Workflows in GitHub Actions
Вставка
- Опубліковано 15 сер 2024
- To make your GitHub Actions workflows faster and more efficient, you can start Caching Dependencies to SPEED UP Workflows in GitHub Actions, for dependencies and other commonly reused files.
GitHub Actions caching is not complex, let's take a look at it in 3 minute. We will see how to add cache to GitHub Actions!
Learn how to use the GitHub Actions Cache
🌟EXCLUSIVE CONTENT🌟
Do you want to access exclusive content, live chats and Q&As, polls, and even 1:1 calls with me? Join my Patreon: / coderdave
🆘 NEED HELP? 🆘
Book a 1:1 Consultation with CoderDave: geni.us/cdconsult
🙏🏻SUPPORT THE CHANNEL🙏🏻
Buy me a coffee: www.buymeacoff...
PayPal me donation: paypal.me/dabe...
💬JOIN THE COMMUNITY
► Website: coderdave.io
► Discord: geni.us/cddiscord
► Newsletter: coderdave.io/n...
► Blog: dev.to/n3wt0n
► GitHub: github.com/n3wt0n
► Twitter: / davidebenvegnu
► Facebook: / coderdaveyt
🎥VIDEOS
► Automate EVERYTHING with GitHub Actions: • Automate EVERYTHING wi...
► How to trigger GitHub Actions manually: • We can START GitHub Ac...
► Composite GitHub Actions: • GitHub Actions - Compo...
🎤PODCAST: geni.us/cdpodcast
❓QUESTIONS?
Have a question about DevOps, Cloud, Coding, or Anything Else? Post in comments section of this video!
🔴SUBSCRIBE to CoderDave here: www.youtube.co...
_______________
👕GET MY MERCH: geni.us/cdmerch
🔮TOOLS I USE
► Twingate - Connect to your Private Resources SECURELY: geni.us/twingate
► TubeBuddy - #1 UA-cam channel Management tool (FREE): www.tubebuddy....
► Moosend - Free Newsletter and Automation Platform: geni.us/moosend
📸🖥️GEAR AND SOFTWARE
► Music - Epidemic Sound (Get 30 days free): epidemicsound....
► Editing - Adobe Premiere Pro: geni.us/AdobeV...
► Gear I Use for UA-cam: kit.co/CoderDa...
► Gear I Use for Streaming: kit.co/CoderDa...
► My Computer Setup: kit.co/CoderDa...
► Full office setup: github.com/n3w...
Disclaimer:
Some product links are affiliate links which means if you buy something I'll receive a small commission at no additional cost to you.
As an Amazon Associate, I earn from qualifying purchases.
Great advice , thank you!
You are so welcome!
This was an amazing video thanks a lot
Thanks! Really happy it’s been helpful ☺️
Don't you wish UA-cam had a feature to track how many minutes and seconds a video has progressed so far ?
Great and amazing video. Thanks a lot!!! Some advice on npm. We do not use `npm install` but `npm ci`. `npm install` do not use the package-lock.json file. `npm ci` do.
Thanks for your comment. Npm ci is only available in version 6, if someone is using version 5 they wouldn’t have it. Also, since I’m using it in Hosted Agents I don’t have the problem of needing to make sure it’s a clean state... because it is always a new clean agent by design. Finally, you can’t cache npm ci... in fact, if it finds an npm modules folder it deletes it and reinstall everything
@CoderDave what if you want the cache action to work for different JOBS. In your case you only use it inside BUILD. In my case I want to use the automated dependencies in TEST, BUILD, ANALYSE
I think it should be possible, just using the same key to retrieve from the caceh
Amazing thnx!
Thanks 🙏🏻
Life saver!
Very happy you liked it ☺️
Hi Dave,
Please, could you send me link to this project, let me try it myself.
I'm new to this, please.
Thank you. Regards
Hi, here is the link to the GitHub Actions file: github.com/n3wt0n/HKOSCon2020/blob/master/.github/workflows/npmCache.yml
@@CoderDave
Thank you so much, Dave.
I will keep in touch with you always.
Definitely, I will join your community as I am preparing to join CI team at College of Computer Science, University of Illinois.
Take good care always. Cheers.
Regards
Cyril
@CoderDave can the id value be dynamic or does it have to be a static value like what you have in the video with: myCacheStep
Good question. The ID must be static, because it is used before runtime to generate an execution plan for the Action. It is used to reference that step in other steps
@@CoderDave Thank you. I could not find this documented anywhere.
Dave, I was wondering...
How would your caching know if the dependencies changed or not, i.e.,
whether it can use the result from the cache or not?
Thanks
😇😇😇 Waiting for your response...
The cache knows that based on the `key` which is specified. In the example I used (and the file linked to my other comment), you see that they key for the cache is cmposed by the runner OS, a cachename variable and most importantly by the hash of the dependency definition file. Because of that, if a dependency changes the hash of the file will be different, making the cache key different... hence, the cache knows that it can't use the current cache value but will generate a new one
PS: I've replied to your email as well
@@CoderDave
Thank you so much, Dave...
@@CoderDave
Hi Dave,
Just some concerns below:
>>>> The cache knows that based on the `key` which is specified.
>>>> the key [...] is composed [...] the hash of the dependency definition file.
What if some dependency/ies have the same name but different content? In
the Java world, one usually does that by naming dependencies SNAPSHOT. I
don't know what's commonly done in the NPM world.
Thank you so much.
Regards
Hey, well that shouldn’t be a problem. You should never have 2 different libraries / dependencies with the same name but different content.
If you have 2 version of the same library, then even if the name is the same the version changes and invalidate the cache
If instead you have 2 different libraries with the same name it is a big problem not just for the cache but in general… how would any dependency manager know which library to consume? Plus any dependency repo requires unique names so you won’t be able to save the dependencies anywhere..
Is there a reason why you use npm install over npm ci in your pipeline?
Npm ci is only available in version 6, if someone is using version 5 they wouldn’t have it. Also, since I’m using it in Hosted Agents I don’t have the problem of needing to make sure it’s a clean state... because it is always a new clean agent by design. Finally, you can’t cache npm ci... in fact, if it finds an npm modules folder it deletes it and reinstall everything
@@CoderDave well explained thnx
@@CoderDave It is correct, that npm ci would clear the node_modules folder. But the use case discussed here doesn't try to cache the the local node_modules but the global .npm cache.