Skip to content

Commit e51b78b

Browse files
committed
chore(ci): make github primary cache keys unique so caches update
github workflow caches are considered immutable, they will never update if there was a hit on the primary cache key ergo, if the primary cache key never changes the caches will never update and you will only ever get fresh caches by chance if stale caches are evicted via LRU cache storage limit management So, all cache primary keys are unique now according to the requirements of the specific cache - the AVD cache is now unique on the api-level/target/arch tuple, and that is set and referenced in an environment variable since it is now used in two places - the firebase emulator cache is set based on the firebase-tools version, which always changes when new emulator versions are downloaded
1 parent f44b958 commit e51b78b

File tree

5 files changed

+58
-37
lines changed

5 files changed

+58
-37
lines changed

.github/workflows/android.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ jobs:
3333
matrix:
3434
working_directory:
3535
['tests', 'packages/cloud_firestore/cloud_firestore/example']
36+
env:
37+
AVD_ARCH: x86_64
38+
AVD_API_LEVEL: 34
39+
AVD_TARGET: google_apis
3640
steps:
3741
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
3842
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
@@ -43,14 +47,18 @@ jobs:
4347
with:
4448
distribution: 'temurin'
4549
java-version: '21'
50+
- name: 'Install Tools'
51+
run: |
52+
sudo npm i -g firebase-tools
53+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
4654
- name: Firebase Emulator Cache
4755
id: firebase-emulator-cache
4856
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
4957
continue-on-error: true
5058
with:
5159
# Must match the save path exactly
5260
path: ~/.cache/firebase/emulators
53-
key: firebase-emulators-v3-${{ runner.os }}
61+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
5462
restore-keys: firebase-emulators-v3
5563
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
5664
with:
@@ -64,9 +72,6 @@ jobs:
6472
melos-version: '5.3.0'
6573
- name: 'Bootstrap package'
6674
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
67-
- name: 'Install Tools'
68-
run: |
69-
sudo npm i -g firebase-tools
7075
- name: Start Firebase Emulator
7176
run: cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
7277
- name: Enable KVM
@@ -93,13 +98,13 @@ jobs:
9398
path: |
9499
~/.android/avd/*
95100
~/.android/adb*
96-
key: avd-${{ runner.os }}
101+
key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }}
97102
- name: Start AVD then run E2E tests
98103
uses: reactivecircus/android-emulator-runner@b530d96654c385303d652368551fb075bc2f0b6b
99104
with:
100-
api-level: 34
101-
target: google_apis
102-
arch: x86_64
105+
api-level: ${{ env.AVD_API_LEVEL }}
106+
target: ${{ env.AVD_TARGET }}
107+
arch: ${{ env.AVD_ARCH }}
103108
emulator-build: 14214601
104109
working-directory: ${{ matrix.working_directory }}
105110
script: |

.github/workflows/e2e_tests_fdc.yaml

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ jobs:
2727
timeout-minutes: 45
2828
strategy:
2929
fail-fast: false
30+
env:
31+
AVD_ARCH: x86_64
32+
AVD_API_LEVEL: 34
33+
AVD_TARGET: google_apis
3034
steps:
3135
- uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938
3236
- uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a
@@ -37,14 +41,18 @@ jobs:
3741
with:
3842
distribution: 'temurin'
3943
java-version: '21'
44+
- name: 'Install Tools'
45+
run: |
46+
sudo npm i -g firebase-tools
47+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
4048
- name: Firebase Emulator Cache
4149
id: firebase-emulator-cache
4250
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
4351
continue-on-error: true
4452
with:
4553
# Must match the save path exactly
4654
path: ~/.cache/firebase/emulators
47-
key: firebase-emulators-v3-fdc-${{ runner.os }}
55+
key: firebase-emulators-v3-fdc-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
4856
restore-keys: firebase-emulators-v3
4957
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
5058
with:
@@ -58,9 +66,6 @@ jobs:
5866
melos-version: '5.3.0'
5967
- name: 'Bootstrap package'
6068
run: melos bootstrap --scope "firebase_data_connect*"
61-
- name: 'Install Tools'
62-
run: |
63-
sudo npm i -g firebase-tools
6469
- name: Start Firebase Emulator
6570
run: |
6671
cd ./packages/firebase_data_connect/firebase_data_connect/example
@@ -91,13 +96,13 @@ jobs:
9196
path: |
9297
~/.android/avd/*
9398
~/.android/adb*
94-
key: avd-${{ runner.os }}
99+
key: avd-${{ runner.os }}-${{ env.AVD_API_LEVEL }}-${{ env.AVD_TARGET }}-${{ env.AVD_ARCH }}
95100
- name: Start AVD then run E2E tests
96101
uses: reactivecircus/android-emulator-runner@v2
97102
with:
98-
api-level: 34
99-
target: google_apis
100-
arch: x86_64
103+
api-level: ${{ env.AVD_API_LEVEL }}
104+
target: ${{ env.AVD_TARGET }}
105+
arch: ${{ env.AVD_ARCH }}
101106
emulator-build: 14214601
102107
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
103108
script: |
@@ -157,14 +162,18 @@ jobs:
157162
path: tests/ios/Pods
158163
key: ${{ runner.os }}-fdc-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
159164
restore-keys: ${{ runner.os }}-ios-pods-v2
165+
- name: 'Install Tools'
166+
run: |
167+
sudo npm i -g firebase-tools
168+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
160169
- name: Firebase Emulator Cache
161170
id: firebase-emulator-cache
162171
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
163172
continue-on-error: true
164173
with:
165174
# Must match the save path exactly
166175
path: ~/.cache/firebase/emulators
167-
key: firebase-emulators-v3-fdc-${{ runner.os }}
176+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
168177
restore-keys: firebase-emulators-v3
169178
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
170179
with:
@@ -176,9 +185,6 @@ jobs:
176185
melos-version: '5.3.0'
177186
- name: 'Bootstrap package'
178187
run: melos bootstrap --scope "firebase_data_connect*"
179-
- name: 'Install Tools'
180-
run: |
181-
sudo npm i -g firebase-tools
182188
- name: 'Build Application'
183189
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
184190
run: |
@@ -257,15 +263,17 @@ jobs:
257263
- name: 'Bootstrap package'
258264
run: melos bootstrap --scope "firebase_data_connect*"
259265
- name: 'Install Tools'
260-
run: sudo npm i -g firebase-tools
261-
- name: Firebase Emulator Cache
266+
run: |
267+
sudo npm i -g firebase-tools
268+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
269+
- name: Firebase Emulator Cache
262270
id: firebase-emulator-cache
263271
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
264272
continue-on-error: true
265273
with:
266274
# Must match the save path exactly
267275
path: ~/.cache/firebase/emulators
268-
key: firebase-emulators-v3-fdc-${{ runner.os }}
276+
key: firebase-emulators-v3-fdc-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
269277
restore-keys: firebase-emulators-v3
270278
- name: Start Firebase Emulator
271279
run: |

.github/workflows/ios.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,18 @@ jobs:
6060
path: tests/ios/Pods
6161
key: pods-v3-${{ runner.os }}-${{ hashFiles('tests/ios/Podfile.lock') }}
6262
restore-keys: pods-v3-${{ runner.os }}
63+
- name: 'Install Tools'
64+
run: |
65+
sudo npm i -g firebase-tools
66+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
6367
- name: Firebase Emulator Cache
6468
id: firebase-emulator-cache
6569
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
6670
continue-on-error: true
6771
with:
6872
# Must match the save path exactly
6973
path: ~/.cache/firebase/emulators
70-
key: firebase-emulators-v3-${{ runner.os }}
74+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
7175
restore-keys: firebase-emulators-v3
7276
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
7377
with:
@@ -81,9 +85,6 @@ jobs:
8185
melos-version: '5.3.0'
8286
- name: 'Bootstrap package'
8387
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
84-
- name: 'Install Tools'
85-
run: |
86-
sudo npm i -g firebase-tools
8788
- name: 'Free up space'
8889
run: |
8990
sudo rm -rf \

.github/workflows/macos.yaml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,18 @@ jobs:
5858
path: tests/macos/Pods
5959
key: pods-v3-${{ runner.os }}-${{ hashFiles('tests/macos/Podfile.lock') }}
6060
restore-keys: pods-v3-${{ runner.os }}
61+
- name: 'Install Tools'
62+
run: |
63+
sudo npm i -g firebase-tools
64+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
6165
- name: Firebase Emulator Cache
6266
id: firebase-emulator-cache
6367
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
6468
continue-on-error: true
6569
with:
6670
# Must match the save path exactly
6771
path: ~/.cache/firebase/emulators
68-
key: firebase-emulators-v3-${{ runner.os }}
72+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
6973
restore-keys: firebase-emulators-v3
7074
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
7175
with:
@@ -79,9 +83,6 @@ jobs:
7983
melos-version: '5.3.0'
8084
- name: 'Bootstrap package'
8185
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
82-
- name: 'Install Tools'
83-
run: |
84-
sudo npm i -g firebase-tools
8586
- name: 'Build Application'
8687
working-directory: ${{ matrix.working_directory }}
8788
run: |

.github/workflows/web.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,15 +56,17 @@ jobs:
5656
- name: 'Bootstrap package'
5757
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
5858
- name: 'Install Tools'
59-
run: sudo npm i -g firebase-tools
59+
run: |
60+
sudo npm i -g firebase-tools
61+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
6062
- name: Firebase Emulator Cache
6163
id: firebase-emulator-cache
6264
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
6365
continue-on-error: true
6466
with:
6567
# Must match the save path exactly
6668
path: ~/.cache/firebase/emulators
67-
key: firebase-emulators-v3-${{ runner.os }}
69+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
6870
restore-keys: firebase-emulators-v3
6971
- name: Start Firebase Emulator
7072
run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
@@ -120,15 +122,17 @@ jobs:
120122
- name: 'Bootstrap package'
121123
run: melos bootstrap --scope tests
122124
- name: 'Install Tools'
123-
run: sudo npm i -g firebase-tools
125+
run: |
126+
sudo npm i -g firebase-tools
127+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
124128
- name: Firebase Emulator Cache
125129
id: firebase-emulator-cache
126130
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
127131
continue-on-error: true
128132
with:
129133
# Must match the save path exactly
130134
path: ~/.cache/firebase/emulators
131-
key: firebase-emulators-v3-${{ runner.os }}
135+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
132136
restore-keys: firebase-emulators-v3
133137
- name: Start Firebase Emulator
134138
run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh
@@ -189,15 +193,17 @@ jobs:
189193
- name: 'Bootstrap package'
190194
run: melos bootstrap --scope tests && melos bootstrap --scope "cloud_firestore*"
191195
- name: 'Install Tools'
192-
run: sudo npm i -g firebase-tools
196+
run: |
197+
sudo npm i -g firebase-tools
198+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
193199
- name: Firebase Emulator Cache
194200
id: firebase-emulator-cache
195201
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
196202
continue-on-error: true
197203
with:
198204
# Must match the save path exactly
199205
path: ~/.cache/firebase/emulators
200-
key: firebase-emulators-v3-${{ runner.os }}
206+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
201207
restore-keys: firebase-emulators-v3
202208
- name: Start Firebase Emulator
203209
run: sudo chown -R 501:20 "/Users/runner/.npm" && cd ./.github/workflows/scripts && ./start-firebase-emulator.sh

0 commit comments

Comments
 (0)