加速 Gitlab Runner 上的多个 yarn 安装

Speed up multiple yarn installs on Gitlab Runner

我在一个项目中有多个文件夹,每个文件夹都有自己的 yarn.lock。在 Gitlab Runner 上 运行 时,即使我使用的是 yarn config set cache-folder:

,通过 yarn 安装所有节点模块也需要很长时间
yarn config set cache-folder .yarn-cache

# For each folder with a yarn.lock file:
yarn install \
   --no-progress \
   --pure-lockfile \
   --ignore-platform

然后我的 .gitlab.yml 文件有以下内容:

cache:
  paths:
    - .yarn-cache
    - node_modules

我已经尝试缓存每个文件夹中的每个 node_modules 文件夹,但有时下载和上传缓存到 s3 的时间太长(超过 20 分钟)并且失败。

有没有更合适的原因?或者有什么方法可以加快安装多个 yarn 的速度吗?


注意它们中的每一个也使用本地文件 node_module 可能会有所帮助。

看起来 yarn config set cache-folder .yarn-cache 将缓存文件夹设置为相对于 运行 来自的目录(至少在我使用的纱线版本中)。

我将行更改为 yarn config set cache-folder "$(pwd)/.yarn-cache" ,这样它就是一个绝对路径,看起来缓存现在正在按预期工作。