From 2fa04be062df32f3e79e75c20ff9b5a219907ece Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Wed, 3 Aug 2022 03:34:29 -0700 Subject: [PATCH] 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. Screenshot 2022-08-03 at 06 26 14 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: https://github.com/facebook/react-native/pull/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 --- .circleci/config.yml | 43 ++++++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index d4da82a4e9b..fae3a50f247 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -51,10 +51,10 @@ references: checkout_cache_key: &checkout_cache_key v1-checkout gems_cache_key: &gems_cache_key v1-gems-{{ checksum "Gemfile.lock" }} gradle_cache_key: &gradle_cache_key v1-gradle-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }}-{{ checksum "ReactAndroid/gradle.properties" }} - hermes_cache_key: &hermes_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }} - hermes_windows_cache_key: &hermes_windows_cache_key v1-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }} - hermes_tarball_cache_key: &hermes_tarball_cache_key v1-hermes-tarball-{{ checksum "/tmp/hermes/cache/.hermes-cache-key-file" }} - pods_cache_key: &pods_cache_key v6-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} + hermes_cache_key: &hermes_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/hermes/hermesversion" }} + hermes_windows_cache_key: &hermes_windows_cache_key v2-hermes-{{ .Environment.CIRCLE_JOB }}-{{ checksum "tmp/hermes/hermesversion" }} + hermes_tarball_cache_key: &hermes_tarball_cache_key v2-hermes-tarball-{{ checksum "/tmp/hermes/hermesversion" }} + pods_cache_key: &pods_cache_key v7-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} windows_yarn_cache_key: &windows_yarn_cache_key v1-win-yarn-cache-{{ arch }}-{{ checksum "yarn.lock" }} yarn_cache_key: &yarn_cache_key v5-yarn-cache-{{ .Environment.CIRCLE_JOB }} @@ -289,16 +289,6 @@ commands: type: boolean default: False steps: - - run: - name: Setup Hermes cache - command: | - HERMES_CACHE_KEY_FILE="/tmp/hermes/cache/.hermes-cache-key-file" - if [ ! -f "$HERMES_CACHE_KEY_FILE" ]; then - echo "File not found. Creating it using latest commit from main" - mkdir -p /tmp/hermes/cache - git ls-remote https://github.com/facebook/hermes main | cut -f 1 > $HERMES_CACHE_KEY_FILE - fi - cat $HERMES_CACHE_KEY_FILE - restore_cache: keys: - *hermes_tarball_cache_key @@ -474,8 +464,7 @@ jobs: cd scripts sh run_ruby_tests.sh - run_yarn - - attach_workspace: - at: /tmp/hermes/ + - *attach_hermes_workspace - run: | cd packages/rn-tester bundle check || bundle install @@ -535,6 +524,16 @@ jobs: - run: name: "Run Tests: iOS Unit and Integration Tests" command: yarn test-ios + - run: + name: Zip Derived data folder + when: always + command: | + echo "zipping tests results" + cd /Users/distiller/Library/Developer/Xcode + XCRESULT_PATH=$(find . -name '*.xcresult') + tar -zcvf xcresults.tar.gz $XCRESULT_PATH + - store_artifacts: + path: /Users/distiller/Library/Developer/Xcode/xcresults.tar.gz # Optionally, run disabled tests - when: @@ -561,6 +560,7 @@ jobs: - store_test_results: path: ./reports/junit + # ------------------------- # JOBS: Test Android # ------------------------- @@ -745,6 +745,7 @@ jobs: steps: - checkout_code_with_cache - run_yarn + - *attach_hermes_workspace # The macOS machine can run out of storage if Hermes is enabled and built from source. # Since this job does not use the iOS Simulator, deleting it provides a quick way to @@ -765,9 +766,6 @@ jobs: - brew_install: package: cmake - - attach_workspace: - at: /tmp/hermes - - with_hermes_tarball_cache_span: set_tarball_path: True steps: @@ -924,6 +922,7 @@ jobs: HERMES_TAG_SHA=$(git ls-remote https://github.com/facebook/hermes main | cut -f 1 | tr -d '[:space:]') echo $HERMES_TAG_SHA > /tmp/hermes/hermesversion fi + cat /tmp/hermes/hermesversion - restore_cache: key: *hermes_cache_key - run: @@ -932,6 +931,8 @@ jobs: node scripts/hermes/prepare-hermes-for-build $CIRCLE_PULL_REQUEST cp sdks/download/* $HERMES_WS_DIR/download/. cp -r sdks/hermes/* $HERMES_WS_DIR/hermes/. + + cat /tmp/hermes/hermesversion - save_cache: key: *hermes_cache_key paths: @@ -1009,10 +1010,6 @@ jobs: brew install cmake - with_hermes_tarball_cache_span: steps: - - persist_to_workspace: - root: /tmp/hermes/ - paths: - - cache - run: name: Build the Hermes iOS frameworks command: |