Repository navigation
Add YAML-validity tests for all generated workflows (regression guard for #407) #430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a4e29cd
Add YAML-validity tests for generated deploy workflows (regression gu…
sk593 8f42a7e
Merge remote-tracking branch 'origin/main' into sk593-fix-deploy-work…
sk593 7a67e8b
Extend live YAML-validity test to cover all generated workflows
sk593 75f4d04
Clarify yaml catalog comment: caret range, not exact pin
sk593 b7cef08
Apply Prettier formatting to workflow YAML tests
sk593 58ae5fa
Add nightly workflow to run live upstream template tests
sk593 01e6b40
Run live upstream template tests on every PR and push, not just nightly
sk593 9752167
Validate generated workflow YAML before commit
sk593 7c34dd1
Merge branch 'main' into sk593-fix-deploy-workflow-yaml-quoting
sk593 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| // Opt-in live regression test. Fetches the CURRENT deploy workflow templates | ||
| // from radius-project/radius `.github/extension/` and asserts that, once the | ||
| // extension fills them, every generated file parses as valid YAML. | ||
| // | ||
| // Why this matters: the extension renders templates fetched from | ||
| // radius-project/radius at RUNTIME (RADIUS_REF, currently `main`) — it bundles | ||
| // no copy. `generateDeployWorkflow` injects GitHub Actions expressions whose | ||
| // string defaults are single-quoted (`${{ vars.RADIUS_BUILD_ARCH_MODE || | ||
| // 'detect' }}`). If an upstream template wraps such a placeholder in a | ||
| // single-quoted YAML scalar, the injected quotes nest and the rendered file | ||
| // becomes invalid YAML — every deploy dispatch then fails upstream with | ||
| // `HTTP 422: failed to parse workflow`. That is exactly issue #407 | ||
| // (radius-project/ai-extensions#407), caused by radius-project/radius#12640 and | ||
| // fixed by radius-project/radius#12721. The hermetic tests in deploy.test.ts use | ||
| // inline fixtures, so only a LIVE render of the real templates catches an | ||
| // upstream quoting regression. | ||
| // | ||
| // This hits the network and depends on an external repo's moving ref, so it is | ||
| // NOT part of the default hermetic suite: it runs only when | ||
| // RUN_LIVE_WORKFLOW_TESTS is set (e.g. locally or in a scheduled job), never in | ||
| // normal CI. | ||
| import { describe, it, expect } from "vitest"; | ||
| import { parse as parseYaml } from "yaml"; | ||
| import { | ||
| RADIUS_WORKFLOW_REPO, | ||
| RADIUS_WORKFLOW_DIR, | ||
| RADIUS_REF, | ||
| DEPLOY_DISPATCHER_FILE, | ||
| DEPLOY_AZURE_FILE, | ||
| DEPLOY_AWS_FILE, | ||
| generateDeployWorkflow | ||
| } from "./deploy.js"; | ||
|
|
||
| const LIVE = !!process.env.RUN_LIVE_WORKFLOW_TESTS; | ||
|
|
||
| async function fetchWorkflow(file: string): Promise<string> { | ||
| const url = `https://raw.githubusercontent.com/${RADIUS_WORKFLOW_REPO}/${RADIUS_REF}/${RADIUS_WORKFLOW_DIR}/${file}`; | ||
| const res = await fetch(url); | ||
| if (!res.ok) { | ||
| throw new Error(`failed to fetch ${url}: ${res.status} ${res.statusText}`); | ||
| } | ||
| return res.text(); | ||
| } | ||
|
|
||
| describe.skipIf(!LIVE)( | ||
| "live deploy-workflow YAML validity (opt-in: set RUN_LIVE_WORKFLOW_TESTS)", | ||
| () => { | ||
| // Render the three real upstream templates through the extension and assert | ||
| // every generated file parses as valid YAML. This is the only test that | ||
| // would have caught the radius#12640 quoting regression, because the | ||
| // extension renders templates fetched from `main` at runtime. | ||
| it( | ||
| "renders valid YAML from the current upstream deploy templates", | ||
| async () => { | ||
| const files = [ | ||
| DEPLOY_DISPATCHER_FILE, | ||
| DEPLOY_AZURE_FILE, | ||
| DEPLOY_AWS_FILE | ||
| ]; | ||
| const bodies = await Promise.all(files.map((f) => fetchWorkflow(f))); | ||
| const templates: Record<string, string> = {}; | ||
| files.forEach((f, i) => { | ||
| templates[f] = bodies[i]; | ||
| }); | ||
|
|
||
| const generated = generateDeployWorkflow( | ||
| "prod", | ||
| ".radius/app.bicep", | ||
| templates | ||
| ); | ||
|
|
||
| for (const [name, body] of Object.entries(generated)) { | ||
| expect( | ||
| () => parseYaml(body), | ||
| `${name} rendered from upstream ${RADIUS_REF} should parse as valid YAML` | ||
| ).not.toThrow(); | ||
| } | ||
| }, | ||
| 30_000 | ||
| ); | ||
| } | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.