Skip to content

Commit 2fa04be

Browse files
Riccardo Cipolleschifacebook-github-bot
authored andcommitted
Fix edge case where prepare_hermes_workspace and build_hermes_macos where using different hermes commits (#34329)
Summary: This PR fixes an edge case where `prepare_hermes_workspace` job was using a commit to build hermes but `build_hermes_macos` was using a different one. This resulted in cache poisoning where subsequent jobs thoughts to be using a version of Hermes while the restored cache was loading a different one. <img width="1440" alt="Screenshot 2022-08-03 at 06 26 14" src="https://user-images.githubusercontent.com/11162307/182570809-5c6d9323-c3fb-4834-952f-7d07b99c4880.png"> This PR simplifies the flow, creating a single `.hermesversion` file in the `prepare_hermes_workspace` workspace and using that file as key for all the caches. ## Changelog [iOS] [Changed] - upload test result as artifact Pull Request resolved: #34329 Test Plan: CircleCI is now green and all the caches are using the same file to create the checksum. We can verify that by looking at the `Save cache`/`Restore cache` commands related to Hermes. (In the workflow, their hash is always `B1NEL0P0OKhQYtk8DE150bXSoGrdWUweedHKmqNqnjo`) Also, we removed completely the code that could create a version misalignment. Reviewed By: cortinico Differential Revision: D38382895 Pulled By: cipolleschi fbshipit-source-id: 5f5501a7ef313eb56abda336716b24b486a34a1f
1 parent 463af23 commit 2fa04be

1 file changed

Lines changed: 20 additions & 23 deletions

File tree

.circleci/config.yml

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ references:
5151
checkout_cache_key: &checkout_cache_key v1-checkout
5252
gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }}
5353
gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }}
54-
hermes_cache_key: &hermes_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
55-
hermes_windows_cache_key: &hermes_windows_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
56-
hermes_tarball_cache_key: &hermes_tarball_cache_key v1-hermes-tarball-{{ checksum "/tmp/hermes/cache/.hermes-cache-key-file" }}
57-
pods_cache_key: &pods_cache_key v6-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
54+
hermes_cache_key: &hermes_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }}
55+
hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }}
56+
hermes_tarball_cache_key: &hermes_tarball_cache_key v2-hermes-tarball-{{ checksum "/tmp/hermes/hermesversion" }}
57+
pods_cache_key: &pods_cache_key v7-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }}
5858
windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }}
5959
yarn_cache_key: &yarn_cache_key v5-yarn-cache-{{ .Environment.CIRCLE_JOB }}
6060

@@ -289,16 +289,6 @@ commands:
289289
type: boolean
290290
default: False
291291
steps:
292-
- run:
293-
name: Setup Hermes cache
294-
command: |
295-
HERMES_CACHE_KEY_FILE="/tmp/hermes/cache/.hermes-cache-key-file"
296-
if [ ! -f "$HERMES_CACHE_KEY_FILE" ]; then
297-
echo "File not found. Creating it using latest commit from main"
298-
mkdir -p /tmp/hermes/cache
299-
git ls-remote https://github.com/facebook/hermes main | cut -f 1 > $HERMES_CACHE_KEY_FILE
300-
fi
301-
cat $HERMES_CACHE_KEY_FILE
302292
- restore_cache:
303293
keys:
304294
- *hermes_tarball_cache_key
@@ -474,8 +464,7 @@ jobs:
474464
cd scripts
475465
sh run_ruby_tests.sh
476466
- run_yarn
477-
- attach_workspace:
478-
at: /tmp/hermes/
467+
- *attach_hermes_workspace
479468
- run: |
480469
cd packages/rn-tester
481470
bundle check || bundle install
@@ -535,6 +524,16 @@ jobs:
535524
- run:
536525
name: "Run Tests: iOS Unit and Integration Tests"
537526
command: yarn test-ios
527+
- run:
528+
name: Zip Derived data folder
529+
when: always
530+
command: |
531+
echo "zipping tests results"
532+
cd /Users/distiller/Library/Developer/Xcode
533+
XCRESULT_PATH=$(find . -name '*.xcresult')
534+
tar -zcvf xcresults.tar.gz $XCRESULT_PATH
535+
- store_artifacts:
536+
path: /Users/distiller/Library/Developer/Xcode/xcresults.tar.gz
538537

539538
# Optionally, run disabled tests
540539
- when:
@@ -561,6 +560,7 @@ jobs:
561560
- store_test_results:
562561
path: ./reports/junit
563562

563+
564564
# -------------------------
565565
# JOBS: Test Android
566566
# -------------------------
@@ -745,6 +745,7 @@ jobs:
745745
steps:
746746
- checkout_code_with_cache
747747
- run_yarn
748+
- *attach_hermes_workspace
748749

749750
# The macOS machine can run out of storage if Hermes is enabled and built from source.
750751
# Since this job does not use the iOS Simulator, deleting it provides a quick way to
@@ -765,9 +766,6 @@ jobs:
765766
- brew_install:
766767
package: cmake
767768

768-
- attach_workspace:
769-
at: /tmp/hermes
770-
771769
- with_hermes_tarball_cache_span:
772770
set_tarball_path: True
773771
steps:
@@ -924,6 +922,7 @@ jobs:
924922
HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]')
925923
echo $HERMES_TAG_SHA > /tmp/hermes/hermesversion
926924
fi
925+
cat /tmp/hermes/hermesversion
927926
- restore_cache:
928927
key: *hermes_cache_key
929928
- run:
@@ -932,6 +931,8 @@ jobs:
932931
node scripts/hermes/prepare-hermes-for-build $CIRCLE_PULL_REQUEST
933932
cp sdks/download/* $HERMES_WS_DIR/download/.
934933
cp -r sdks/hermes/* $HERMES_WS_DIR/hermes/.
934+
935+
cat /tmp/hermes/hermesversion
935936
- save_cache:
936937
key: *hermes_cache_key
937938
paths:
@@ -1009,10 +1010,6 @@ jobs:
10091010
brew install cmake
10101011
- with_hermes_tarball_cache_span:
10111012
steps:
1012-
- persist_to_workspace:
1013-
root: /tmp/hermes/
1014-
paths:
1015-
- cache
10161013
- run:
10171014
name: Build the Hermes iOS frameworks
10181015
command: |

0 commit comments

Comments
 (0)