-
Notifications
You must be signed in to change notification settings - Fork 456
[CDRIVER-6142] Refactor dependency/environment setup in Earthfile #2165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
[CDRIVER-6142] Refactor dependency/environment setup in Earthfile #2165
Conversation
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.
|
@eramongodb requested you especially because this does some juggling of the ECR handling in EVG. |
eramongodb
left a comment
There was a problem hiding this 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!
eramongodb
left a comment
There was a problem hiding this 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.
| # devdocs : | ||
| # Builds the developer documentation pages as HTML, and writes the resulting pages into | ||
| # `_build/devdocs` on the host for browsing. |
There was a problem hiding this comment.
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" \ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| This script is inteded for use with preparing a container environment, providing | |
| This script is intended for use with preparing a container environment, providing |
Summary
This changeset modifies how Earthly environments are specified and set up for the build.
While doing refactors to the
amongocCI 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_installutility. The following significant changes are made:env.fooEarthly targets are dropped. Instead, environments are specified using--frominstead of--env, which just executes a regularFROMcommand to set the base container image.ADD_FOOEarthly 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).__toolscript, which explodes itself using__aliasto reproduce the same set of tools that were available beforehand.__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 "Ifgcc-c++is available, install it." without needing to know which package manager we're going to use.--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 toearthly.py.+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
--fromrather than needing to modifyEarthfileto support a new platform.