Skip to content

Commit ad965a1

Browse files
cipolleschikelset
authored andcommitted
Make CircleCI caches for hermesc be version dependent (#37452)
Summary: Pull Request resolved: #37452 Fixes #37428 We do have cache poisoning for hermesc on Windows and Linux due to reusing the same cache key among different React Native version. This fixes it by specifying a cache key which is version dependent + it invalidates the caches by defining a new key. Changelog: [Internal] [Fixed] - Make CircleCI caches for hermesc be version dependent Reviewed By: cortinico Differential Revision: D45909178 fbshipit-source-id: 830c87ae45739c7053342a68dac2ee7581945c1d # Conflicts: # .circleci/config.yml
1 parent 47b45df commit ad965a1

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

.circleci/config.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ references:
6262
hermes_workspace_cache_key: &hermes_workspace_cache_key v4-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
6363
hermes_workspace_debug_cache_key: &hermes_workspace_debug_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
6464
hermes_workspace_release_cache_key: &hermes_workspace_release_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
65-
hermes_windows_cache_key: &hermes_windows_cache_key v3-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
65+
hermes_linux_cache_key: &hermes_linux_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-linux-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
66+
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "/Users/circleci/project/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
6667
hermes_tarball_debug_cache_key: &hermes_tarball_debug_cache_key v4-hermes-tarball-debug-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
6768
hermes_tarball_release_cache_key: &hermes_tarball_release_cache_key v3-hermes-tarball-release-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }}
6869
pods_cache_key: &pods_cache_key v8-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
@@ -314,11 +315,24 @@ commands:
314315
- run:
315316
name: Get React Native version
316317
command: |
317-
VERSION=$( grep '"version"' packages/react-native/package.json | cut -d '"' -f 4 | head -1)
318+
VERSION=$(cat packages/react-native/package.json | jq -r '.version')
318319
# Save the react native version we are building in a file so we can use that file as part of the cache key.
319320
echo "$VERSION" > /tmp/react-native-version
320321
echo "React Native Version is $(cat /tmp/react-native-version)"
321-
echo "Hermes commit is $(cat /tmp/hermes/hermesversion)"
322+
HERMES_VERSION="$(cat /tmp/hermes/hermesversion)"
323+
echo "Hermes commit is $HERMES_VERSION"
324+
325+
get_react_native_version_windows:
326+
steps:
327+
- run:
328+
name: Get React Native version on Windows
329+
command: |
330+
$VERSION=cat packages/react-native/package.json | jq -r '.version'
331+
# Save the react native version we are building in a file so we can use that file as part of the cache key.
332+
echo "$VERSION" > /tmp/react-native-version
333+
echo "React Native Version is $(cat /tmp/react-native-version)"
334+
$HERMES_VERSION=cat C:\Users\circleci\project\tmp\hermes\hermesversion
335+
echo "Hermes commit is $HERMES_VERSION"
322336
323337
with_hermes_tarball_cache_span:
324338
parameters:
@@ -1172,17 +1186,18 @@ jobs:
11721186
docker:
11731187
- image: debian:bullseye
11741188
resource_class: "xlarge"
1175-
working_directory: /root
11761189
steps:
1190+
- checkout_code_with_cache
11771191
- run:
11781192
name: Install dependencies
11791193
command: |
11801194
apt update
11811195
apt install -y git openssh-client cmake build-essential \
1182-
libreadline-dev libicu-dev zip python3
1196+
libreadline-dev libicu-dev jq zip python3
11831197
- *attach_hermes_workspace
1198+
- get_react_native_version
11841199
- restore_cache:
1185-
key: *hermes_workspace_cache_key
1200+
key: *hermes_linux_cache_key
11861201
- run:
11871202
name: Set up workspace
11881203
command: |
@@ -1201,7 +1216,7 @@ jobs:
12011216
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
12021217
fi
12031218
- save_cache:
1204-
key: *hermes_workspace_cache_key
1219+
key: *hermes_linux_cache_key
12051220
paths:
12061221
- /tmp/hermes/linux64-bin/
12071222
- /tmp/hermes/hermes/destroot/
@@ -1322,7 +1337,9 @@ jobs:
13221337
- MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
13231338
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
13241339
steps:
1340+
- checkout_code_with_cache
13251341
- *attach_hermes_workspace
1342+
- get_react_native_version_windows
13261343
- restore_cache:
13271344
key: *hermes_windows_cache_key
13281345
- run:

0 commit comments

Comments
 (0)