@ayufan i don't have the permission to close issues, but this is not an issue for me. It could be a candidate for an faq section, or tag it with question here.
When the runner is running I verified that that the /npmcache dir was being populated
But for whatever reason, npm does not seem to use the cache for subsequent builds, and as a result there seems to be no speed up from making the npm cache persistent (the dependencies are downloaded and compiled on each build). No idea why this is the case.
So I tried caching the node_modules directory instead. Node doesn't allow changing the node_modules directory location easily, so I just added - ln -s /node_modules node_modules to my .yml after adding a /node_modules volume in config.toml
The .yml looks likes this:
Can we create a data-container or a cached volume using the gitlab-runner:cache image which is shared over all build types and trashed after the whole .gitlab-ci.yml scripts finished?
What i want to achive is a shared folder to avoid running npm install again in every type. Since we basically support build pipelines it would be great if we could do something like this:
image: centos:7types:- build- qa- test- deploybuild: type: build script: - npm installquality-assurance: type: qa script: - npm run linterstest: type: test script: - npm run test-protractor-abcdeploy: type: deploy script: ...
Also will apply to make this feature. Since for example if I have vagrant getting up at the beginning, then every time the folder .vagrant is deleted, since I have it in my .gitignore and because of that I need to create virtual machine from scratch, instead of using existing one.
+1 to this. npm install builds are painfully slow. Sequential builds should really use the same node_modules folder. And given that other products offer already available solutions, I believe this should be addressed duly.
@ayufan Is this still scheduled for 8.2? We are considering upgrading our Gitlab instance before EOW, but we might wait for this to come up if it's going to see the light of day in the near future.
I use a gitlab-runner with shell execution and tried to add this to my build file:
cache: paths: - node_modules/
Unfortunately, I get the following error:
gitlab-ci-multi-runner 0.6.2 (3227f0a)WARNING: Defined cache is not supported for that executorUsing Shell executor...Running on around-media-gitlab-ce...
I would like to keep the node_modules/ directory cached in between builds
I read here that I need to use a file outside my directory, but this node_modules/ gets generated by doing npm install. Anyone that can help me out?
before finishing, but my node_modules directory is still being deleted before starting a job and dependencies are installed as normal (no sign of caching whatsover), even on subsequent builds. @ayufan, what am I missing here?
Hi, I waited for this feature, however that tar/untar works quite slow for projects with thousands of files in node_modules. So I went back to making symlinks to /cache folder.
@inwaar How the caching works is the subject to change. It's tied to the code of GitLab Runner. So we are free to improve it overtime :) The most important is that we have it working, and the GitLab returns paths that we can consume anyway we want later.
Based on the discussion above, it is implied here that the same cache should be used for all of the build jobs. However, on my server with Gitlab 8.2.1 and runner 0.7.2, a separate cache tarball is created for each job.
@kohenkatz Currently the cache is per-job. The 8.3 will introduce option to "group" cache and reuse it between different jobs. It's currently done this way, because you can test against different versions of NodeJS, and the cached objects may not be valid for different image.
I'm thinking about adding:
cache: name: "$CI_BUILD_REF"
You could use any name you want. You could group by branch, tag, job name, stage name, some variable. It will be flexible. However, the default will always be per-job caching.
@ayufan Is there any example on how the group option is used? Can there be per job and grouped cache at the same time? If yes how, if no is it planned?
Is it possible to cache folders outside the project path?
For example, unlike node, .NET DNX stores all downloaded packages in a global folder - /root/.dnx/packages. I'd like to be able to share the downloaded packages across jobs which belong to different stages.
When I create two jobs with a shared cache (through the new group name), sharing works fine, but only for paths relative to the project folder (for example ./my-local-path).
However, when I attempt to use the following cache definition:
cache:group:my_grouppaths:-/root/.dnx/packages/
the runner yields:
Archiving cache... INFO[0000] No files to archive.
I checked - the folder is there and it is full of files, but the cache archiving seems to be skipping it for some reason.
On another note, what is the best way to debug the build script generated by gitlab-ci-multi-runner? Being able to peek behind actions such as Archiving cache... would be helpful.
Is there any way to speed up archiving/restoring of the cache (for example turn off compression)?
Also, is there a way to tell a job to restore the cache, but not archive at the end?
Yes, I think adding an option to enable/disable compression (and maybe make it disabled by default) would be a very useful update.
I am using cache as a way to speed up my builds, but in reality my build process slows down because of the overhead of the archive-and-restore operations.
I'm sorry to tell you but I'm experiencing the same. My builds are taking 14 seconds longer.
Besides, I'm having another problem: On Windows I'm experiencing difficulties archiving my node_modules directory. I enable git.long_paths (or something like that), but it's complaining about files it cannot locate.. And surprise surprise, it can't find the long paths ;-) And of course, it's having difficulties restoring the archive as well.
Why are you archiving? Why not using the linking as default? It appears to be much quicker. Perhaps you could work something out by using hard links instead of soft links. This way the data will exist on the disk.
i don't understand people claiming here about slower builds when using cache. if it is slower, don't use it :-) if you ever built an app with npm in your tests with a lot of dependencies you gonna really like this cache! i experienced - to mention something positive here - at least 500% faster builds than without cache.
@ayufan just an idea, but thinking about allowing different compression levels for zip or just plain tar, which should be fastest to be configureable in config.toml what do you think?