【发布时间】:2021-03-26 10:11:31
【问题描述】:
我正在为位于我的 repo 的 backend/core 文件夹中的现有 Express 服务器项目设置 CI。从基本设置和 linting 开始。我能够让 npm install 和 linting 工作,但我想缓存依赖项,这样每次推送就不需要 4 分钟加载。
我使用了他们描述的缓存方案here,但它似乎仍然每次都运行完整安装。或者如果它使用缓存的依赖项,它每次都安装 grpc,这需要一段时间。有什么想法我能做什么?
我的 config.yml 供参考:
# Use the latest 2.1 version of CircleCI pipeline process engine. See: https://circleci.com/docs/2.0/configuration-reference
# default executors
executors:
core-executor:
docker:
- image: 'cimg/base:stable'
commands:
init_env:
description: initialize environment
steps:
- checkout
- node/install
- restore_cache:
keys:
# when lock file changes, use increasingly general patterns to restore cache
- node-v1-{{ .Branch }}-{{ checksum "backend/core/package-lock.json" }}
- node-v1-{{ .Branch }}-
- node-v1-
- run: npm --prefix ./backend/core install
- save_cache:
paths:
- ~/backend/core/usr/local/lib/node_modules # location depends on npm version
key: node-v1-{{ .Branch }}-{{ checksum "backend/core/package-lock.json" }}
jobs:
install-node:
executor: core-executor
steps:
- checkout
- node/install
- run: node --version
- run: pwd
- run: ls -A
- run: npm --prefix ./backend/core install
lint:
executor: core-executor
steps:
- init_env
- run: pwd
- run: ls -A
- run: ls backend
- run: ls backend/core -A
- run: npm --prefix ./backend/core run lint
orbs:
node: circleci/node@4.1.0
version: 2.1
workflows:
test_my_app:
jobs:
#- install-node
- lint
#requires:
#- install-node
【问题讨论】:
标签: node.js npm caching circleci circleci-2.0