Skip to content

Commit a1fb919

Browse files
committed
chore: adjust cache key to share yarn cache between generated projects
1 parent 16dace2 commit a1fb919

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed

.github/workflows/build-templates.yml

+10-14
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
with:
5353
path: |
5454
**/node_modules
55-
key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }}
55+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
5656

5757
- name: Install dependencies
5858
if: steps.root-yarn-cache.outputs.cache-hit != 'true'
@@ -63,14 +63,10 @@ jobs:
6363
run: |
6464
yarn workspace create-react-native-library prepare
6565
66-
- name: Create temporary working directory
67-
run: |
68-
mkdir ../tmp
69-
7066
- name: Create library
71-
working-directory: ../tmp
7267
run: |
73-
../react-native-builder-bob/packages/create-react-native-library/bin/create-react-native-library react-native-test \
68+
WORK_DIR=tmp-${{ matrix.type }}-${{ matrix.language }}-${{ matrix.example }}
69+
./packages/create-react-native-library/bin/create-react-native-library "$WORK_DIR" \
7470
--slug react-native-test \
7571
--description test \
7672
--author-name test \
@@ -80,33 +76,33 @@ jobs:
8076
--type ${{ matrix.type }} \
8177
--languages ${{ matrix.language }} \
8278
--example ${{ matrix.example }}
79+
echo "work_dir=$WORK_DIR" >> $GITHUB_ENV
8380
8481
- name: Cache dependencies of library
8582
id: library-yarn-cache
8683
uses: actions/cache@v3
8784
with:
8885
path: |
89-
../tmp/react-native-test/node_modules
90-
../tmp/example/node_modules
91-
key: ${{ runner.os }}-library-yarn-${{ matrix.type }}-${{ matrix.language }}-${{ matrix.example}}-${{ hashFiles('yarn.lock') }}
86+
${{ env.work_dir }}/**/node_modules
87+
key: ${{ runner.os }}-library-yarn-${{ hashFiles(format(env.work_dir, '/**/package.json')) }}
9288

9389
- name: Install dependencies of library
9490
if: steps.library-yarn-cache.outputs.cache-hit != 'true'
95-
working-directory: ../tmp/react-native-test
91+
working-directory: ${{ env.work_dir }}
9692
run: |
9793
yarn
9894
9995
- name: Lint library
100-
working-directory: ../tmp/react-native-test
96+
working-directory: ${{ env.work_dir }}
10197
run: |
10298
yarn lint
10399
104100
- name: Typecheck library
105-
working-directory: ../tmp/react-native-test
101+
working-directory: ${{ env.work_dir }}
106102
run: |
107103
yarn typescript
108104
109105
- name: Test library
110-
working-directory: ../tmp/react-native-test
106+
working-directory: ${{ env.work_dir }}
111107
run: |
112108
yarn test

0 commit comments

Comments
 (0)