Repository navigation
Align JavaScript Dockerfile run-script validator with Go and Python pipeline registration - #21461
Conversation
The validator was registered as a PipelineStepAnnotation on the container, so: - a resource excluded from the manifest still failed publish; - PublishAsDockerFile(c => c.WithDockerfile(...)) threw 'Sequence contains more than one element' when WithDockerfile replaced the step annotation; - the image build step did not depend on it, so deploy graphs that run BuildCompute steps directly (Azure Container Apps, App Service) skipped it. Register it through builder.Pipeline, skip excluded resources, and make the container's BuildCompute steps depend on it, matching #21186. Part of #21205 Co-authored-by: Copilot <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21461Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21461" |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the JavaScript Dockerfile validation changes.
No open issues 🎉
What changed in this PR
Aligns JavaScript’s existing-Dockerfile run-script validator with the Go and Python pipeline pattern, addressing part of #21205. The Next.js dependency change and shared registration helper remain out of scope.
Changes:
- Registers validation directly with the application pipeline so later
WithDockerfilecalls cannot replace it. - Skips validation for excluded resources and makes image-build steps depend on validation.
- Adds three regression tests and updates the existing test to resolve the application’s registered pipeline.
| File | Description |
|---|---|
| tests/Aspire.Hosting.JavaScript.Tests/AddJavaScriptAppTests.cs | Covers excluded resources, Dockerfile reconfiguration, and image-build dependencies. |
| src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs | Updates validator registration, exclusion handling, and build ordering. |
Review effort: Balanced
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
…e builds (#21822) ## Description Next.js deployments to Azure Container Apps and App Service now validate standalone output before building the image, rather than silently skipping the check when the deployment graph selects `BuildCompute` directly. **Stacked on #21461. Base: `agent/js-dockerfile-validator-pipeline`; merge #21461 first, then retarget this PR to `main`.** This PR does not duplicate that PR's excluded-JavaScript-resource, Dockerfile annotation collision, or JavaScript image-build dependency fixes. Fixes #21205 together with #21461. Part of #21115. - Link one internal `PublishValidationExtensions` helper into Go, Python and JavaScript. All existing-Dockerfile validators and the Next.js standalone check use it for application-pipeline registration, late excluded-resource checks, and resource-specific `BuildCompute` ordering. - Preserve the existing Go warning and Python/JavaScript failure behavior, step names, and manifest callbacks. Next.js retains its build-prerequisite dependency and build-only aggregate requirement; manifest-only publish does not newly require standalone validation. - Preserve `DisableBuildValidation()` and skip Next.js validation for resources excluded from publishing. No public API is added. - Exercise the real ACA and App Service preparation/configuration graphs locally. Both regression cases failed at the missing Next.js image-build dependency on the #21461 base, and pass here. These are graph tests, not Azure deployments, and do not provision resources. ### User-facing usage Existing AppHosts need no changes: ```csharp builder.AddNextJsApp("frontend", "./frontend"); ``` When deploying to Azure Container Apps or App Service, the image build now waits for validation of the existing Next.js configuration: ```typescript export default { output: 'standalone' }; ``` Applications with dynamically supplied configuration can continue to use `.DisableBuildValidation()`. ### Validation All 22 focused tests passed. Exact commands: ```powershell dotnet test --project tests\Aspire.Hosting.JavaScript.Tests\Aspire.Hosting.JavaScript.Tests.csproj --no-launch-profile -- --filter-method '*.NextJs*' --filter-method '*.PublishPipeline*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` Passed: 9 tests, including invalid/valid standalone configuration, suppression, exclusion, image-build ordering, and the inherited #21461 JavaScript regressions. ```powershell dotnet test --project tests\Aspire.Hosting.Go.Tests\Aspire.Hosting.Go.Tests.csproj --no-launch-profile -- --filter-method '*.PublishPipeline*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` Passed: 7 tests. ```powershell dotnet test --project tests\Aspire.Hosting.Python.Tests\Aspire.Hosting.Python.Tests.csproj --no-launch-profile -- --filter-method '*.PublishPipeline*' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` Passed: 4 tests. ```powershell dotnet test --project tests\Aspire.Hosting.Azure.Tests\Aspire.Hosting.Azure.Tests.csproj --no-launch-profile -- --filter-class '*.JavaScriptPublishValidationTests' --filter-not-trait 'quarantined=true' --filter-not-trait 'outerloop=true' ``` Passed: 2 tests. Before the fix, both failed because `build-nextjs` did not reach `nextjs-standalone-check-nextjs`. `git diff --check` passed. Evaluated MSBuild `Compile` items include the linked helper once in each integration; existing project-reference edges cover the test consumers, so no test-trigger-map change is needed. Builds emitted the same pre-existing Dashboard ILCompiler NU1903 advisory observed on the base. Full suites and live Azure deployment were not run. ## Checklist - Is this feature complete? - [x] Yes. Ready to ship. - [ ] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No Co-authored-by: IEvangelist <[email protected]> Co-authored-by: Copilot App <[email protected]>
Tests selector14 / 101 PR test projects · 4 PR jobs, from 10 changed files. Selected PR test projects (14 / 101)
Selected PR jobs (4)
How these were chosen — grouped by what changed
🔧 🔧 🔧 🧪 📦 affected project 🔧 🔧 🔧 🧪 🧪 Job reasons
Selection computed for commit |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
✅ No documentation update needed. docs_optional → bug_fix_restores_documented_behavior. No signals triggered (signal_count 0). The PR fixes the JavaScript Dockerfile run-script validator's pipeline registration: excluded resources no longer fail publish, |
…ipeline registration (#21461) ## Description Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (`validate-javascript-dockerfile-run-script-{name}`) with the Go and Python validators fixed in #21186. ### Bugs on `main`, each reproduced by a new test 1. **Excluded resources still fail publish.** A JavaScript app with an existing Dockerfile and an explicit run script that is marked `ExcludeFromManifest()` still runs the validator and throws `JavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile ...`. The resource isn't published at all, so this failure is spurious. 2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in publish mode.** The validator was a second `PipelineStepAnnotation` on the container. `WithDockerfile` calls `EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with `ResourceAnnotationMutationBehavior.Replace` and then fails with `InvalidOperationException: Sequence contains more than one element`. 3. **Deploy graphs skip the validator.** It was only `RequiredBySteps = [Build, Publish]`. Azure Container Apps and App Service select a resource's `BuildCompute` steps directly, so `build-{name}` never depended on the validator. ### Fix This is the same shape #21186 merged for Go and Python: - Register the step through `builder.Pipeline.AddStep`, so it's no longer a container annotation that `WithDockerfile` can replace. - Skip validation when `containerBuilder.Resource.IsExcludedFromPublish()`. - Make the container's `BuildCompute` steps depend on the validation step through `WithPipelineConfiguration`. The existing test `PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit` built a bare `new DistributedApplicationPipeline()`, which doesn't contain steps added through `builder.Pipeline`. It now resolves the app's `IDistributedApplicationPipeline`, as the Go and Python tests in #21186 do. Its assertions are unchanged. Not in this PR (remaining #21205 items): the Next.js standalone check's `BuildCompute` dependency and a shared helper across Go, Python and JavaScript. ### Before/after (local) | Test | Before (`main` source) | After | |---|---|---| | `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` | ❌ `DistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...` | ✅ | | `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌ `InvalidOperationException: Sequence contains more than one element` (from `WithDockerfile`) | ✅ | | `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌ `Assert.Contains() Failure: Filter not matched` (validator not in the `build-js` closure) | ✅ | - The four `*PublishPipeline*` tests pass in 20/20 repeated runs. - Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19 failures are environmental and unrelated: - Bun and Deno functional tests fail in 0ms because those tools aren't installed. - Verify snapshot tests fail because the sandbox HOME is `/root`, which the scrubber rewrites inside `/root/.cache`. With a different HOME, all 101 snapshot tests pass. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: David Pine <[email protected]> Co-authored-by: IEvangelist <[email protected]> (cherry picked from commit 059be63)
…ipeline registration (#21461) ## Description Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (`validate-javascript-dockerfile-run-script-{name}`) with the Go and Python validators fixed in #21186. ### Bugs on `main`, each reproduced by a new test 1. **Excluded resources still fail publish.** A JavaScript app with an existing Dockerfile and an explicit run script that is marked `ExcludeFromManifest()` still runs the validator and throws `JavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile ...`. The resource isn't published at all, so this failure is spurious. 2. **`PublishAsDockerFile(c => c.WithDockerfile(...))` crashes in publish mode.** The validator was a second `PipelineStepAnnotation` on the container. `WithDockerfile` calls `EnsureBuildAndPushPipelineAnnotations`, which adds its annotation with `ResourceAnnotationMutationBehavior.Replace` and then fails with `InvalidOperationException: Sequence contains more than one element`. 3. **Deploy graphs skip the validator.** It was only `RequiredBySteps = [Build, Publish]`. Azure Container Apps and App Service select a resource's `BuildCompute` steps directly, so `build-{name}` never depended on the validator. ### Fix This is the same shape #21186 merged for Go and Python: - Register the step through `builder.Pipeline.AddStep`, so it's no longer a container annotation that `WithDockerfile` can replace. - Skip validation when `containerBuilder.Resource.IsExcludedFromPublish()`. - Make the container's `BuildCompute` steps depend on the validation step through `WithPipelineConfiguration`. The existing test `PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicit` built a bare `new DistributedApplicationPipeline()`, which doesn't contain steps added through `builder.Pipeline`. It now resolves the app's `IDistributedApplicationPipeline`, as the Go and Python tests in #21186 do. Its assertions are unchanged. Not in this PR (remaining #21205 items): the Next.js standalone check's `BuildCompute` dependency and a shared helper across Go, Python and JavaScript. ### Before/after (local) | Test | Before (`main` source) | After | |---|---|---| | `PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifest` | ❌ `DistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...` | ✅ | | `PublishPipelineValidationStepSurvivesLaterWithDockerfile` | ❌ `InvalidOperationException: Sequence contains more than one element` (from `WithDockerfile`) | ✅ | | `PublishPipelineRunsValidationStepBeforeImageBuildStep` | ❌ `Assert.Contains() Failure: Filter not matched` (validator not in the `build-js` closure) | ✅ | - The four `*PublishPipeline*` tests pass in 20/20 repeated runs. - Full `Aspire.Hosting.JavaScript.Tests`: 408/427 pass locally. The 19 failures are environmental and unrelated: - Bun and Deno functional tests fail in 0ms because those tools aren't installed. - Verify snapshot tests fail because the sandbox HOME is `/root`, which the scrubber rewrites inside `/root/.cache`. With a different HOME, all 101 snapshot tests pass. ## Checklist - Is this feature complete? - [ ] Yes. Ready to ship. - [x] No. Follow-up changes expected. - Are you including unit tests for the changes and scenario tests if relevant? - [x] Yes - [ ] No - Did you add public API? - [ ] Yes - If yes, did you have an API Review for it? - [ ] Yes - [ ] No - Did you add `<remarks />` and `<code />` elements on your triple slash comments? - [ ] Yes - [ ] No - [x] No - Does the change make any security assumptions or guarantees? - [ ] Yes - If yes, have you done a threat model and had a security review? - [ ] Yes - [ ] No - [x] No **🤖 Posted by AspireAgent (AI Agent)** --------- Co-authored-by: davidfowl <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: David Pine <[email protected]> Co-authored-by: IEvangelist <[email protected]> (cherry picked from commit 059be63)
Description
Part of #21205. Aligns the JavaScript existing-Dockerfile run-script validator (
validate-javascript-dockerfile-run-script-{name}) with the Go and Python validators fixed in #21186.Bugs on
main, each reproduced by a new testExcludeFromManifest()still runs the validator and throwsJavaScript app resource 'js' is configured to run script 'migrate', but publish is using the existing Dockerfile .... The resource isn't published at all, so this failure is spurious.PublishAsDockerFile(c => c.WithDockerfile(...))crashes in publish mode. The validator was a secondPipelineStepAnnotationon the container.WithDockerfilecallsEnsureBuildAndPushPipelineAnnotations, which adds its annotation withResourceAnnotationMutationBehavior.Replaceand then fails withInvalidOperationException: Sequence contains more than one element.RequiredBySteps = [Build, Publish]. Azure Container Apps and App Service select a resource'sBuildComputesteps directly, sobuild-{name}never depended on the validator.Fix
This is the same shape #21186 merged for Go and Python:
builder.Pipeline.AddStep, so it's no longer a container annotation thatWithDockerfilecan replace.containerBuilder.Resource.IsExcludedFromPublish().BuildComputesteps depend on the validation step throughWithPipelineConfiguration.The existing test
PublishPipelineWithExistingDockerfileThrowsFromValidationStepWhenRunScriptNameIsExplicitbuilt a barenew DistributedApplicationPipeline(), which doesn't contain steps added throughbuilder.Pipeline. It now resolves the app'sIDistributedApplicationPipeline, as the Go and Python tests in #21186 do. Its assertions are unchanged.Not in this PR (remaining #21205 items): the Next.js standalone check's
BuildComputedependency and a shared helper across Go, Python and JavaScript.Before/after (local)
mainsource)PublishPipelineValidationStepIsNoOpForResourceExcludedFromManifestDistributedApplicationException: JavaScript app resource 'js' is configured to run script 'migrate' ...PublishPipelineValidationStepSurvivesLaterWithDockerfileInvalidOperationException: Sequence contains more than one element(fromWithDockerfile)PublishPipelineRunsValidationStepBeforeImageBuildStepAssert.Contains() Failure: Filter not matched(validator not in thebuild-jsclosure)*PublishPipeline*tests pass in 20/20 repeated runs.Aspire.Hosting.JavaScript.Tests: 408/427 pass locally. The 19 failures are environmental and unrelated:/root, which the scrubber rewrites inside/root/.cache. With a different HOME, all 101 snapshot tests pass.Checklist
<remarks />and<code />elements on your triple slash comments?🤖 Posted by AspireAgent (AI Agent)