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