Skip to content

Fetch only BASE and HEAD commits for CloudFormation diff - #1948

Draft
klutchell wants to merge 1 commit into
masterfrom
klutchell/optimize-git-fetch
Draft

klutchell wants to merge 1 commit into
masterfrom
klutchell/optimize-git-fetch

Conversation

@klutchell

@klutchell klutchell commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

The flowzone.yml step that diffs CloudFormation templates fetched entire branch histories for BASE and HEAD before diffing. In a shallow clone, fetching a ref without --depth pulls full history, which is slow and unnecessary since a tree diff only needs the two commits.

Fetch BASE and HEAD with --depth=1 --no-tags --no-recurse-submodules. Since --depth disables git's automatic submodule recursion, the script now walks the raw diff output itself: for each changed submodule (:160000 160000 <old> <new> M), it recurses into that submodule directory and repeats the shallow two-commit fetch there.

Tested here https://github.com/balena-io/environment-playground/actions/runs/36622349287/job/109591049498?pr=4518

@flowzone-app

flowzone-app Bot commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Website deployed to CF Pages, 👀 preview link https://8a77cf96.flowzone.pages.dev

The versioned checkout is shallow, so fetching BASE and HEAD without
--depth pulled their full history. On environment-production this took
~110s per fetch.

Fetch with --depth=1 instead. Git skips on-demand submodule recursion
when --depth is set, so fetch the old and new commits of each changed
submodule explicitly to keep --submodule=diff working.

Git failures in this step now fail the step. Before, a failed fetch or
diff silently dropped stacks from the matrix.

Change-type: patch
Signed-off-by: Kyle Harding <kyle@balena.io>

This branch was previously deployed

1 inactive deployment
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