CI: change cache strategy for node modules
Using gitlab CI cache for node modules installation is not enough reliable on the new forge https://forgemia.inra.fr.
As several runners are available and do not share their cache, the first fix was to set a fixed the runner server in order to assure to get the cache from the same server during a pipeline (See e8ec200f).
But this was not enough since the cache can randomly be cleaned between jobs of a same pipeline.
I think there is 2 strategies to overcome this issue:
- To check the presence of node_modules at the beginning of each job (in
before_script
) and make the installation if necessary - Use artifacts which are linked to a pipeline and can be transmitted between runners.
Both strategies have their advantages. Currently, we use the persistent cache we make a clean installation at each pipeline which is a bit overkill since dependencies are not changing every day. If we do a check that installed npm packages are identical to the one specified in package-lock.json
, we can make the installation only when it's needed. It's a bit tricky to set up and it could be eventually inefficient on 4 runners which has a great probability to clean the cache between pipelines and jobs.
Using artifact is in fact quiet similar to the current situation but without the risk of having node_modules
unavailable in a job of pipeline.