feature: add support for sparse checkouts#3410
feature: add support for sparse checkouts#3410jasonwbarnett wants to merge 2 commits intobuildkite:mainfrom
Conversation
a58094b to
25b9bc2
Compare
25b9bc2 to
298092e
Compare
|
For the record, I'm aware of https://github.com/buildkite-plugins/sparse-checkout-buildkite-plugin. One of the downsides is it forces you to specify the plugin for each step which in a larger organization is messy and prone to error. You also miss out of the advantages of using git mirrors on your agents when you use a buildkite plugin for checkouts (we already embed a mirror of our monorepo in our AMIs to avoid reaching out to the git server as much as possible). The checkout functionality within the agent is quite robust and it would be nice to leverage all of it's functionality without redoing it all in a plugin. If this feature were to get merged it has the advantages of being able to tie steps that simply upload a pipeline via buildkite-agent pipeline upload to a particular queue which has an agent with all of the pre-defined values, i.e. Allowing you to have 100's of pipeline steps like: steps:
- label: ":pipeline: Pipeline upload"
agents:
queue: bk-sparse-checkout
command: buildkite-agent pipeline upload .buildkite/pipelines/<...>/pipeline.ymlIf in the future something changes, i.e. you need to add a new sparse checkout path, just update your |
Description
This PR adds support for Git partial clones and sparse checkouts to the Buildkite Agent, enabling users to clone only specific directories from large repositories (monorepos).
Problem being solved:
Solution:
--filterand--depthflagsAlternatives considered:
Context
This addresses the common request from users with large monorepos who want to optimize their build times. Similar to features available in other CI/CD platforms.
Changes
New Environment Variables:
BUILDKITE_GIT_SPARSE_CHECKOUT- Enable sparse checkout (boolean)BUILDKITE_GIT_SPARSE_CHECKOUT_PATHS- Comma-separated paths to includeBUILDKITE_GIT_CLONE_DEPTH- Clone depth for shallow clonesBUILDKITE_GIT_CLONE_FILTER- Filter specification (e.g., "tree:0")New CLI Flags:
--git-sparse-checkout Enable sparse checkout for partial clones
--git-sparse-checkout-paths value Paths to include in sparse checkout (comma-separated)
--git-clone-depth value Clone depth for shallow clones (e.g., "200")
--git-clone-filter value Filter specification for partial clones (e.g., "tree:0")
Code Changes:
gitSparseCheckoutInit()andgitSparseCheckoutSet()functions--no-checkoutwhen sparse checkout is enabledExample Usage:
Testing
Additional Testing: