Skip to content

Commit b6b12f4

Browse files
committed
[CI] Cache the result of pip install and npm install
1 parent 7d8b12f commit b6b12f4

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

.circleci/config.yml

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,14 @@ commands:
5757
bootstrap:
5858
description: "bootstrap"
5959
steps:
60+
- restore_cache:
61+
keys:
62+
- bootstrap-node-deps-{{ arch }}-{{ checksum "package-lock.json" }}
6063
- run: ./bootstrap
64+
- save_cache:
65+
key: bootstrap-node-deps-{{ arch }}-{{ checksum "package-lock.json" }}
66+
paths:
67+
- node_modules
6168
pip-install:
6269
description: "pip install"
6370
parameters:
@@ -66,9 +73,22 @@ commands:
6673
type: string
6774
default: python3
6875
steps:
76+
- restore_cache:
77+
keys:
78+
- python-deps-v2-{{ arch }}-{{ .Environment.USER }}-{{ checksum "requirements-dev.txt" }}
6979
- run:
7080
name: pip install
71-
command: << parameters.python >> -m pip install -r requirements-dev.txt
81+
command: |
82+
if [[ -e ~/.cache/pip ]]; then
83+
echo "Skipping npm ci due to cache hit"
84+
else
85+
<< parameters.python >> -m pip install -r requirements-dev.txt
86+
fi
87+
- save_cache:
88+
key: python-deps-v2-{{ arch }}-{{ .Environment.USER }}-{{ checksum "requirements-dev.txt" }}
89+
paths:
90+
- ~/.cache/pip
91+
- ~/.local/bin
7292
install-rust:
7393
steps:
7494
- run:
@@ -557,10 +577,24 @@ jobs:
557577
executor: linux-node
558578
steps:
559579
- checkout
560-
- run: npm ci
580+
- restore_cache:
581+
keys:
582+
- node-deps-{{ arch }}-{{ checksum "package-lock.json" }}
583+
- run:
584+
name: npm ci
585+
command: |
586+
if [[ -e node_modules ]]; then
587+
echo "Skipping npm ci due to cache hit"
588+
else
589+
npm ci
590+
fi
561591
- run: |
562592
npm run lint
563593
npm run check
594+
- save_cache:
595+
key: node-deps-{{ arch }}-{{ checksum "package-lock.json" }}
596+
paths:
597+
- node_modules
564598
test-sanity:
565599
executor: ubuntu-lts
566600
steps:

0 commit comments

Comments
 (0)