Skip to content

refactor(buildcontext): unify Earthfile parsing into single pass and … - #799

Draft
janishorsts wants to merge 1 commit into
mainfrom
refactor-buildfile
Draft

refactor(buildcontext): unify Earthfile parsing into single pass and …#799
janishorsts wants to merge 1 commit into
mainfrom
refactor-buildfile

Conversation

@janishorsts

@janishorsts janishorsts commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Previously, resolving an Earthfile required parsing the file twice: once through ParseVersion (via parseFeatures) to inspect feature flags, and later through earthfile.ParseFile to construct the AST. To bridge these separate passes, Resolver maintained its own parseCache alongside the existing buildFileCache.
Caching parsed ASTs to avoid re-parsing files that were already being cached by the resolver was an unnecessary layer of indirection.
This change unifies Earthfile parsing into a single pass:

  1. newEarthfileBuild reads and parses the Earthfile into its full AST (earthfile.Tree) up front.
  2. Feature flags are extracted directly from tree.Version, processed for warnings, and merged with CLI overrides.
  3. The resulting buildFile struct carries both the feature configuration and the AST tree.
  4. parseFeatures.go, version.go, and the redundant parseCache are removed.
    Parsing once and holding the result simplifies control flow, removes ~320 lines of redundant parsing logic, and keeps resolver caching in one clear place.

@janishorsts janishorsts self-assigned this Aug 11, 2026
@github-actions

Copy link
Copy Markdown

➖ Are we earthbuild yet?

No change in "earthly" occurrences

📈 Overall Progress

Branch Total Count
main 4050
This PR 4050
Difference +0

Keep up the great work migrating from Earthly to Earthbuild! 🚀

💡 Tips for finding more occurrences

Run locally to see detailed breakdown:

./.github/scripts/count-earthly.sh

Note that the goal is not to reach 0.
There is anticipated to be at least some occurences of earthly in the source code due to backwards compatibility with config files and language constructs.

@janishorsts
janishorsts marked this pull request as ready for review August 11, 2026 11:26
@janishorsts
janishorsts requested a review from a team as a code owner August 11, 2026 11:26
@janishorsts
janishorsts requested review from gilescope and removed request for a team August 11, 2026 11:27
@janishorsts
janishorsts marked this pull request as draft August 12, 2026 09:02
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