We have a huge git repository (1+GB) with lots of history.
In a workflow with lots of jobs, it took 2+ mins on each job to do the checkout. It can lead to a lot of added time.
Here’s what you can do to only have to use “checkout” once:
Define a job that will checkout your repository and persist it in a workspace:
persist-checkout-to-workspace: docker: - image: python steps: - checkout - run: rm -rf .git - persist_to_workspace: root: /root paths: - project
Define a fast-checkout anchor:
fast-checkout: &fast-checkout attach_workspace: at: /root
You can now use the instant fast-checkout step in any job following persist-checkout-to-workspace in your workflow:
sample-job: docker: - image: node steps: - *fast-checkout - [...] workflows: version: 2 some-workflow: jobs: - persist-checkout-to-workspace - sample-job: requires: - persist-checkout-to-workspace