Skip to content

Add support for GIT LFS checkout#3909

Draft
lizrabuya wants to merge 2 commits into
feat/git-checkout-featuresfrom
feat/sup-6529/lfs-checkout
Draft

Add support for GIT LFS checkout#3909
lizrabuya wants to merge 2 commits into
feat/git-checkout-featuresfrom
feat/sup-6529/lfs-checkout

Conversation

@lizrabuya
Copy link
Copy Markdown
Contributor

@lizrabuya lizrabuya commented May 11, 2026

Description

Add configuration and environment variables when the backend sets BUILDKITE_GIT_LFS_ENABLED=true in the job environment. When BUILDKITE_GIT_LFS_ENABLED=true is set, the agent will check if the git-lfs binary is installed and proceed to perform a git lfs fetch + git lfs checkout.

Changes

Configuration & CLI (clicommand/bootstrap.go, internal/job/config.go)

  • Added a new GitLFSEnabled bool field to ExecutorConfig, backed by env var BUILDKITE_GIT_LFS_ENABLED
  • Exposed it as a --git-lfs-enabled CLI flag on the bootstrap command with usage description
  • Wired the flag through from BootstrapConfig into ExecutorConfig

Checkout behaviour (internal/job/checkout.go)

  • Added a fail-fast binary check: if GitLFSEnabled is true and git-lfs is not on PATH, the checkout fails immediately with a descriptive error before any fetch/checkout work
  • Added git lfs install --local after clone/clean but before fetch, so the LFS filter is registered in the local repo config
  • Added a call to gitLFSFetchCheckout after the main git checkout (and after submodule updates) to explicitly pull down and materialise LFS objects

LFS fetch helper (internal/job/git.go)

  • Added gitLFSFetchCheckout, which runs git lfs fetch then git lfs checkout, wrapping each failure with a distinct error prefix ("git lfs fetch: ..." / "git lfs checkout: ...") so the
    failing step is identifiable from logs alone

Smudge bypass (internal/job/executor.go)

  • Set GIT_LFS_SKIP_SMUDGE=1 in setUp so LFS objects are never downloaded implicitly during git checkout; the explicit gitLFSFetchCheckout call handles download instead

Tests (internal/job/checkout_test.go)

  • Added TestDefaultCheckoutPhase_GitLFS covering four scenarios: LFS disabled, LFS enabled with binary present, LFS enabled with binary missing (PATH restricted via t.Setenv), and LFS
    enabled with a failing git lfs command (fake git-lfs script that exits 1)

Testing

  • Tests have run locally (with go test ./...). Buildkite employees may check this if the pipeline has run automatically.
  • Code is formatted (with go tool gofumpt -extra -w .)

Disclosures / Credits

The main function changes were implemented by me based on the recommendation from the research done for this function. I used Claude to review the code and to assist with writing the tests.

@lizrabuya lizrabuya changed the title Enable git-lfs checkout Add Git LFS Config and Environment Variables May 11, 2026
@lizrabuya lizrabuya changed the base branch from main to feat/git-checkout-features May 11, 2026 06:57
@lizrabuya lizrabuya changed the title Add Git LFS Config and Environment Variables Add Git LFS support May 11, 2026
@lizrabuya lizrabuya force-pushed the feat/sup-6529/lfs-checkout branch from f9e4186 to 255aa11 Compare May 11, 2026 07:10
@lizrabuya lizrabuya changed the title Add Git LFS support Add support for GIT LFS checkout May 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant