Skip to content

Add image-version and dev-stream inputs to build workflows#480

Merged
bschwedler merged 5 commits intomainfrom
dispatch-filters
Apr 23, 2026
Merged

Add image-version and dev-stream inputs to build workflows#480
bschwedler merged 5 commits intomainfrom
dispatch-filters

Conversation

@bschwedler
Copy link
Copy Markdown
Contributor

@bschwedler bschwedler commented Apr 22, 2026

Summary

Dispatches from product repos need to narrow the build matrix to a specific image version and release stream. Main's bakery build and bakery run dgoss already accept --image-version and --dev-stream (the CLI half landed in #457), but the reusable workflows don't expose those inputs yet — so the three in-flight dev-dispatch-inputs PRs in images-connect/images-workbench/images-package-manager have to pin to the orphaned release-stream-filter branch.

This PR closes that gap by adding two optional inputs (image-version, dev-stream) to bakery-build-native.yml and bakery-build.yml, and plumbing them through to the matrix and build steps. It also folds in #467 so the ci matrix loop uses the shared matches_dev_filter() method instead of inline dev/stream checks.

Changes

  • bakery-build-native.yml and bakery-build.yml: add image-version and dev-stream as optional workflow_call inputs (default empty). Append them to bakery ci matrix calls only when set, using bash arrays so existing callers keep working unchanged.
  • posit_bakery/cli/ci.py: add --image-version option to bakery ci matrix. Without this, passing --image-version to matrix generation would fail on main (only bakery build and bakery run dgoss had it). Exits non-zero when the filter matches nothing so CI doesn't silently skip all build jobs.
  • Folded from Deduplicate dev version filter logic #467: ImageVersion.matches_dev_filter() extracted to deduplicate the dev/stream check between generate_image_targets and ci matrix; Pydantic model_fields deprecation fix on dependency.py.
  • Feature scenarios for matching, non-matching, and combined --image-version filters.

Scope intentionally excludes dev-channel / --value overrides from the release-stream-filter branch — the bakery CLI has no --dev-channel on main and the dispatch PRs listed in #302 don't use it.

Unblocks

After this merges, those PRs can repoint their development.yml from bakery-build-native.yml@release-stream-filter to @main.

Supersedes

Test plan

  • Existing bakery ci matrix tests pass (unchanged).
  • New --image-version filter produces a matrix containing only the named version.
  • Non-matching --image-version exits non-zero.
  • 924 bakery tests pass locally.

@bschwedler bschwedler requested a review from ianpittwood as a code owner April 22, 2026 18:28
bschwedler added a commit that referenced this pull request Apr 22, 2026
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.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 22, 2026

Test Results

1 378 tests  +13   1 378 ✅ +13   7m 59s ⏱️ -54s
    1 suites ± 0       0 💤 ± 0 
    1 files   ± 0       0 ❌ ± 0 

Results for commit 83b2f09. ± Comparison against base commit 8e5a705.

♻️ This comment has been updated with latest results.

ianpittwood pushed a commit that referenced this pull request Apr 23, 2026
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.
Copy link
Copy Markdown
Contributor

@ianpittwood ianpittwood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested locally against PPM

Comment on lines +123 to +142
def matches_dev_filter(
self,
dev_versions: DevVersionInclusionEnum,
dev_stream: ReleaseStreamEnum | None = None,
) -> tuple[bool, str | None]:
"""Check whether this version should be included given dev version filters.

:param dev_versions: Whether dev versions are included, excluded, or the only versions.
:param dev_stream: If set, only include dev versions from this release stream.
:return: A tuple of (included, reason). If excluded, reason explains why.
"""
if self.isDevelopmentVersion and dev_versions == DevVersionInclusionEnum.EXCLUDE:
return False, "excluded by --dev-versions exclude"
if not self.isDevelopmentVersion and dev_versions == DevVersionInclusionEnum.ONLY:
return False, "not a development version (excluded by --dev-versions only)"
if dev_stream is not None and self.isDevelopmentVersion:
version_stream = self.metadata.get("release_stream")
if version_stream != dev_stream:
return False, (f"dev stream '{version_stream}' does not match --dev-stream '{dev_stream.value}'")
return True, None
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude, this is terrible and you know it.

@bschwedler bschwedler enabled auto-merge April 23, 2026 16:30
bschwedler and others added 5 commits April 23, 2026 13:13
Dispatches from product repos need to narrow the matrix to a specific
image version and release stream. bakery build and bakery run dgoss
already accept --image-version and --dev-stream; this wires those
through as workflow_call inputs on bakery-build-native.yml and
bakery-build.yml, and adds --image-version to bakery ci matrix so the
matrix generation filters as well (otherwise every version schedules
a runner that filters to a no-op).

Inputs default to empty and are only appended when set, so existing
callers are unaffected.
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.
The ci matrix command iterates img.versions directly instead of using
generate_image_targets(), so the dev_stream filter was not applied to
its output.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Access model_fields from the class instead of the instance to
fix PydanticDeprecatedSince211 warnings. Deprecated in Pydantic
v2.11, will be removed in v3.0.
Cherry-picking the matches_dev_filter() refactor on top of a branch
that also edited the same loop left a three-line dev_stream check
below the new matches_dev_filter() call. Remove it — the method
already handles stream filtering.
@bschwedler bschwedler added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 39eea1c Apr 23, 2026
22 checks passed
@bschwedler bschwedler deleted the dispatch-filters branch April 23, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants