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.
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