Skip to content

Commit 2393208

Browse files
ci(actions): 💚 improve ci perf (#329)
2 parents 955f7d1 + 472dc43 commit 2393208

File tree

2 files changed

+1929
-5136
lines changed

2 files changed

+1929
-5136
lines changed

.github/workflows/main.yml

Lines changed: 27 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
name: Build
1+
name: main
22

33
on:
44
push:
5-
branches: [main]
5+
branches:
6+
- main
67
pull_request:
78
branches:
89
- main
@@ -21,22 +22,16 @@ jobs:
2122
with:
2223
node-version-file: .nvmrc
2324

24-
- name: Get yarn cache directory path
25-
id: yarn-cache-dir-path
26-
run: echo "::set-output name=dir::$(yarn cache dir)"
27-
2825
- name: Cache node_modules
29-
- uses: actions/cache@v3
30-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
26+
uses: actions/cache@v3
27+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
3128
with:
32-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
33-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
34-
restore-keys: |
35-
${{ runner.os }}-yarn-
29+
path: node_modules
30+
key: modules-${{ hashFiles('yarn-lock.json') }}
3631

3732
- name: Install Dependencies
38-
if: steps.yarn-cache.outputs.cache-hit != 'true'
39-
run: yarn --prefer-offline --frozen-lockfile
33+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
34+
run: yarn --frozen-lockfile
4035

4136
lint:
4237
name: Lint
@@ -53,17 +48,15 @@ jobs:
5348
node-version-file: .nvmrc
5449

5550
- name: Cache node_modules
56-
- uses: actions/cache@v3
57-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
51+
uses: actions/cache@v3
52+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
5853
with:
59-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
60-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
61-
restore-keys: |
62-
${{ runner.os }}-yarn-
54+
path: node_modules
55+
key: modules-${{ hashFiles('yarn-lock.json') }}
6356

6457
- name: Install Dependencies
65-
if: steps.yarn-cache.outputs.cache-hit != 'true'
66-
run: yarn --prefer-offline --frozen-lockfile
58+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
59+
run: yarn --frozen-lockfile
6760

6861
- name: Lint
6962
run: yarn lint
@@ -83,17 +76,15 @@ jobs:
8376
node-version-file: .nvmrc
8477

8578
- name: Cache node_modules
86-
- uses: actions/cache@v3
87-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
79+
uses: actions/cache@v3
80+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
8881
with:
89-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
90-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
91-
restore-keys: |
92-
${{ runner.os }}-yarn-
82+
path: node_modules
83+
key: modules-${{ hashFiles('yarn-lock.json') }}
9384

9485
- name: Install Dependencies
95-
if: steps.yarn-cache.outputs.cache-hit != 'true'
96-
run: yarn --prefer-offline --frozen-lockfile
86+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
87+
run: yarn --frozen-lockfile
9788

9889
- name: Built
9990
run: yarn build
@@ -117,17 +108,15 @@ jobs:
117108
node-version-file: .nvmrc
118109

119110
- name: Cache node_modules
120-
- uses: actions/cache@v3
121-
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
111+
uses: actions/cache@v3
112+
id: cache-node-modules # use this to check for `cache-hit` (`steps.cache-node-modules.outputs.cache-hit != 'true'`)
122113
with:
123-
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
124-
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
125-
restore-keys: |
126-
${{ runner.os }}-yarn-
114+
path: node_modules
115+
key: modules-${{ hashFiles('yarn-lock.json') }}
127116

128117
- name: Install Dependencies
129-
if: steps.yarn-cache.outputs.cache-hit != 'true'
130-
run: yarn --prefer-offline --frozen-lockfile
118+
if: steps.cache-node-modules.outputs.cache-hit != 'true'
119+
run: yarn --frozen-lockfile
131120

132121
- name: Test
133122
run: yarn test -- --maxWorkers 2 --shard ${{ matrix.shard }}

0 commit comments

Comments
 (0)