From 759cca54db19d205bff073ed0e2e8fe42afefc2a Mon Sep 17 00:00:00 2001 From: "Ian H. Pittwood" Date: Fri, 12 Jun 2026 14:31:46 -0600 Subject: [PATCH] fix(bakery): apply image_name filter in ci matrix command The matrix command was iterating c.model.images (all images, unfiltered) instead of applying the image_name regex from BakeryConfigFilter, causing patterns like 'workbench$' to match prefix-colliding names like 'workbench-session-init'. Adds a regression test using the existing merge-multi-image context. Co-Authored-By: Claude Sonnet 4.6 --- posit-bakery/posit_bakery/cli/ci.py | 3 ++- .../ci/matrix/merge-multi-image/image_name_filter.json | 1 + posit-bakery/test/features/cli/ci/matrix.feature | 9 +++++++++ 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 posit-bakery/test/cli/testdata/ci/matrix/merge-multi-image/image_name_filter.json diff --git a/posit-bakery/posit_bakery/cli/ci.py b/posit-bakery/posit_bakery/cli/ci.py index 7b018f1b5..04980d352 100644 --- a/posit-bakery/posit_bakery/cli/ci.py +++ b/posit-bakery/posit_bakery/cli/ci.py @@ -1,6 +1,7 @@ import glob import json import logging +import re import python_on_whales from enum import Enum from pathlib import Path @@ -132,7 +133,7 @@ def matrix( dev_spec=dev_spec, # type: ignore[arg-type] # typer requires str annotation; parse_dev_spec callback delivers DevBuildSpec at runtime ) c = BakeryConfig.from_context(context=context, settings=settings) - images = [i for i in c.model.images] + images = [i for i in c.model.images if image_name is None or re.search(image_name, i.name) is not None] data = [] for img in images: diff --git a/posit-bakery/test/cli/testdata/ci/matrix/merge-multi-image/image_name_filter.json b/posit-bakery/test/cli/testdata/ci/matrix/merge-multi-image/image_name_filter.json new file mode 100644 index 000000000..711bb2083 --- /dev/null +++ b/posit-bakery/test/cli/testdata/ci/matrix/merge-multi-image/image_name_filter.json @@ -0,0 +1 @@ +[{"image": "test-alpha", "version": "1.0.0", "dev": false, "platform": "linux/amd64"}] diff --git a/posit-bakery/test/features/cli/ci/matrix.feature b/posit-bakery/test/features/cli/ci/matrix.feature index 243a794ba..b5c6f4d52 100644 --- a/posit-bakery/test/features/cli/ci/matrix.feature +++ b/posit-bakery/test/features/cli/ci/matrix.feature @@ -47,3 +47,12 @@ Feature: matrix | --image-version | 9.9.9 | When I execute the command Then The command fails + + Scenario: Filtering the CI matrix by image name excludes non-matching images + Given I call bakery ci matrix + * in the merge-multi-image context + * with the arguments: + | test-alpha$ | + When I execute the command + Then The command succeeds + * the matrix matches testdata ci/matrix/merge-multi-image/image_name_filter.json