Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cache .git to improve checkout time #33845

Closed
wants to merge 9 commits into from
30 changes: 24 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -419,7 +437,7 @@ jobs:
environment:
- REPORTS_DIR: "./reports/junit"
steps:
- checkout
- checkout_code_with_cache
- setup_artifacts
- setup_ruby
- run:
Expand Down Expand Up @@ -657,7 +675,7 @@ jobs:
- PROJECT_NAME: "iOSTemplateProject"

steps:
- checkout
- checkout_code_with_cache
- run_yarn
- attach_workspace:
at: .
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1057,7 +1075,7 @@ jobs:
default: false
executor: reactnativeios
steps:
- checkout
- checkout_code_with_cache
- run_yarn
- add_ssh_keys:
fingerprints:
Expand Down