Skip to content

Test: pin the bake/build metadata file contract with real fixtures #740

Description

@ianpittwood

Context

The spike (#728) verified by hand that bakery build --strategy bake --metadata-file and
bakery build --strategy build --metadata-file produce interchangeable files. Nothing in the
test suite pins that: the two shapes are produced by completely separate code paths (raw buildx
passthrough for bake vs. BakeryConfig._merge_sequential_build_metadata_files() at
config/config.py:1116-1126 for build), so they can drift silently and the failure would
surface in CI as a broken bakery ci publish, not as a test failure.

Work

Add real captured metadata files as fixtures — the two files used in the spike are good
candidates:

  • a --strategy bake metadata file
  • a --strategy build metadata file

for the same set of targets (package-manager 2026.06.0, 6 targets: Standard/Minimal ×
Ubuntu 22.04/24.04/26.04, linux/amd64, built with --push + temp registry).

Add a parametrized test over both fixtures asserting the contract that
bakery dgoss run / bakery ci publish actually rely on:

  • MetadataFile.load() validates the file without error;
  • the UID key set is identical between the two fixtures;
  • for every entry: image_ref is not None, and is of the form <name>@sha256:...;
  • for every entry: platform == "linux/amd64";
  • for every entry: created_at resolves from the descriptor annotation (not the
    datetime.now() fallback in BuildMetadata.created_at);
  • the primary tag (image_tags[0]) matches between the two fixtures per UID.

Sanity-check the fallback paths too, since they are what silently degrade in production:

  • an entry with no descriptor platform yields platform is None (the multi-platform
    single-invocation case);
  • an entry with no descriptor annotation falls back to the
    label:org.opencontainers.image.created provenance arg.

Acceptance criteria

  • Both real fixtures are committed and both validate through MetadataFile.load().
  • A single parametrized test enforces the shared contract, so a divergence in either producer
    fails the suite rather than CI.
  • Fixtures are documented (in-file comment or docstring) with the exact commands that produced
    them, so they can be regenerated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dockerRelated to container images we producedocker/toolsRelated to container build/test toolsqaRelated to quality assurance (e.g. testing)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions