Skip to content

Commit d817548

Browse files
cortinicofacebook-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 Differential Revision: D45909178 fbshipit-source-id: bf2828aeb7f45f4e8e0d5cf11bba5292810d5114
1 parent 0a4a95f commit d817548

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

.circleci/config.yml

Lines changed: 21 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 v1-hermes-{{ .Environment.CIRCLE_JOB }}-windows-{{ checksum "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" }}
@@ -312,9 +313,19 @@ commands:
312313
get_react_native_version:
313314
steps:
314315
- run:
315-
name: Get React Native version
316+
name: Get React Native version on Unix
317+
when: << pipeline.platform != 'windows' >>
316318
command: |
317-
VERSION=$( grep '"version"' packages/react-native/package.json | cut -d '"' -f 4 | head -1)
319+
VERSION=$(cat packages/react-native/package.json | jq -r '.version')
320+
# Save the react native version we are building in a file so we can use that file as part of the cache key.
321+
echo "$VERSION" > /tmp/react-native-version
322+
echo "React Native Version is $(cat /tmp/react-native-version)"
323+
echo "Hermes commit is $(cat /tmp/hermes/hermesversion)"
324+
- run:
325+
name: Get React Native version on Windows
326+
when: << pipeline.platform == 'windows' >>
327+
command: |
328+
$VERSION=cat packages/react-native/package.json | jq -r '.version'
318329
# Save the react native version we are building in a file so we can use that file as part of the cache key.
319330
echo "$VERSION" > /tmp/react-native-version
320331
echo "React Native Version is $(cat /tmp/react-native-version)"
@@ -1146,17 +1157,18 @@ jobs:
11461157
docker:
11471158
- image: debian:bullseye
11481159
resource_class: "xlarge"
1149-
working_directory: /root
11501160
steps:
1161+
- checkout_code_with_cache
11511162
- run:
11521163
name: Install dependencies
11531164
command: |
11541165
apt update
11551166
apt install -y git openssh-client cmake build-essential \
1156-
libreadline-dev libicu-dev zip python3
1167+
libreadline-dev libicu-dev jq zip python3
11571168
- *attach_hermes_workspace
1169+
- get_react_native_version
11581170
- restore_cache:
1159-
key: *hermes_workspace_cache_key
1171+
key: *hermes_linux_cache_key
11601172
- run:
11611173
name: Set up workspace
11621174
command: |
@@ -1175,7 +1187,7 @@ jobs:
11751187
cp /tmp/hermes/build/bin/hermesc /tmp/hermes/linux64-bin/.
11761188
fi
11771189
- save_cache:
1178-
key: *hermes_workspace_cache_key
1190+
key: *hermes_linux_cache_key
11791191
paths:
11801192
- /tmp/hermes/linux64-bin/
11811193
- /tmp/hermes/hermes/destroot/
@@ -1296,7 +1308,9 @@ jobs:
12961308
- MSBUILD_DIR: 'C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\MSBuild\Current\Bin'
12971309
- CMAKE_DIR: 'C:\Program Files\CMake\bin'
12981310
steps:
1311+
- checkout_code_with_cache
12991312
- *attach_hermes_workspace
1313+
- get_react_native_version
13001314
- restore_cache:
13011315
key: *hermes_windows_cache_key
13021316
- run:

0 commit comments

Comments
 (0)