Skip to content

Commit 9ec53f4

Browse files
committed
ci: pull cache from dev branch if one doesn't exist for current
1 parent 84f0f90 commit 9ec53f4

File tree

1 file changed

+41
-40
lines changed

1 file changed

+41
-40
lines changed

.circleci/config.yml

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 2.1
22

33
orbs:
4-
welcome: circleci/[email protected]
4+
welcome: circleci/[email protected]
55

66
jobs:
77
build:
@@ -11,63 +11,64 @@ jobs:
1111
steps:
1212
- checkout
1313
- run:
14-
name: "Update NPM"
15-
command: sudo npm install -g [email protected]
14+
name: 'Update NPM'
15+
command: sudo npm install -g [email protected]
1616
- run:
17-
name: "Update Yarn"
18-
command: yarn policies set-version 1.22.4
17+
name: 'Update Yarn'
18+
command: yarn policies set-version 1.22.4
1919
- run:
20-
name: "Set caching variables"
21-
command: |
22-
LAST_SUCCESSFUL_BUILD_URL="https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/dev?filter=successful&limit=1"
23-
LAST_SUCCESSFUL_COMMIT=`curl -Ss -u "$CIRCLE_TOKEN:" $LAST_SUCCESSFUL_BUILD_URL | jq -r '.[0]["vcs_revision"]'`
24-
echo $LAST_SUCCESSFUL_COMMIT > /tmp/last-successful-commit
25-
echo $CIRCLE_SHA1 > /tmp/current-commit
20+
name: 'Set caching variables'
21+
command: |
22+
LAST_SUCCESSFUL_BUILD_URL="https://circleci.com/api/v1.1/project/github/$CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME/tree/dev?filter=successful&limit=1"
23+
LAST_SUCCESSFUL_COMMIT=`curl -Ss -u "$CIRCLE_TOKEN:" $LAST_SUCCESSFUL_BUILD_URL | jq -r '.[0]["vcs_revision"]'`
24+
echo $LAST_SUCCESSFUL_COMMIT > /tmp/last-successful-commit
25+
echo $CIRCLE_SHA1 > /tmp/current-commit
2626
- restore_cache:
27-
keys:
28-
- build-cache-{{ .Branch }}-{{ checksum "/tmp/last-successful-commit" }}
27+
keys:
28+
- build-cache-{{ .Branch }}-{{ checksum "/tmp/last-successful-commit" }}
29+
- build-cache-dev-{{ checksum "/tmp/last-successful-commit" }}
2930
- run:
30-
name: "Install Dependencies"
31-
command: yarn install
31+
name: 'Install Dependencies'
32+
command: yarn install
3233
- run:
33-
name: "Build Packages"
34-
command: yarn build
34+
name: 'Build Packages'
35+
command: yarn build
3536
- save_cache:
36-
key: repo-{{ .Environment.CIRCLE_SHA1 }}
37-
paths:
38-
- ~/repo
37+
key: repo-{{ .Environment.CIRCLE_SHA1 }}
38+
paths:
39+
- ~/repo
3940
- save_cache:
40-
key: build-cache-{{ .Branch }}-{{ checksum "/tmp/current-commit" }}
41-
paths:
42-
- ~/repo/packages/contract-artifacts/node_modules
43-
- ~/repo/packages/contract-artifacts/lib
44-
- ~/repo/packages/contracts/node_modules
45-
- ~/repo/packages/dev-utils/node_modules
46-
- ~/repo/packages/react-app/node_modules
47-
- ~/repo/packages/subgraph/node_modules
41+
key: build-cache-{{ .Branch }}-{{ checksum "/tmp/current-commit" }}
42+
paths:
43+
- ~/repo/packages/contract-artifacts/node_modules
44+
- ~/repo/packages/contract-artifacts/lib
45+
- ~/repo/packages/contracts/node_modules
46+
- ~/repo/packages/dev-utils/node_modules
47+
- ~/repo/packages/react-app/node_modules
48+
- ~/repo/packages/subgraph/node_modules
4849
test:
4950
working_directory: ~/repo
5051
docker:
5152
- image: circleci/node:10.18.1
5253
steps:
5354
- restore_cache:
54-
keys:
55-
- repo-{{ .Environment.CIRCLE_SHA1 }}
55+
keys:
56+
- repo-{{ .Environment.CIRCLE_SHA1 }}
5657
- run:
57-
name: "Test Packages"
58-
command: yarn test
58+
name: 'Test Packages'
59+
command: yarn test
5960

6061
workflows:
6162
version: 2
6263
main:
6364
jobs:
6465
- build:
65-
filters:
66-
branches:
67-
ignore: gh-pages
66+
filters:
67+
branches:
68+
ignore: gh-pages
6869
- test:
69-
requires:
70-
- build
71-
filters:
72-
branches:
73-
ignore: gh-pages
70+
requires:
71+
- build
72+
filters:
73+
branches:
74+
ignore: gh-pages

0 commit comments

Comments
 (0)