support rad app graph app.bicep (modeled graphs)#12057
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends the Radius application graph surface to support modeled graphs produced from a local app.bicep (no control plane call), adds a stable per-resource diff hash to enable graph comparisons, and introduces a git-backed persistence abstraction for committing modeled graph artifacts to a dedicated orphan branch.
Changes:
- Add
diffHash(and, for Radius.Core, optional source references) toApplicationGraphResourcein TypeSpec + OpenAPI + generated Go models. - Introduce
pkg/cli/graphhelpers to build modeled graphs from ARM JSON templates and compute stablediffHashvalues. - Extend
rad app graphto accept anapp.biceppath (modeled graph mode) and optionally persist the graph via apersistence.Store(git-backed store wiring added to the CLI framework).
Reviewed changes
Copilot reviewed 14 out of 20 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| typespec/Radius.Core/applications.tsp | Adds diffHash, appDefinitionLine, and codeReference to the Radius.Core graph resource model. |
| typespec/Applications.Core/applications.tsp | Adds diffHash to the Applications.Core graph resource model. |
| swagger/specification/radius/resource-manager/Radius.Core/preview/2025-08-01-preview/openapi.json | Updates OpenAPI schema for the new Radius.Core graph fields. |
| swagger/specification/applications/resource-manager/Applications.Core/preview/2023-10-01-preview/openapi.json | Updates OpenAPI schema to include diffHash. |
| pkg/graph/persistence/store.go | Adds a go:generate mock target for the Store interface. |
| pkg/graph/persistence/mock_store.go | Adds generated gomock for persistence.Store. |
| pkg/corerp/api/v20250801preview/zz_generated_models.go | Regenerates models to include the new Radius.Core graph fields. |
| pkg/corerp/api/v20250801preview/zz_generated_models_serde.go | Updates JSON (un)marshalling to include the new fields. |
| pkg/corerp/api/v20231001preview/zz_generated_models.go | Regenerates models to include diffHash. |
| pkg/corerp/api/v20231001preview/zz_generated_models_serde.go | Updates JSON (un)marshalling to include diffHash. |
| pkg/cli/graph/modeled.go | Implements modeled-graph construction from ARM templates (including symbolic-name layout normalization). |
| pkg/cli/graph/modeled_test.go | Adds unit tests for modeled graph building and connection handling. |
| pkg/cli/graph/diffhash.go | Implements stable sha256: hashing over authorable properties + sorted dependsOn. |
| pkg/cli/graph/diffhash_test.go | Adds unit tests for hash stability and filtering. |
| pkg/cli/framework/framework.go | Extends CLI factory interface/impl to provide a graph persistence store. |
| pkg/cli/framework/mock_factory.go | Updates the framework mock factory for the new GetGraphStore() method. |
| pkg/cli/cmd/app/graph/graph.go | Adds modeled-graph mode (rad app graph ./app.bicep) and repo-radius persistence behavior. |
| pkg/cli/cmd/app/graph/graph_test.go | Adds tests for modeled-graph mode, local output, and persistence behavior. |
| pkg/armrpc/api/v1/types.go | Renames provisioning state constant value from Undefined to NotSpecified. |
| cmd/rad/cmd/root.go | Wires a git-backed graph store into the CLI framework on startup. |
Files not reviewed (6)
- pkg/cli/framework/mock_factory.go: Language not supported
- pkg/corerp/api/v20231001preview/zz_generated_models.go: Language not supported
- pkg/corerp/api/v20231001preview/zz_generated_models_serde.go: Language not supported
- pkg/corerp/api/v20250801preview/zz_generated_models.go: Language not supported
- pkg/corerp/api/v20250801preview/zz_generated_models_serde.go: Language not supported
- pkg/graph/persistence/mock_store.go: Language not supported
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #12057 +/- ##
==========================================
+ Coverage 52.14% 52.20% +0.06%
==========================================
Files 734 736 +2
Lines 46704 47002 +298
==========================================
+ Hits 24354 24539 +185
- Misses 20015 20111 +96
- Partials 2335 2352 +17 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Radius functional test overviewClick here to see the test run details
Test Status⌛ Building Radius and pushing container images for functional tests... |
# Description This pull request introduces a new "modeled graph" feature to the `rad app graph` command, allowing users to generate and persist application graphs from Bicep files without contacting the Radius control plane. The command now detects when it is running in a GitHub Actions environment and, in that case, commits the modeled graph to a special orphan branch in the repository instead of writing it locally. The implementation includes extensive new logic, environment variable handling, and tests for these scenarios. Additionally, there are minor updates to provisioning state constants and framework interfaces. **Modeled Graph Feature for `rad app graph`:** * Added support for generating application graphs directly from Bicep files: if the positional argument is a `.bicep` file, the command compiles it and produces `app-graph.json` locally or commits it to the `radius-graph` orphan branch if running in GitHub Actions. * The command now distinguishes between "deployed graph" (fetching from control plane) and "modeled graph" (building from Bicep), with clear validation and execution paths for each. * When in GitHub Actions, the modeled graph is stored in a branch named `radius-graph` under a directory for the source branch, using github supplied environment variables `GITHUB_HEAD_REF` and `GITHUB_REF_NAME` to determine the branch. **Testing Improvements:** * Comprehensive new tests for the modeled graph feature, covering local file output, orphan branch persistence, environment variable fallbacks, error handling, and mocking of Bicep compilation and persistence. [[1]](diffhunk://#diff-da99a20c2559c82eb4031f76e38b2e779804b73f46c7020dda30910b0e744192R10-R25) [[2]](diffhunk://#diff-da99a20c2559c82eb4031f76e38b2e779804b73f46c7020dda30910b0e744192R280-R544) **Other Minor Changes:** * Updated ARM provisioning state constant from `Undefined` to `NotSpecified` for clarity and alignment with expected values. (https://learn.microsoft.com/en-us/javascript/api/%40azure/arm-managedapplications/provisioningstate?view=azure-node-latest) ## Type of change <!-- Please select **one** of the following options that describes your change and delete the others. Clearly identifying the type of change you are making will help us review your PR faster, and is used in authoring release notes. If you are making a bug fix or functionality change to Radius and do not have an associated issue link, please create one now. --> - This pull request fixes a bug in Radius and has an approved issue (issue link required). - This pull request adds or changes features of Radius and has an approved issue (issue link required). - This pull request is a minor refactor, code cleanup, test improvement, or other maintenance task and doesn't change the functionality of Radius (issue link optional). - This pull request is a design document and only includes files in the eng/design-notes directory. <!-- Please update the following to link the associated issue. This is required for some kinds of changes (see above). --> Fixes: radius-project#12009 ## Contributor checklist Please verify that the PR meets the following requirements, where applicable: - An overview of proposed schema changes is included in a linked GitHub issue. - [ ] Yes - [ ] Not applicable - A design document is added or updated under `eng/design-notes/` in this repository, if new APIs are being introduced. - [ ] Yes - [ ] Not applicable - The design document has been reviewed and approved by Radius maintainers/approvers. - [ ] Yes - [ ] Not applicable - A PR for [resource-types-contrib](https://github.com/radius-project/resource-types-contrib/) is created, if resource types or recipes are affected by the changes in this PR. - [ ] Yes - [ ] Not applicable - A PR for [dashboard](https://github.com/radius-project/dashboard/) is created, if the Radius Dashboard is affected by the changes in this PR. - [ ] Yes - [ ] Not applicable - A PR for the [documentation repository](https://github.com/radius-project/docs) is created, if the changes in this PR affect the documentation or any user facing updates are made. - [ ] Yes - [ ] Not applicable Signed-off-by: Reshma Abdul Rahim <reshmarahim.abdul@microsoft.com>
Description
This pull request introduces a new "modeled graph" feature to the
rad app graphcommand, allowing users to generate and persist application graphs from Bicep files without contacting the Radius control plane. The command now detects when it is running in a GitHub Actions environment and, in that case, commits the modeled graph to a special orphan branch in the repository instead of writing it locally. The implementation includes extensive new logic, environment variable handling, and tests for these scenarios. Additionally, there are minor updates to provisioning state constants and framework interfaces.Modeled Graph Feature for
rad app graph:Added support for generating application graphs directly from Bicep files: if the positional argument is a
.bicepfile, the command compiles it and producesapp-graph.jsonlocally or commits it to theradius-graphorphan branch if running in GitHub Actions.The command now distinguishes between "deployed graph" (fetching from control plane) and "modeled graph" (building from Bicep), with clear validation and execution paths for each.
When in GitHub Actions, the modeled graph is stored in a branch named
radius-graphunder a directory for the source branch, using github supplied environment variablesGITHUB_HEAD_REFandGITHUB_REF_NAMEto determine the branch.Testing Improvements:
Other Minor Changes:
UndefinedtoNotSpecifiedfor clarity and alignment with expected values. (https://learn.microsoft.com/en-us/javascript/api/%40azure/arm-managedapplications/provisioningstate?view=azure-node-latest)Type of change
Fixes: #12009
Contributor checklist
Please verify that the PR meets the following requirements, where applicable:
eng/design-notes/in this repository, if new APIs are being introduced.