From 7b703eb78b87ff5aa9d8eea0dfa6899aff46c0be Mon Sep 17 00:00:00 2001 From: Franco Meloni Date: Wed, 18 May 2022 07:43:51 -0700 Subject: [PATCH] Cache .git to improve checkout time (#33845) Summary: Caching the .git to speed up the checkout. https://circleci.com/docs/2.0/caching/#source-caching Screenshot 2022-05-17 at 11 11 54 This doesn't work on the machines that use a docker executor Screenshot 2022-05-17 at 12 17 14 ## Changelog [Infrastructure] - Cache .git to improve checkout time Pull Request resolved: https://github.com/facebook/react-native/pull/33845 Test Plan: Run the change on Circle Reviewed By: hramos, cortinico Differential Revision: D36443844 Pulled By: f-meloni fbshipit-source-id: 7b07e177f4527ed5956f03ad622838f20ad64950 --- .circleci/config.yml | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 4fcac46f444a25..afeeb6fee35f30 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -37,6 +37,7 @@ references: cache_keys: buck_cache_key: &buck_cache_key v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} + 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" }} @@ -102,6 +103,23 @@ executors: # COMMANDS # ------------------------- commands: + # Checkout with cache, on machines that are using Docker the cache is ignored + checkout_code_with_cache: + parameters: + checkout_base_cache_key: + default: *checkout_cache_key + type: string + steps: + - restore_cache: + keys: + - << parameters.checkout_base_cache_key >>-{{ .Branch }}-{{ .Revision }} + - << parameters.checkout_base_cache_key >>-{{ .Branch }}- + - << parameters.checkout_base_cache_key >> + - checkout + - save_cache: + key: << parameters.checkout_base_cache_key >>-{{ .Branch }}-{{ .Revision }} + paths: + - ".git" setup_artifacts: steps: @@ -419,7 +437,7 @@ jobs: environment: - REPORTS_DIR: "./reports/junit" steps: - - checkout + - checkout_code_with_cache - setup_artifacts - setup_ruby - run: @@ -657,7 +675,7 @@ jobs: - PROJECT_NAME: "iOSTemplateProject" steps: - - checkout + - checkout_code_with_cache - run_yarn - attach_workspace: at: . @@ -687,7 +705,7 @@ jobs: test_ios_rntester: executor: reactnativeios steps: - - checkout + - checkout_code_with_cache - run_yarn # The macOS machine can run out of storage if Hermes is enabled and built from source. @@ -742,7 +760,7 @@ jobs: - ANDROID_TOOLS_VERSION: 31.0.0 - GRADLE_OPTS: -Dorg.gradle.daemon=false steps: - - checkout + - checkout_code_with_cache - run: name: Install Node @@ -933,7 +951,7 @@ jobs: environment: - HERMES_WS_DIR: *hermes_workspace_root steps: - - checkout + - checkout_code_with_cache - *attach_hermes_workspace - restore_cache: key: *hermes_cache_key @@ -1057,7 +1075,7 @@ jobs: default: false executor: reactnativeios steps: - - checkout + - checkout_code_with_cache - run_yarn - add_ssh_keys: fingerprints: