Skip to content

Commit c56968c

Browse files
cipolleschifacebook-github-bot
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
1 parent d6c4f27 commit c56968c

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

.circleci/config.yml

Lines changed: 25 additions & 8 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:
@@ -729,7 +743,7 @@ jobs:
729743

730744
- store_test_results:
731745
path: ~/react-native/packages/react-native-gradle-plugin/build/test-results
732-
746+
733747
- store_test_results:
734748
path: ~/react-native/packages/react-native/ReactAndroid/build/test-results
735749

@@ -1146,17 +1160,18 @@ jobs:
11461160
docker:
11471161
- image: debian:bullseye
11481162
resource_class: "xlarge"
1149-
working_directory: /root
11501163
steps:
1164+
- checkout_code_with_cache
11511165
- run:
11521166
name: Install dependencies
11531167
command: |
11541168
apt update
11551169
apt install -y git openssh-client cmake build-essential \
1156-
libreadline-dev libicu-dev zip python3
1170+
libreadline-dev libicu-dev jq zip python3
11571171
- *attach_hermes_workspace
1172+
- get_react_native_version
11581173
- restore_cache:
1159-
key: *hermes_workspace_cache_key
1174+
key: *hermes_linux_cache_key
11601175
- run:
11611176
name: Set up workspace
11621177
command: |
@@ -1175,7 +1190,7 @@ jobs:
11751190
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
11761191
fi
11771192
- save_cache:
1178-
key: *hermes_workspace_cache_key
1193+
key: *hermes_linux_cache_key
11791194
paths:
11801195
- /tmp/hermes/linux64-bin/
11811196
- /tmp/hermes/hermes/destroot/
@@ -1296,7 +1311,9 @@ jobs:
12961311
- MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
12971312
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
12981313
steps:
1314+
- checkout_code_with_cache
12991315
- *attach_hermes_workspace
1316+
- get_react_native_version_windows
13001317
- restore_cache:
13011318
key: *hermes_windows_cache_key
13021319
- run:

0 commit comments

Comments
 (0)