Skip to content

Commit 3fdd39b

Browse files
authored
Use workspace caches (codesandbox#2220)
* Use workspace caches * Updategp * Improve caching behaviour * Fix caching * Remove dependency changes
1 parent 0800efe commit 3fdd39b

File tree

1 file changed

+46
-19
lines changed

1 file changed

+46
-19
lines changed

.circleci/config.yml

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,23 @@ version: 2.1
55
################################
66

77
aliases:
8-
- &restore_repo_cache
9-
key: v24-repo-{{ .Environment.CIRCLE_SHA1 }}
8+
- &attach_deps_workspace
9+
at: ~/codesandbox-client
1010

11-
- &save_repo_cache
12-
key: v24-repo-{{ .Environment.CIRCLE_SHA1 }}
11+
- &build_deps_paths
12+
root: ~/codesandbox-client
1313
paths:
14-
- ~/codesandbox-client
14+
- packages/codesandbox-api/dist
15+
- packages/common/lib
16+
- packages/deps/dist
17+
- packages/executors/dist
18+
- packages/node-services/lib
19+
- packages/notifications/lib
20+
- packages/sse-hooks/dist
21+
- standalone-packages/codesandbox-browserfs/dist
22+
- standalone-packages/codesandbox-browserfs/build
23+
- standalone-packages/vscode-textmate/out
24+
- standalone-packages/vscode-textmate/node_modules
1525

1626
- &restore_deps_cache
1727
keys:
@@ -51,20 +61,21 @@ aliases:
5161
paths:
5262
- standalone-packages/codesandbox-browserfs/node_modules
5363

54-
- &restore_prod_build_cache
55-
key: v24-prod-app-build-cache-master
64+
- &restore_prod_homepage_cache
65+
key: v24-prod-homepage-build-cache-master
5666

5767
- &restore_prod_cache
5868
key:
5969
v24-prod-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{
6070
.Environment.CIRCLE_SHA1 }}
6171

62-
- &save_prod_app_cache
72+
# To persist the images built by sharp
73+
- &save_prod_homepage_cache
6374
key:
64-
v24-prod-app-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{
75+
v24-prod-homepage-build-cache-{{ .Environment.CIRCLE_BRANCH }}-{{
6576
.Environment.CIRCLE_SHA1 }}
6677
paths:
67-
- ./packages/homepage/.cache
78+
- ./packages/homepage/public
6879

6980
- &save_prod_cache
7081
key:
@@ -115,22 +126,32 @@ commands:
115126
- run:
116127
name: Build
117128
command: yarn build:deps
118-
- save_cache: *save_repo_cache
129+
- persist_to_workspace: *build_deps_paths
119130
build_prod:
120131
description: 'Build the Application with `yarn build:prod`'
121132
steps:
122-
- restore_cache: *restore_repo_cache
123-
- restore_cache: *restore_prod_build_cache
133+
- checkout
134+
- restore_cache: *restore_deps_cache
135+
- attach_workspace: *attach_deps_workspace
136+
- restore_cache: *restore_prod_homepage_cache
124137
- run:
125138
name: Build Application
126139
command: yarn build:prod
127-
- save_cache: *save_prod_app_cache
128140
- save_cache: *save_prod_cache
141+
- run:
142+
name: Remove non-images from public
143+
command: |
144+
find packages/homepage/public -name "*.js" -type f -delete
145+
find packages/homepage/public -name "*.json" -type f -delete
146+
find packages/homepage/public -name "*.js.map" -type f -delete
147+
- save_cache: *save_prod_homepage_cache
129148
test_integrations:
130149
description:
131150
"Test Integrations with `yarn start:test` & 'yarn test:integrations'"
132151
steps:
133-
- restore_cache: *restore_repo_cache
152+
- checkout
153+
- restore_cache: *restore_deps_cache
154+
- attach_workspace: *attach_deps_workspace
134155
- run:
135156
name: Start Test Server
136157
command: yarn start:test
@@ -154,7 +175,9 @@ commands:
154175
test_jest:
155176
description: 'Test with `yarn test`'
156177
steps:
157-
- restore_cache: *restore_repo_cache
178+
- checkout
179+
- restore_cache: *restore_deps_cache
180+
- attach_workspace: *attach_deps_workspace
158181
- run:
159182
name: Test
160183
command: yarn test --ci --testResultsProcessor="jest-junit"
@@ -163,16 +186,20 @@ commands:
163186
yarn_lint:
164187
description: 'Lint with `yarn lint`'
165188
steps:
166-
- restore_cache: *restore_repo_cache
189+
- checkout
190+
- restore_cache: *restore_deps_cache
191+
- attach_workspace: *attach_deps_workspace
167192
- run:
168193
name: Lint
169194
command: yarn lint
170195
yarn_typecheck:
171196
description: 'Lint with `yarn typecheck`'
172197
steps:
173-
- restore_cache: *restore_repo_cache
198+
- checkout
199+
- restore_cache: *restore_deps_cache
200+
- attach_workspace: *attach_deps_workspace
174201
- run:
175-
name: Lint
202+
name: Typecheck
176203
command: yarn typecheck
177204
docker_cache:
178205
description: 'Cache, Sign In, Create, and Push Docker Image'

0 commit comments

Comments
 (0)