Skip to content

Conversation

@vector-of-bool
Copy link
Contributor

Summary

Refer: CDRIVER-6142, this is a set of drive-by changes done as part of CDRIVER-5982, split into a separate PR to keep a clean history and review set.

This changeset modifies how Earthly environments are specified and set up for the build.

Most of this changeset consists of modifications to generated Evergreen configs.

While doing refactors to the amongoc CI plan, I found that it is far simpler to have an Earthly function for each dependency that knows how to "do the right thing" to install the relevant packages for whatever host platform it happens to be running within, especially by adding a new __can_install utility. The following significant changes are made:

  1. The env.foo Earthly targets are dropped. Instead, environments are specified using --from instead of --env, which just executes a regular FROM command to set the base container image.
  2. For each dependency, an ADD_FOO Earthly function is defined, and it will just "do the right thing" to obtain the relevant package for the build (or do nothing, if that dependency is disabled).
  3. The many small scripts are consolidated into a single __tool script, which explodes itself using __alias to reproduce the same set of tools that were available beforehand.
  4. New tools are defined, the most important being __can_install <pkg>, which determines whether a package <pkg> is available for installation. This makes dep management far simpler since we don't need to do fancy platform/tool detection when we can just say "If gcc-c++ is available, install it." without needing to know which package manager we're going to use.
  5. Because --from (formerly --env) has been modified to take a plain container image specifier, the logic for switching to ECR for the base platform container images is moved to earthly.py.
  6. The build has been split into four steps: +init, +build-environment, +configure, and +build. The main purpose of this split is to support subdividing the EVG build into the four steps so that we get separate timing/logging information for each.

All of the above also has the added benefit of being able to test any Linux distro/version on-the-fly by just passing a new --from rather than needing to modify Earthfile to support a new platform.

This change rewrites much of Earthfile's dependency-installation handling
code to be simpler to modify, and more flexible to use.

Previously, each environment had its own target that needed to know how
to install all of our dependencies for the specific platform. This
refactor inverts the relationship: Instead, each dependency has an Earthly
function that knows how to install itself based on whatever platform it
happens to be running within.

This allows the FROM line to be a plain image, rather that one of our
handcrafted `env.foo` targets. This will make introducing and testing
additional environments far more simple in the future.

This change also allows us to remove the tools/build.earth utility, since we can
now fit everything in the top-level file.
@vector-of-bool vector-of-bool marked this pull request as ready for review November 10, 2025 16:25
@vector-of-bool vector-of-bool requested a review from a team as a code owner November 10, 2025 16:25
@vector-of-bool vector-of-bool requested review from connorsmacd and eramongodb and removed request for connorsmacd November 10, 2025 16:25
@vector-of-bool
Copy link
Contributor Author

@eramongodb requested you especially because this does some juggling of the ECR handling in EVG.

Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Earthly workflow is a lot easier to track than before. Thank you for these improvements!

Copy link
Contributor

@eramongodb eramongodb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions/questions remaining; otherwise, LGTM.

Comment on lines +406 to +408
# devdocs :
# Builds the developer documentation pages as HTML, and writes the resulting pages into
# `_build/devdocs` on the host for browsing.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be under _build/docs/dev instead?

ARG uv_version = "0.8.15"
ARG uv_install_sh_url = "https://astral.sh/uv/$uv_version/install.sh"
IF ! __have_command uv
RUN curl -LsSf "$uv_install_sh_url" \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if not for the source tarballs downloaded by the install script, recommend adding checksum validation for the install script itself.

# shellcheck disable=SC3043

true <<EOF
This script is inteded for use with preparing a container environment, providing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This script is inteded for use with preparing a container environment, providing
This script is intended for use with preparing a container environment, providing

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.

2 participants