Integrate contrib types into unified Bicep extension#11915
Conversation
Wire up the build pipeline so that contrib resource type manifests (maintained via 'make update-resource-types') are included in the unified 'radius' Bicep extension alongside the existing TypeSpec/Swagger-generated types. This eliminates the separate radiusCompute, radiusData, and radiusSecurity extensions. - Add generate-bicep-types-contrib Makefile target that reads deploy/manifest/defaults.yaml to discover which contrib namespaces to include and passes all per-type manifests for each namespace to 'manifest-to-bicep generate' for merging. - Add generate-yq-installed prerequisite target for yq detection. - Add publish-bicep-extension Makefile target wrapping 'bicep publish-extension' for local testability. - Extract buildTypeIndex() from generate.ts into a shared index-builder.ts module. Add rebuild-index.ts as a thin CLI wrapper. - Extend generate-bicep-types target to call generate-bicep-types-contrib then rebuild-index after the existing autorest step. - Remove radiusCompute, radiusData, radiusSecurity from bicepconfig.json, install-bicep.sh, and pkg/cli/setup since these namespaces are now part of the single 'radius' extension. Part of: unified Bicep extension publishing (PR 2/4) Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.Scanned FilesNone |
There was a problem hiding this comment.
Pull request overview
This PR integrates contrib resource types into the unified Radius Bicep extension pipeline so users can rely on a single extension radius configuration.
Changes:
- Adds Make targets to generate contrib Bicep types, rebuild the unified index, and publish the extension.
- Refactors Bicep type index generation into a shared TypeScript module with a new
rebuild-indexCLI. - Removes separate contrib extension references from generated and repo-level Bicep configs.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
build/generate.mk |
Adds contrib generation, index rebuild, and publish targets. |
hack/bicep-types-radius/src/generator/src/index-builder.ts |
Extracts shared index-building logic. |
hack/bicep-types-radius/src/generator/src/cmd/rebuild-index.ts |
Adds CLI entry point for rebuilding indexes. |
hack/bicep-types-radius/src/generator/src/cmd/generate.ts |
Reuses shared index builder. |
hack/bicep-types-radius/src/generator/package.json |
Adds rebuild-index script. |
bicepconfig.json |
Removes separate contrib extensions. |
build/install-bicep.sh |
Updates generated Bicep config extension list. |
pkg/cli/setup/application.go / application_test.go |
Updates scaffolded Bicep config and test expectation. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11915 +/- ##
==========================================
- Coverage 51.72% 51.71% -0.02%
==========================================
Files 726 726
Lines 45608 45608
==========================================
- Hits 23593 23588 -5
- Misses 19792 19794 +2
- Partials 2223 2226 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
The doc generation script in the docs repo walks the generated/ tree and expects a docs/ subdirectory under each namespace/apiVersion. The autorest pipeline creates this for core namespaces, but manifest-to-bicep generate does not. Without it, the script crashes with FileNotFoundError. Creating an empty docs/ directory is safe because the script handles empty directories gracefully (prints a message and continues). Contrib resource type docs will be addressed separately. Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
The generate-bicep-types-contrib Makefile target requires yq to parse deploy/manifest/defaults.yaml. Add an explicit yq install step (using go install) before the generate-bicep-types step in the noncloud and cloud functional test workflows. Uses the same pattern as verify-resource-types.yaml from the automated resource type registration PR. Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Adds generated types for Radius.Compute, Radius.Data, and Radius.Security and rebuilds the unified index.json to include all 8 namespaces. Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Signed-off-by: Karishma Chawla <kachawla@microsoft.com>
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
| # Required by make generate-bicep-types-contrib to parse defaults.yaml. | ||
| run: | | ||
| mkdir -p "${RUNNER_TEMP}/bin" | ||
| GOBIN="${RUNNER_TEMP}/bin" go install github.com/mikefarah/yq/v4@v4.44.3 |
There was a problem hiding this comment.
Can the yq version be an env var similar to the other tool vars at top of the workflow?
| # Required by make generate-bicep-types-contrib to parse defaults.yaml. | ||
| run: | | ||
| mkdir -p "${RUNNER_TEMP}/bin" | ||
| GOBIN="${RUNNER_TEMP}/bin" go install github.com/mikefarah/yq/v4@v4.44.3 |
There was a problem hiding this comment.
Same as previous comment: can the yq version be an env var similar to the other tool vars at top of the workflow?
| .PHONY: generate-yq-installed | ||
| generate-yq-installed: | ||
| @echo "$(ARROW) Detecting yq..." | ||
| @which yq > /dev/null || { echo "run 'go install github.com/mikefarah/yq/v4@latest' to install yq, then ensure ~/go/bin is on your PATH"; exit 1; } |
There was a problem hiding this comment.
This should be the same version of yq used in the GitHub workflows.
| echo "Run generator from hack/bicep-types-radius/src/generator dir"; \ | ||
| CI=true pnpm -C hack/bicep-types-radius/src/generator install && pnpm -C hack/bicep-types-radius/src/generator run generate --specs-dir ../../../../swagger --release-version ${VERSION} --verbose | ||
| @echo "$(ARROW) Generating Bicep types for default contrib resource type namespaces..." | ||
| @$(MAKE) generate-bicep-types-contrib |
There was a problem hiding this comment.
Should this be a prerequisite this target instead of sub call to make? In other words, on line 144 add generate-bicep-types-contrib as a prerequisite like the other two targets on that line.
| generate-bicep-types-contrib: generate-yq-installed ## Generates Bicep types.json files for default contrib namespaces from defaults.yaml. | ||
| # Discover unique namespaces from defaults.yaml. | ||
| @NAMESPACES=$$(yq '.defaultRegistration[]' $(DEFAULTS_YAML) | sed 's|/.*||' | sort -u) && \ | ||
| for ns in $$NAMESPACES; do \ | ||
| ns_lower=$$(echo "$$ns" | tr '[:upper:]' '[:lower:]') && \ | ||
| out_dir="$(BICEP_TYPES_OUTPUT_BASE)/$$ns_lower/$(BICEP_TYPES_CONTRIB_API_VERSION)" && \ | ||
| manifest_args="" && \ | ||
| for entry in $$(yq '.defaultRegistration[]' $(DEFAULTS_YAML) | grep "^$$ns/"); do \ | ||
| type_name=$$(echo "$$entry" | cut -d'/' -f2) && \ | ||
| manifest="$(BICEP_TYPES_CONTRIB_MANIFEST_DIR)/$$type_name.yaml" && \ | ||
| if [ ! -f "$$manifest" ]; then \ | ||
| echo "ERROR: Manifest not found: $$manifest (from entry '$$entry')"; \ | ||
| exit 1; \ | ||
| fi && \ | ||
| manifest_args="$$manifest_args $$manifest"; \ | ||
| done && \ | ||
| echo " -> $$ns ($$manifest_args) -> $$out_dir" && \ | ||
| go run ./bicep-tools/cmd/manifest-to-bicep generate $$manifest_args "$$out_dir" && \ | ||
| mkdir -p "$$out_dir/docs" || exit 1; \ | ||
| done |
There was a problem hiding this comment.
This is a non-trivial nested shell loop embedded in a Makefile. It is hard to read, hard to test, and easy to break (line continuations, && chains, || exit 1). Strongly consider extracting to build/scripts/generate-bicep-contrib.sh and invoking it from the recipe. That also lets you set -euo pipefail and add shellcheck coverage. Aligns with the project's .github/instructions/shell.instructions.md guidance.
Overview
Today, resource types from
resource-types-contrib(e.g.Radius.Compute/containers,Radius.Security/secrets) are published as separate Bicep extensions (radiusCompute,radiusData,radiusSecurity), requiring users to configure multiple entries inbicepconfig.jsonand use differentextensiondirectives depending on the namespace. This PR is part of a series that consolidates them into the existingradiusBicep extension so users have a singleextension radiusfor all Radius-authored types.Specifically, this PR wires up the build pipeline so that contrib resource type manifests (maintained via
make update-resource-types) are included in the unifiedradiusextension alongside the existing TypeSpec/Swagger-generated types.What this PR does
generate-bicep-types-contribMakefile target -- readsdeploy/manifest/defaults.yamlto discover which contrib namespaces to include and passes all per-type manifests for each namespace tomanifest-to-bicep generatefor merging intotypes.json+index.json+index.md. Creates emptydocs/directories so the doc generation script doesn't crash (contrib resource type docs tracked in #11918).publish-bicep-extensionMakefile target -- wrapsbicep publish-extensionfor local testability.index-builder.tsmodule -- extractsbuildTypeIndex()fromgenerate.tsinto a shared module so both the autorest pipeline and the newrebuild-indexCLI can use it without code duplication.rebuild-index.tsCLI wrapper -- standalone entry point that rebuilds the unifiedindex.json/index.mdafter contribtypes.jsonfiles are added to the generated tree.generate-bicep-typestarget -- now callsgenerate-bicep-types-contribthenrebuild-indexafter the existing autorest step, so the full pipeline produces one unified extension.radiusCompute,radiusData,radiusSecurityremoved frombicepconfig.json,install-bicep.sh, andpkg/cli/setupsince these namespaces are now part of the singleradiusextension.yqinstall step tofunctional-test-noncloud.yamlandfunctional-test-cloud.yamlbefore themake generate-bicep-typesstep, since the newgenerate-bicep-types-contribtarget requiresyqto parsedefaults.yaml.How the build pipeline works after this PR
CI impact
The
generate-bicep-types-contribstep requiresyqto parsedefaults.yaml. Workflows that callmake generate-bicep-typesneedyqinstalled beforehand. This PR adds the install step to the two affected workflows (functional-test-noncloud.yamlandfunctional-test-cloud.yaml), using the same pattern asverify-resource-types.yamlfrom #11911.Test plan
go test ./pkg/cli/setup/...-- verifies updated bicepconfig templatepnpm -C hack/bicep-types-radius/src/generator run build-- verifies the refactored generate.ts and new index-builder.ts compile cleanlyDependencies
defaults.yamland per-type manifest files)Changes
build/generate.mk: Newgenerate-yq-installed,generate-bicep-types-contrib, andpublish-bicep-extensiontargetshack/bicep-types-radius/src/generator/src/index-builder.ts: New shared module exportingbuildTypeIndex()hack/bicep-types-radius/src/generator/src/cmd/generate.ts: Refactored to importbuildTypeIndexfrom the shared module instead of defining it inlinehack/bicep-types-radius/src/generator/src/cmd/rebuild-index.ts: New thin CLI wrapper that parses args and calls the sharedbuildTypeIndex()hack/bicep-types-radius/src/generator/package.json: Addedrebuild-indexscript entrybicepconfig.json,build/install-bicep.sh,pkg/cli/setup/application.go,pkg/cli/setup/application_test.go: Removed contrib extension references.github/workflows/functional-test-noncloud.yaml: Addedyqinstall step beforemake generate-bicep-types.github/workflows/functional-test-cloud.yaml: Addedyqinstall step beforemake generate-bicep-typeshack/bicep-types-radius/generated/: Regeneratedindex.jsonand added contrib type definitions forRadius.Compute,Radius.Data, andRadius.Security(3 new namespace directories withtypes.json,index.json,index.md, and emptydocs/placeholder)Part of
Unified Bicep extension publishing (PR 2/4). See design note.