Skip to content

Commit 20e2ca0

Browse files
authored
ci: Fix node_modules cache sometimes getting stale (#217)
The cache of `node_modules` folder can get stale if changes to `react-native-test-app` was made after the cache has been updated, e.g. when iterating on a PR. This change also bumps several packages, addressing [CVE-2020-15168](GHSA-w7rc-rwvf-8q5r), and switches npm registry to https://registry.npmjs.org.
1 parent a860012 commit 20e2ca0

13 files changed

Lines changed: 2729 additions & 2639 deletions

File tree

.github/workflows/build.yml

Lines changed: 77 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ jobs:
1818
uses: actions/checkout@v2
1919
with:
2020
fetch-depth: 64
21-
- name: Cache /node_modules
21+
- name: Cache /.yarn-offline-mirror
2222
uses: actions/cache@v2
2323
with:
24-
path: node_modules
25-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
24+
path: .yarn-offline-mirror
25+
key: ${{ hashFiles('yarn.lock') }}
2626
- name: Install
2727
run: |
28-
yarn
28+
yarn ci
2929
- name: ClangFormat
3030
if: ${{ github.event_name == 'pull_request' }}
3131
env:
@@ -65,14 +65,14 @@ jobs:
6565
node-version: 12
6666
- name: Checkout
6767
uses: actions/checkout@v2
68-
- name: Cache /example/node_modules
68+
- name: Cache /example/.yarn-offline-mirror
6969
uses: actions/cache@v2
7070
with:
71-
path: example/node_modules
72-
key: example-${{ runner.os }}-${{ hashFiles('example/yarn.lock') }}
71+
path: example/.yarn-offline-mirror
72+
key: ${{ hashFiles('example/yarn.lock') }}
7373
- name: Install
7474
run: |
75-
yarn
75+
yarn ci
7676
working-directory: example
7777
- name: Build
7878
run: |
@@ -99,20 +99,25 @@ jobs:
9999
node-version: 12
100100
- name: Checkout
101101
uses: actions/checkout@v2
102-
- name: Cache /node_modules
102+
- name: Cache /.yarn-offline-mirror
103103
uses: actions/cache@v2
104104
with:
105-
path: node_modules
106-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
107-
- name: Cache /template-example/node_modules
105+
path: .yarn-offline-mirror
106+
key: ${{ hashFiles('yarn.lock') }}
107+
- name: npm pack
108+
run: |
109+
npm pack
110+
shell: bash
111+
- name: Cache /template-example/.yarn-offline-mirror
108112
uses: actions/cache@v2
109113
with:
110114
path: |
111-
template-example/node_modules
115+
template-example/.yarn-offline-mirror
112116
template-example/yarn.lock
113-
key: ${{ matrix.template }}-${{ runner.os }}-${{ hashFiles('p*e.js*') }} # package.json + plopfile.js
117+
key: ${{ matrix.template }}-${{ hashFiles('react-native-test-app-0.0.1-dev.tgz') }}
114118
- name: Install
115-
run: scripts/install-test-template.sh ${{ matrix.template }}
119+
run: |
120+
scripts/install-test-template.sh ${{ matrix.template }}
116121
- name: Build
117122
run: |
118123
set -eo pipefail
@@ -149,14 +154,14 @@ jobs:
149154
uses: actions/checkout@v2
150155
- name: Validate Gradle wrapper
151156
uses: gradle/wrapper-validation-action@v1
152-
- name: Cache /example/node_modules
157+
- name: Cache /example/.yarn-offline-mirror
153158
uses: actions/cache@v2
154159
with:
155-
path: example/node_modules
156-
key: example-${{ runner.os }}-${{ hashFiles('example/yarn.lock') }}
160+
path: example/.yarn-offline-mirror
161+
key: ${{ hashFiles('example/yarn.lock') }}
157162
- name: Install
158163
run: |
159-
yarn
164+
yarn ci
160165
working-directory: example
161166
- name: Build
162167
shell: bash
@@ -166,15 +171,16 @@ jobs:
166171
pushd android 1> /dev/null
167172
./gradlew clean build check test
168173
working-directory: example
169-
- name: Cache /node_modules
174+
- name: Cache /.yarn-offline-mirror
170175
if: ${{ matrix.os == 'macos-latest' }}
171176
uses: actions/cache@v2
172177
with:
173-
path: node_modules
174-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
178+
path: .yarn-offline-mirror
179+
key: ${{ hashFiles('yarn.lock') }}
175180
- name: Install
176181
if: ${{ matrix.os == 'macos-latest' }}
177-
run: yarn
182+
run: |
183+
yarn ci
178184
- name: Run instrumented tests
179185
if: ${{ matrix.os == 'macos-latest' }}
180186
uses: reactivecircus/android-emulator-runner@v2
@@ -205,20 +211,25 @@ jobs:
205211
node-version: 12.9.1
206212
- name: Checkout
207213
uses: actions/checkout@v2
208-
- name: Cache /node_modules
214+
- name: Cache /.yarn-offline-mirror
209215
uses: actions/cache@v2
210216
with:
211-
path: node_modules
212-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
213-
- name: Cache /template-example/node_modules
217+
path: .yarn-offline-mirror
218+
key: ${{ hashFiles('yarn.lock') }}
219+
- name: npm pack
220+
run: |
221+
npm pack
222+
shell: bash
223+
- name: Cache /template-example/.yarn-offline-mirror
214224
uses: actions/cache@v2
215225
with:
216226
path: |
217-
template-example/node_modules
227+
template-example/.yarn-offline-mirror
218228
template-example/yarn.lock
219-
key: ${{ matrix.template }}-${{ runner.os }}-${{ hashFiles('p*e.js*') }} # package.json + plopfile.js
229+
key: ${{ matrix.template }}-${{ hashFiles('react-native-test-app-0.0.1-dev.tgz') }}
220230
- name: Install
221-
run: scripts/install-test-template.sh ${{ matrix.template }}
231+
run: |
232+
scripts/install-test-template.sh ${{ matrix.template }}
222233
shell: bash
223234
- name: Build
224235
run: |
@@ -239,14 +250,14 @@ jobs:
239250
node-version: 12
240251
- name: Checkout
241252
uses: actions/checkout@v2
242-
- name: Cache /example/node_modules
253+
- name: Cache /example/.yarn-offline-mirror
243254
uses: actions/cache@v2
244255
with:
245-
path: example/node_modules
246-
key: example-${{ runner.os }}-${{ hashFiles('example/yarn.lock') }}
256+
path: example/.yarn-offline-mirror
257+
key: ${{ hashFiles('example/yarn.lock') }}
247258
- name: Install
248259
run: |
249-
yarn
260+
yarn ci
250261
working-directory: example
251262
- name: Build
252263
run: |
@@ -273,20 +284,25 @@ jobs:
273284
node-version: 12
274285
- name: Checkout
275286
uses: actions/checkout@v2
276-
- name: Cache /node_modules
287+
- name: Cache /.yarn-offline-mirror
277288
uses: actions/cache@v2
278289
with:
279-
path: node_modules
280-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
281-
- name: Cache /template-example/node_modules
290+
path: .yarn-offline-mirror
291+
key: ${{ hashFiles('yarn.lock') }}
292+
- name: npm pack
293+
run: |
294+
npm pack
295+
shell: bash
296+
- name: Cache /template-example/.yarn-offline-mirror
282297
uses: actions/cache@v2
283298
with:
284299
path: |
285-
template-example/node_modules
300+
template-example/.yarn-offline-mirror
286301
template-example/yarn.lock
287-
key: ${{ matrix.template }}-${{ runner.os }}-${{ hashFiles('p*e.js*') }} # package.json + plopfile.js
302+
key: ${{ matrix.template }}-${{ hashFiles('react-native-test-app-0.0.1-dev.tgz') }}
288303
- name: Install
289-
run: scripts/install-test-template.sh ${{ matrix.template }}
304+
run: |
305+
scripts/install-test-template.sh ${{ matrix.template }}
290306
- name: Build
291307
run: |
292308
set -eo pipefail
@@ -317,14 +333,14 @@ jobs:
317333
node-version: 12
318334
- name: Checkout
319335
uses: actions/checkout@v2
320-
- name: Cache /example/node_modules
336+
- name: Cache /example/.yarn-offline-mirror
321337
uses: actions/cache@v2
322338
with:
323-
path: example/node_modules
324-
key: example-${{ runner.os }}-${{ hashFiles('example/yarn.lock') }}
339+
path: example/.yarn-offline-mirror
340+
key: ${{ hashFiles('example/yarn.lock') }}
325341
- name: Install
326342
run: |
327-
yarn
343+
yarn ci
328344
working-directory: example
329345
- name: Build bundle and create solution
330346
run: |
@@ -359,18 +375,22 @@ jobs:
359375
node-version: 12
360376
- name: Checkout
361377
uses: actions/checkout@v2
362-
- name: Cache /node_modules
378+
- name: Cache /.yarn-offline-mirror
363379
uses: actions/cache@v2
364380
with:
365-
path: node_modules
366-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
367-
- name: Cache /template-example/node_modules
381+
path: .yarn-offline-mirror
382+
key: ${{ hashFiles('yarn.lock') }}
383+
- name: npm pack
384+
run: |
385+
npm pack
386+
shell: bash
387+
- name: Cache /template-example/.yarn-offline-mirror
368388
uses: actions/cache@v2
369389
with:
370390
path: |
371-
template-example/node_modules
391+
template-example/.yarn-offline-mirror
372392
template-example/yarn.lock
373-
key: ${{ matrix.template }}-${{ runner.os }}-${{ hashFiles('p*e.js*') }} # package.json + plopfile.js
393+
key: ${{ matrix.template }}-${{ hashFiles('react-native-test-app-0.0.1-dev.tgz') }}
374394
- name: Install
375395
run: |
376396
scripts/install-test-template.sh ${{ matrix.template }}
@@ -411,16 +431,17 @@ jobs:
411431
node-version: 12
412432
- name: Checkout
413433
uses: actions/checkout@v2
414-
- name: Cache /node_modules
434+
- name: Cache /.yarn-offline-mirror
415435
uses: actions/cache@v2
416436
with:
417-
path: node_modules
418-
key: project-${{ runner.os }}-${{ hashFiles('yarn.lock') }}
437+
path: .yarn-offline-mirror
438+
key: ${{ hashFiles('yarn.lock') }}
419439
- name: Install
420440
run: |
421-
yarn
441+
yarn ci
422442
- name: Release
423443
env:
424444
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
425445
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
426-
run: npx semantic-release
446+
run: |
447+
npx semantic-release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
.gradle/
66
.idea/
77
.vs/
8+
.yarn-offline-mirror/
89
Pods/
910
clang-format-diff.py
1011
coverage/

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
.github/
77
.rubocop.yml
88
.swiftlint.yml
9+
.yarn*
910
Brewfile*
1011
Gemfile*
1112
android/app/build/

.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry "https://registry.npmjs.org"

.yarnrc-offline

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry "https://registry.npmjs.org"
2+
yarn-offline-mirror ".yarn-offline-mirror"

example/.yarnrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
registry "https://registry.npmjs.org"

example/.yarnrc-offline

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
registry "https://registry.npmjs.org"
2+
yarn-offline-mirror ".yarn-offline-mirror"

example/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"build:ios": "mkdirp dist && react-native bundle --entry-file index.js --platform ios --dev true --bundle-output dist/main.ios.jsbundle --assets-dest dist --reset-cache",
88
"build:macos": "mkdirp dist && react-native bundle --entry-file index.js --platform macos --dev true --bundle-output dist/main.macos.jsbundle --assets-dest dist --reset-cache --config=metro.config.macos.js",
99
"build:windows": "mkdirp dist && react-native bundle --entry-file index.js --platform windows --dev true --bundle-output dist/main.windows.bundle --assets-dest dist --reset-cache --config=metro.config.windows.js",
10+
"ci": "yarn --use-yarnrc .yarnrc-offline --prefer-offline",
1011
"start": "react-native start",
1112
"start:macos": "react-native start --config=metro.config.macos.js",
1213
"start:windows": "react-native start --config=metro.config.windows.js"
@@ -22,8 +23,8 @@
2223
"mkdirp": "^0.5.1",
2324
"react": "16.11.0",
2425
"react-native": "0.62.2",
25-
"react-native-macos": "0.62.1",
26+
"react-native-macos": "0.62.10",
2627
"react-native-test-app": "../",
27-
"react-native-windows": "0.62.7"
28+
"react-native-windows": "0.62.9"
2829
}
2930
}

0 commit comments

Comments
 (0)