Skip to content

Commit

Permalink
🏗 🚀 Only cache the .git directory in CircleCI for push jobs on the `m…
Browse files Browse the repository at this point in the history
…ain` branch (#39848)
  • Loading branch information
danielrozenberg authored Feb 23, 2024
1 parent 5b13944 commit d9177ae
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,27 +70,24 @@ executors:

commands:
checkout_repo:
parameters:
save-git-cache:
description: 'True when this step should save the .git directory to the cache'
type: boolean
steps:
- restore_cache:
name: 'Restore Git Cache'
keys:
- git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
- git-cache-{{ arch }}-v2-{{ .Branch }}-
- git-cache-{{ arch }}-v2-
- git-cache-{{ arch }}-v3-main-{{ .Revision }}
- git-cache-{{ arch }}-v3-main-
- git-cache-{{ arch }}-v3-
- checkout
- when:
condition: << parameters.save-git-cache >>
condition:
equal: ['main', << pipeline.git.branch >>]
steps:
- run:
name: 'Garbage Collection for Git'
command: git gc --auto
- save_cache:
name: 'Save Git Cache'
key: git-cache-{{ arch }}-v2-{{ .Branch }}-{{ .Revision }}
key: git-cache-{{ arch }}-v3-main-{{ .Revision }}
paths:
- .git
setup_vm:
Expand All @@ -106,8 +103,7 @@ commands:
- unless:
condition: << parameters.is-initializing-job >>
steps:
- checkout_repo:
save-git-cache: false
- checkout_repo
- attach_workspace:
at: /tmp
- run:
Expand Down Expand Up @@ -215,8 +211,7 @@ jobs:
executor:
name: node-docker-medium
steps:
- checkout_repo:
save-git-cache: true
- checkout_repo
- run:
name: 'Initialize Repository'
command: ./.circleci/initialize_repo.sh
Expand All @@ -233,8 +228,7 @@ jobs:
executor:
name: macos-medium
steps:
- checkout_repo:
save-git-cache: true
- checkout_repo
- setup_vm:
is-initializing-job: true
checks:
Expand Down

0 comments on commit d9177ae

Please sign in to comment.