From 01d7ec13b1402edb599cf818eb1cf2f37fccf9a7 Mon Sep 17 00:00:00 2001 From: Moti Zilberman Date: Mon, 11 Sep 2023 05:53:45 -0700 Subject: [PATCH] Use Hermes-engine version in caches for RNTester jobs (#39366) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/39366 With the recent CI optimization, we were caching the hermes-engine stored in the Pods folder in order to reuse it. However, by doing so, we would not avtually use the hermes-engine we were building in CI nor we were using the most recent version in the E2E tests as the Podfile.lock would not have actually changed and Cocoapods would have found a proper version for the Hermes-engine. ## Changelog: [Internal] - use the hermes engine version to invalidate cocoapods caches Reviewed By: blakef Differential Revision: D49125000 fbshipit-source-id: 2af81522d02a7f461fe3ab5b98a4f314013c185a --- .circleci/configurations/commands.yml | 18 ++++++++++++++++++ .circleci/configurations/jobs.yml | 21 ++------------------- .circleci/configurations/top_level.yml | 4 ++-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/.circleci/configurations/commands.yml b/.circleci/configurations/commands.yml index 2f7c7b67b14..0461946330a 100644 --- a/.circleci/configurations/commands.yml +++ b/.circleci/configurations/commands.yml @@ -180,6 +180,24 @@ commands: name: Report size of RNTester.app (analysis-bot) command: GITHUB_TOKEN="$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_A""$PUBLIC_ANALYSISBOT_GITHUB_TOKEN_B" scripts/circleci/report-bundle-size.sh << parameters.platform >> || true + setup_hermes_version: + steps: + - run: + name: Set up Hermes workspace and caching + command: | + mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes" + + if [ -f "$HERMES_VERSION_FILE" ]; then + echo "Hermes Version file found! Using this version for the build:" + cat $HERMES_VERSION_FILE > /tmp/hermes/hermesversion + else + echo "Hermes Version file not found!!!" + echo "Using the last commit from main for the build:" + 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 + get_react_native_version: steps: - run: diff --git a/.circleci/configurations/jobs.yml b/.circleci/configurations/jobs.yml index c3a2aa0ca34..7e9e3810f6f 100644 --- a/.circleci/configurations/jobs.yml +++ b/.circleci/configurations/jobs.yml @@ -122,8 +122,7 @@ jobs: steps: - checkout_code_with_cache - run_yarn - - attach_workspace: - at: . + - setup_hermes_version - run: name: Install appium command: npm install appium@2.0.0 -g @@ -219,8 +218,6 @@ jobs: cd packages/rn-tester yarn start background: true - - attach_workspace: - at: . - with_gradle_cache: steps: - run: @@ -688,21 +685,7 @@ jobs: apt install -y nodejs npm install --global yarn - checkout - - run: - name: Set up Hermes workspace and caching - command: | - mkdir -p "/tmp/hermes" "/tmp/hermes/download" "/tmp/hermes/hermes" - - if [ -f "$HERMES_VERSION_FILE" ]; then - echo "Hermes Version file found! Using this version for the build:" - cat $HERMES_VERSION_FILE > /tmp/hermes/hermesversion - else - echo "Hermes Version file not found!!!" - echo "Using the last commit from main for the build:" - 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 + - setup_hermes_version - get_react_native_version - restore_cache: key: *hermes_workspace_cache_key diff --git a/.circleci/configurations/top_level.yml b/.circleci/configurations/top_level.yml index bbc35b1455b..1787c721521 100644 --- a/.circleci/configurations/top_level.yml +++ b/.circleci/configurations/top_level.yml @@ -91,11 +91,11 @@ references: hermes_dsym_release_cache_key: &hermes_dsym_release_cache_key v1-hermes-release-dsym-{{ checksum "/tmp/hermes/hermesversion" }}-{{ checksum "/tmp/react-native-version" }} # Cocoapods - RNTester pods_cache_key: &pods_cache_key v10-pods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock.bak" }}-{{ checksum "packages/rn-tester/Podfile" }} - cocoapods_cache_key: &cocoapods_cache_key v7-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }} + cocoapods_cache_key: &cocoapods_cache_key v7-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile.lock" }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }} rntester_podfile_lock_cache_key: &rntester_podfile_lock_cache_key v5-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "packages/rn-tester/Podfile" }}-{{ checksum "/tmp/week_year" }} # Cocoapods - Template - template_cocoapods_cache_key: &template_cocoapods_cache_key v1-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }} + template_cocoapods_cache_key: &template_cocoapods_cache_key v1-cocoapods-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile.lock" }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/hermes/hermesversion" }} template_podfile_lock_cache_key: &template_podfile_lock_cache_key v1-podfilelock-{{ .Environment.CIRCLE_JOB }}-{{ checksum "/tmp/iOSTemplateProject/ios/Podfile" }}-{{ checksum "/tmp/week_year" }} # Windows