If you use git during your builds (to create commits, or to run git describe), it would make sense to add it to your. npm/ - a folder we picked for keeping the cache. If we were adding more jobs, we could save few seconds making sure we only pull-push from the very first one, and all the others will only pull policy: pull-push - setting the default cache policy explicitly - it will load the cache before & upload it after the job run.In the documentation they show an example of how to limit cache use only to the current CI run - in the case of npm dependencies, they are safe to reuse between CI runs, especially because npm still will make sure to install them in the correct version. cache:key: npm - I want to share this cache across different CI runs. npm/ build: stage: build script: - npm ci -cache. Adding cacheįor enabling the cache, the configuration gets a bit more complicated image: node:16 stages: - build cache: key: npm policy: pull-push paths:. I run the build with this configuration 3 times, and every time the total time was 1 minute 41 seconds in our baseline. In this way, the complete time of the job is setting up the stage for the build itself - getting the node:16 image to the agent & dependencies for npm. To simplify, I only run the installation with npm ci. The baseline CI configuration is as follow: image: node:16 stages: - build build: stage: build script: - npm ci It's installing quite a few dependencies, and we need enough of them to see the positive impact of caching on the run time. Example packageįor this article, I created a project with create-react-app. In this article, I'll show how to set up & use npm caching in GitLab CI.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |