chore: add support to build libdatadog from a commit reference#56
chore: add support to build libdatadog from a commit reference#56hoolioh wants to merge 2 commits into
Conversation
|
|
||
| selected = {source: source, tag: tag, ref: ref}.select { |_, value| value } | ||
| if selected.size > 1 | ||
| raise "Only one of source, tag, ref may be set at a time (got: #{selected.keys.join(", ")})" |
There was a problem hiding this comment.
Why would that be?
I think it would be entirely reasonable for tag/ref to be usable with a local source (git clone local/path somewhere/else absolutely works)
With the presumed tag/ref argument unification noted nearby this whole check would go away.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b2d7db89d3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| # Git builds pass --locked so they reproducibly use libdatadog's Cargo.lock. | ||
| # features: optional comma-separated cargo feature override, appended in all cases. | ||
| def cargo_install_cmd(ref: nil, features: nil) | ||
| kind, value = ref ? parse_ref(ref) : [:tag, "v#{Libdatadog::LIB_VERSION}"] |
There was a problem hiding this comment.
Treat empty LIBDATADOG_REF as default
When a CI job or shell wrapper exports LIBDATADOG_REF as an empty string, ENV["LIBDATADOG_REF"] is truthy in Ruby, so this calls parse_ref("") and raises instead of building the pinned tag. The task below already treats ref && !ref.empty? as the explicit-ref case, so this makes default builds fail only when the optional env var is present but blank; use the same blank check here before parsing.
Useful? React with 👍 / 👎.
|
So I've tried this with |
Why?
rake libdatadog:buildcould only build the single pinnedv<LIB_VERSION>tag fromlibdatadog's GitHub repo, plus a local checkout via
LIBDATADOG_SOURCE. Support for aspecific tag/commit was then added as separate
LIBDATADOG_TAG/LIBDATADOG_COMMITvariables — one variable per source type, which is verbose, has no option for building a
branch, and needs mutual-exclusion validation to police the multi-var design.
This consolidates all of them into a single
LIBDATADOG_REFvariable and adds first-classbranch support.
What does this PR do?
Replaces
LIBDATADOG_SOURCE/LIBDATADOG_TAG/LIBDATADOG_COMMITwith one variable:LIBDATADOG_REF— an explicit<kind>:<value>pair, wherekindis one of:tag:v33.0.0→cargo install --git … --tagbranch:my-feature→cargo install --git … --branch(new — branches are now first-class)commit:<sha>→cargo install --git … --revpath:/path/to/checkout→cargo install --pathThe kind is always stated explicitly — there is no auto-detection — so the source type is
never guessed and a value without a recognized prefix fails fast with a clear message.
Behavior is unchanged when
LIBDATADOG_REFis unset: it builds the pinnedv<LIB_VERSION>tag.
Git builds (tag/branch/commit) pass
cargo install --locked, so the builder is builtreproducibly against the dependency versions pinned in libdatadog's
Cargo.lock(supply-chain hardening). Local-path builds intentionally omit
--locked, since thecheckout may be modified locally.
The old
LIBDATADOG_SOURCE/LIBDATADOG_TAG/LIBDATADOG_COMMITvariables are removed(hard cut —
LIBDATADOG_COMMITwas never released). To avoid silently ignoring staleusage, the task raises a clear error pointing to
LIBDATADOG_REFif any of them is set.Artifacts from an explicit-ref build now land in a directory named after the ref value
(
vendor/libdatadog-v32.0.0/,vendor/libdatadog-main/,vendor/libdatadog-<sha>/,vendor/libdatadog-<checkout-basename>/) instead of alwaysvendor/libdatadog-<LIB_VERSION>/,so a non-release build is no longer mislabeled as the pinned version. The default build is
unchanged and still uses the canonical
libdatadog-<LIB_VERSION>location that packaging andthe runtime look up.
rake libdatadog:cleannow removes everyvendor/libdatadog-*tree.Implementation
BuildFromSource::Builder.parse_refsplits an explicit<kind>:<value>string into[kind, value](or raises on an unrecognized/missing prefix).BuildFromSource::Builder.cargo_install_cmd(ref:, features:)then routes each kind to itscanonical cargo flag via the
GIT_FLAGmap, special-casingpath:(uses--path, no--locked), and defaults to the pinned--tag v<LIB_VERSION>whenrefis blank.The
libdatadog:buildtask readsLIBDATADOG_REF/LIBDATADOG_FEATURESfrom theenvironment, guards against the removed legacy vars, passes the ref straight through, and
logs which ref it is building.
How to test the change?
Build a specific tag (requires a Rust toolchain):
LIBDATADOG_REF=tag:v33.0.0 bundle exec rake libdatadog:buildBuild a branch or a specific commit: