Skip to content

Commit 2c4d1b0

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 9f0c10b commit 2c4d1b0

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: |
@@ -156,14 +161,18 @@ jobs:
156161
path: tests/ios/Pods
157162
key: ${{ runner.os }}-fdc-pods-v3-${{ hashFiles('tests/ios/Podfile.lock') }}
158163
restore-keys: ${{ runner.os }}-ios-pods-v2
164+
- name: 'Install Tools'
165+
run: |
166+
sudo npm i -g firebase-tools
167+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
159168
- name: Firebase Emulator Cache
160169
id: firebase-emulator-cache
161170
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
162171
continue-on-error: true
163172
with:
164173
# Must match the save path exactly
165174
path: ~/.cache/firebase/emulators
166-
key: firebase-emulators-v3-fdc-${{ runner.os }}
175+
key: firebase-emulators-v3-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
167176
restore-keys: firebase-emulators-v3
168177
- uses: subosito/flutter-action@f2c4f6686ca8e8d6e6d0f28410eeef506ed66aff
169178
with:
@@ -175,9 +184,6 @@ jobs:
175184
melos-version: '5.3.0'
176185
- name: 'Bootstrap package'
177186
run: melos bootstrap --scope "firebase_data_connect*"
178-
- name: 'Install Tools'
179-
run: |
180-
sudo npm i -g firebase-tools
181187
- name: 'Build Application'
182188
working-directory: 'packages/firebase_data_connect/firebase_data_connect/example'
183189
run: |
@@ -256,15 +262,17 @@ jobs:
256262
- name: 'Bootstrap package'
257263
run: melos bootstrap --scope "firebase_data_connect*"
258264
- name: 'Install Tools'
259-
run: sudo npm i -g firebase-tools
260-
- name: Firebase Emulator Cache
265+
run: |
266+
sudo npm i -g firebase-tools
267+
echo "FIREBASE_TOOLS_VERSION=$(npm firebase --version)" >> $GITHUB_ENV
268+
- name: Firebase Emulator Cache
261269
id: firebase-emulator-cache
262270
uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
263271
continue-on-error: true
264272
with:
265273
# Must match the save path exactly
266274
path: ~/.cache/firebase/emulators
267-
key: firebase-emulators-v3-fdc-${{ runner.os }}
275+
key: firebase-emulators-v3-fdc-${{ runner.os }}-${{ env.FIREBASE_TOOLS_VERSION }}
268276
restore-keys: firebase-emulators-v3
269277
- name: Start Firebase Emulator
270278
run: |

.github/workflows/ios.yaml

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

.github/workflows/macos.yaml

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