Implement latest tag for image matrix builds#501
Merged
Conversation
dcdd8b9 to
01c5884
Compare
7 tasks
01c5884 to
4b22aa8
Compare
bschwedler
requested changes
May 8, 2026
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pin which axis/candidate fires the warning so tests catch regressions in iteration order and short-circuit semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Per CLAUDE.md, prefer file-level imports unless there's a circular-import or perf reason. The integration test for matrix latest tags doesn't have either. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add a "Latest Tag Selection" subsection to the ImageMatrix docs covering auto-selection semantics, the unparseable-axis warning path, and scalar vs list value handling. Mirror latest_combination's str() coercion in _matches_latest so YAML- typed scalars (int/float) in list-typed values compare correctly against the stringified picks. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4b22aa8 to
8235454
Compare
Refactors ImageMatrix.to_image_versions to call resolved_dependencies a single time and pass the result to both _cartesian_product and a new _compute_latest_combination helper. The previous code invoked the network-bound, deepcopying resolved_dependencies property twice — once via latest_combination and again for the cartesian product — and a non-deterministic upstream could in principle have produced divergent version sets between the two calls. Also returns None from latest_combination when the matrix has no version-bearing axes (no dependencies and no list-typed values), so a matrix with only scalar values does not silently mark every row as latest. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous broad except Exception path emitted a "has unparseable version" warning for every error, including ones unrelated to version parsing. Split into: - except InvalidVersion: keep the parsing-specific message - except Exception: new "unexpected error" message that includes the exception type so operators can triage without being misled Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
A list-typed value with no entries (e.g., values: {flavor: []}) used to
crash latest_combination with `ValueError: max() iterable argument is
empty`. The function now detects empty axes up front and follows the
same return-None-with-warning convention as the other failure paths.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dc.resolve_versions() can hit the network (the Python constraint reads upstream version metadata), and a single build commonly reads resolved_dependencies more than once via latest_combination, to_image_versions, and external callers. Switch the property to cached_property so each matrix only resolves its constraints once per instance. Field assignment is gated by validate_assignment=True, so the same update path (e.g., Image.create_matrix(update_if_exists=True)) that mutates dependencies/dependencyConstraints would have left a stale cache. Add a model_validator(mode="after") that pops the cache on every re-validation so subsequent reads re-resolve. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Both default_tag_patterns and default_matrix_tag_patterns returned the same four LATEST-filtered TagPatterns. Extract them into a private _shared_latest_tag_patterns helper that each function splats into its return list so the LATEST set has a single definition site. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bschwedler
approved these changes
May 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #498.
Summary
ImageMatrix.latest_combinationthat resolves the cartesian-product row at the maximum version of every dependency and list-typed value, returningNone(with a warning) for non-version-parseable axes.ImageMatrix.to_image_versions()now setslatest=Trueon the single matching row via a new_matches_lateststatic helper.default_matrix_tag_patterns()gains the fourLATEST-filtered patterns fromdefault_tag_patterns(), so the existingImageTarget.tag_patternsfilter machinery emitslatest,<os>,<variant>, and<os>-<variant>on the right rows.No changes to
ImageTarget, README push, CI workflows, or other consumers — they already handlelatest=Truecorrectly.This unblocks #484 (push-order in CI) by giving matrix images a meaningful
latestsignal.Test Plan
None-on-unparseable, short-circuit, scalar/list value distinction, original-string preservation,latest=Truepropagation, default-pattern parity (1439 tests pass)ImageTarget.tag_suffixesemits the barelatesttag for the latest matrix row + primary OS + primary variantimages-connect/connect-content:latest,base,ubuntu-24.04,ubuntu-24.04-base(+ existing matrix tags)pro,ubuntu-24.04-proonlyubuntu-22.04,ubuntu-22.04-baseonlyposit-bakery/docs/configuration.qmdImageMatrix section)🤖 Generated with Claude Code