Skip to content

Commit c9ea36d

Browse files
committed
ci: refactor pnpm setup and drop node_modules caching
1 parent e826e01 commit c9ea36d

File tree

1 file changed

+24
-69
lines changed

1 file changed

+24
-69
lines changed

.circleci/config.yml

Lines changed: 24 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -4,58 +4,42 @@ orbs:
44
browser-tools: circleci/[email protected]
55

66
commands:
7-
pnpm:
7+
pnpm_setup:
88
steps:
99
- run:
10-
name: Install pnpm
11-
command: sudo corepack enable
12-
10+
name: Install pnpm package manager
11+
command: |
12+
sudo corepack enable
13+
pnpm config set store-dir ~/repo/.pnpm-store
14+
- restore_cache:
15+
name: Restore pnpm package cache
16+
keys:
17+
- pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
1318
- run:
14-
name: Setup pnpm store path
15-
command: pnpm config set store-dir ~/repo/.pnpm-store
19+
name: Install Dependencies
20+
command: pnpm install --frozen-lockfile
1621

1722
jobs:
1823
install:
1924
docker:
2025
- image: cimg/node:20.11.1-browsers
2126
working_directory: ~/repo
22-
environment:
23-
- CYPRESS_CACHE_FOLDER: '~/repo/node_modules/.cache/Cypress'
2427
steps:
25-
# Fetch Code
2628
- checkout
27-
- pnpm
28-
29-
- restore_cache:
30-
keys:
31-
# Restore cached node_modules
32-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
33-
# fallback to using the latest cache if no exact match is found
34-
- v19-dependencies-
35-
36-
- run:
37-
name: Install Dependencies
38-
command: pnpm install --frozen-lockfile
39-
40-
# Save the node_modules cache
29+
- pnpm_setup
4130
- save_cache:
31+
name: Save pnpm package cache
32+
key: pnpm-packages-{{ checksum "pnpm-lock.yaml" }}
4233
paths:
4334
- .pnpm-store
44-
- node_modules
45-
key: v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
4635

4736
validate:
4837
docker:
4938
- image: cimg/node:20.11.1-browsers
5039
working_directory: ~/repo
5140
steps:
5241
- checkout
53-
- pnpm
54-
55-
- restore_cache:
56-
keys:
57-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
58-
42+
- pnpm_setup
5943
- run:
6044
name: Lint + Typecheck
6145
command: pnpm validate
@@ -70,12 +54,7 @@ jobs:
7054
type: string
7155
steps:
7256
- checkout
73-
- pnpm
74-
75-
- restore_cache:
76-
keys:
77-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
78-
57+
- pnpm_setup
7958
- run:
8059
name: Jest Suite
8160
command: pnpm test
@@ -92,12 +71,7 @@ jobs:
9271
working_directory: ~/repo
9372
steps:
9473
- checkout
95-
- pnpm
96-
97-
- restore_cache:
98-
keys:
99-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
100-
74+
- pnpm_setup
10175
- run:
10276
name: Check Bundle Size
10377
command: pnpm run bundle-size:check
@@ -108,16 +82,10 @@ jobs:
10882
working_directory: ~/repo
10983
steps:
11084
- checkout
111-
- pnpm
112-
113-
- restore_cache:
114-
keys:
115-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
116-
85+
- pnpm_setup
11786
- run:
11887
name: Build asset
11988
command: pnpm build
120-
12189
- persist_to_workspace:
12290
root: dist
12391
paths:
@@ -128,25 +96,20 @@ jobs:
12896
- image: cimg/node:20.11.1-browsers
12997
working_directory: ~/repo
13098
environment:
131-
- CYPRESS_CACHE_FOLDER: '~/repo/node_modules/.cache/Cypress'
99+
CYPRESS_CACHE_FOLDER: ~/repo/.cache/Cypress
132100
steps:
133101
- browser-tools/install-chrome
134102
- browser-tools/install-chromedriver
135103
- checkout
136-
- pnpm
137-
104+
- pnpm_setup
105+
- run:
106+
name: Make sure cypress binary is installed
107+
command: pnpm cypress install
138108
- attach_workspace:
139109
at: ~/repo/dist
140-
141-
- restore_cache:
142-
keys:
143-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
144-
145110
- run:
146111
name: 'Run cypress'
147112
command: node browser-test-harness.js browser
148-
149-
# store videos and screenshots (if any) as CI artifacts
150113
- store_artifacts:
151114
path: cypress/videos
152115
- store_artifacts:
@@ -160,22 +123,14 @@ jobs:
160123
- browser-tools/install-chrome
161124
- browser-tools/install-chromedriver
162125
- checkout
163-
- pnpm
164-
126+
- pnpm_setup
165127
- attach_workspace:
166128
at: ~/repo/dist
167-
168-
- restore_cache:
169-
keys:
170-
- v19-dependencies-{{ checksum "pnpm-lock.yaml" }}
171-
172129
- run:
173130
name: Accessibility Audit
174131
command: node browser-test-harness.js accessibility
175-
176132
- store_artifacts:
177133
path: test-reports/lighthouse
178-
179134
- store_test_results:
180135
path: test-reports/lighthouse
181136

0 commit comments

Comments
 (0)