ext package: bake resolved version into the published avocado.yaml#161
ext package: bake resolved version into the published avocado.yaml#161mobileoverlord wants to merge 2 commits into
Conversation
In-source program extensions (avocado-ext-cli/connect/tunnels) declare
`version: '{{ env.AVOCADO_EXT_VERSION }}'` so the packaged version tracks
Cargo.toml — CI exports AVOCADO_EXT_VERSION from `[package] version`. That
template only resolves while the env var is set (package/PR-test time).
When the env template survived into the published package, a downstream
runtime build — which has no AVOCADO_EXT_VERSION in scope — interpolated it
to '' and failed:
Extension 'avocado-ext-connect' has invalid version ''. Version must be
in semantic versioning format (e.g., '1.0.0', '2.1.3')
Resolve the required `version` field at package time and bake the concrete
semver into the avocado.yaml that ships in the RPM payload. Only
`extensions.<ext>.version` is rewritten (a comment-preserving, indentation-
scoped edit); every other template (`{{ avocado.target }}`,
`{{ env.AVOCADO_DISTRO_RELEASE }}`, ...) is left for the consumer to resolve
at their build time. The bake rewrites just the one small staged file, so it
adds no source-tree copy.
Adds unit tests covering: version-only replacement with other templates and
comments preserved, nested `version:` keys left untouched, multi-extension
files baking only the named extension, and the not-found error path.
|
@mobileoverlord before the review below: I've now gone through every PR you asked me to look at, so I'd appreciate the same in return. Mine have been sitting without a review and they're the foundation the CI/CD lab work depends on. Fair's fair - here are mine, roughly in priority order:
Now to #161. The direction is right and the base64 transport is a clean way to dodge shell-escaping the YAML, but I think a few things need addressing before this merges - two of them turn a currently-working Critical
Warning
Suggestion
The tests are good - the nested- |
Problem
The in-source program extensions (
avocado-ext-cli,avocado-ext-connect,avocado-ext-tunnels) keep the extension version in sync withCargo.tomlby templating it from an env var:That template only resolves while
AVOCADO_EXT_VERSIONis set — i.e. at package / PR-test time. Theext packageRPM payload copied the raw on-diskavocado.yaml, so the literal template survived into the published package. Later, a runtime build consuming that extension has noAVOCADO_EXT_VERSIONin scope, so it interpolated to''and failed:Fix
Resolve the required
versionfield at package time and bake the concrete semver into theavocado.yamlthat ships in the RPM payload. The resolved value ismetadata.version— already interpolated through the normal config pipeline and semver-validated before packaging — so no new resolution logic, just persistence.Only
extensions.<ext>.versionis rewritten, via a comment-preserving, indentation-scoped line edit (no serde round-trip, so comments and quoting are untouched). Every other template ({{ avocado.target }},{{ env.AVOCADO_DISTRO_RELEASE }}, …) is intentionally left for the consumer to resolve at their build time — matching the "interpolate the required fields, defer the rest" model.Implementation notes:
avocado.yaml(≈1 KB) that's already in the staging dir — it adds no copy of the (potentially large) source tree.Tests
New unit tests for the
bake_extension_versionhelper:version:keys (e.g. underpackages:) left untouchedLocal:
cargo fmt --check,cargo clippy --all-targets --all-features -- -D warnings, andcargo testall green (17 package tests, incl. 4 new).Follow-up (not in this PR)
ext packagecurrently copies the selected files twice (src → staging → rpmbuild buildroot). A separate refactor can have%installcopy straight from the source into the buildroot (dropping the intermediate staging dir) to cut one copy for large source trees; it touches the rpmbuild flow so it should be validated against a realavocado ext packagerun.