Skip to content

Commit a8fc459

Browse files
bschwedlerianpittwood
authored andcommitted
Fail ci matrix on empty --image-version filter and cover it
Per review feedback on #480: - When --image-version is set and matches nothing, exit non-zero instead of emitting "[]". In CI, a silent empty matrix skips all build jobs while the workflow reports green, masking a dispatch that targeted a nonexistent version. - Add feature scenarios for matching and non-matching filters.
1 parent 779eb64 commit a8fc459

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

posit-bakery/posit_bakery/cli/ci.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,14 @@ def matrix(
143143
else:
144144
data.append(entry.copy())
145145

146+
if image_version is not None and not data:
147+
log.error(f"No matrix entries matched --image-version '{image_version}'")
148+
raise typer.Exit(code=1)
149+
146150
stdout_console.print(json.dumps(data))
147151

152+
except typer.Exit:
153+
raise
148154
except:
149155
log.exception("Failed to load bakery config")
150156
raise typer.Exit(code=1)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[{"image": "test-image", "version": "1.0.0", "dev": false, "platform": "linux/amd64"}]

posit-bakery/test/features/cli/ci/matrix.feature

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,20 @@ Feature: matrix
3030
When I execute the command
3131
Then The command succeeds
3232
* the matrix matches testdata ci/matrix/multiplatform/exclude_platform.json
33+
34+
Scenario: Filtering the CI matrix to a matching image version
35+
Given I call bakery ci matrix
36+
* in the basic context
37+
* with the arguments:
38+
| --image-version | 1.0.0 |
39+
When I execute the command
40+
Then The command succeeds
41+
* the matrix matches testdata ci/matrix/basic/image_version_match.json
42+
43+
Scenario: Filtering the CI matrix to an unknown image version fails loudly
44+
Given I call bakery ci matrix
45+
* in the basic context
46+
* with the arguments:
47+
| --image-version | 9.9.9 |
48+
When I execute the command
49+
Then The command fails

0 commit comments

Comments
 (0)