Repository navigation
Detect drift in generated pipeline output - #21681
Eric Erhardt (eerhardt) merged 5 commits into
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21681Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21681" |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
PR Testing Report (local, Windows, dogfood CLI)
Scenarios (aspire-empty +
|
| # | Scenario | Result |
|---|---|---|
| 1 | aspire do publish-and-diff on a git repo with no committed output |
Pass - fails, Added: docker-compose.yaml |
| 2 | Commit output, rerun publish-and-diff |
Pass - 10/10 steps, exit 0 |
| 3 | Tamper with docker-compose.yaml, plain aspire do publish |
Pass - generation-only, exit 0, output regenerated |
| 4 | Tamper again, publish-and-diff |
Pass - fails, Changed: docker-compose.yaml, exit 6 |
| 5 | Non-git directory (filesystem fallback): clean run, then tamper | Pass - exit 0, then Changed: docker-compose.yaml |
| 6 | Pipeline:OutputDiff:UseGit=true with no worktree |
Pass - clear failure: "Git is required to capture pipeline output..." |
Notes
- The
Removedpath andPipeline:OutputDiffglob rules were not exercised end-to-end (unit tests cover them). - The scenario 6 message ends with a trailing
:and an empty directory path in the observed output (possibly console wrapping); minor. WithOutputDiffingrequiresusing Aspire.Hosting.Pipelines;(not covered by implicit usings).
Overall: PR VERIFIED for tested scenarios.
David Pine (IEvangelist)
left a comment
There was a problem hiding this comment.
Three non-blocking considerations: sharing process termination mechanics, environment-dependent output fingerprinting, and documenting Git protocol constants.
5be9395 to
b9328e7
Compare
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Register output diffing services and configuration only through the application builder. Use explicit capture modes, mark the diffing contracts experimental, and keep the file hasher internal.
Pair asynchronous snapshotters and comparers through a shared snapshot type. Add constrained builder overloads for custom providers while preserving the default opt-in and capture lifecycle.
Resolve snapshotters independently for before and after captures and select the default strategy per capture. Keep only the baseline snapshot in a StrongBox so default-valued struct snapshots remain valid. Rename the built-in providers to Default, narrow interface documentation, and update lifetime, retry, clone, and strategy-change coverage.
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
c64ba9f
into
microsoft:main
Add a new "Detect drift in generated pipeline output" page covering the opt-in WithOutputDiffing API (microsoft/aspire#21681), the `aspire do publish-and-diff` step, targeting other steps, the Pipeline:OutputDiff configuration (rules and Git mode), how Git and filesystem comparison work, a GitHub Actions example, and custom snapshotter and comparer extensibility. Also add the ASPIREPIPELINES005 diagnostic page, overview row, and sidebar entries, and cross-link from the pipelines, CI/CD, Docker Compose, and aspire do/publish reference pages. Co-authored-by: Copilot App <[email protected]>
## Summary Documents the 17.0 feature "Detect drift in generated pipeline output" from microsoft/aspire#21681 (fixes microsoft/aspire#18833). - Adds [`deployment/output-diffing.mdx`](src/frontend/src/content/docs/deployment/output-diffing.mdx): why and when to use it, enabling `WithOutputDiffing`, running `aspire do publish-and-diff`, reading `Added`/`Changed`/`Removed` results and fixing drift, a GitHub Actions example, comparing other steps, `Pipeline:OutputDiff` configuration (ordered include/exclude rules and `Auto`/`Git`/`FileSystem` mode), how Git and filesystem comparison work, capture timing, and C#-only custom `IPipelineOutputSnapshotter<TSnapshot>` / `IPipelineOutputComparer<TSnapshot>` extensibility. Includes a sidebar entry with all locale translations. - Adds the `ASPIREPIPELINES005` diagnostic page, overview table row, and sidebar entry. - Cross-links from the pipelines overview, CI/CD overview (new section and card), Docker Compose output artifacts, and the `aspire do` and `aspire publish` CLI reference pages. - AppHost samples use synced TypeScript-then-C# tabs. `withOutputDiffing` is exported to the TypeScript AppHost SDK; the factory and generic overloads, options-pattern configuration, and custom snapshotter/comparer are C#-only, with a note beside each operation. The 17.0 what's-new page is intentionally not touched. ### Assumptions and notes - The PR description shows `builder.Pipeline.WithOutputDiffing()` and mentions `IPipelineOutputDiffer` / `IPipelineOutputFileHasher`. The merged code on `release/17.0` and `main` exposes `builder.WithOutputDiffing()` (an extension on `IDistributedApplicationBuilder`), and the public extension points are the snapshotter and comparer interfaces. The hasher is internal. The docs follow the merged code and docs/specs/pipeline-output.md. - `ASPIREPIPELINES005` is documented as an error because a C# AppHost build reports `error ASPIREPIPELINES005` until suppressed (verified). The product repo's docs/list-of-diagnostics.md lists it as a warning. - The checked-in API reference data stops at 13.6, so the new APIs are inline code rather than `ApiReference` links, and the TypeScript blocks have no `twoslash` meta (the generated type bundle doesn't contain `withOutputDiffing`). The TypeScript samples were type-checked against a generated SDK instead (see Validation). - No open docs PR covers this feature. #1852 and #1856 (diagnostic graduations) and #2035 (pipelines page) edit nearby files but different content; this PR doesn't duplicate or contradict them. ## Third-party links and affiliations None. ## Validation Documentation behavior was verified against a dev Aspire CLI (`17.1.0-preview.1.26556.5`, a `main` build that contains #21681; the output diffing source is identical on `release/17.0`) using C# file-based and TypeScript AppHosts with a Docker Compose environment: - `aspire do publish-and-diff` with no committed output: failed with `Added: docker-compose.yaml`, exit code 6. - Same command after committing output: succeeded (10/10 steps). - After tampering with the committed file or changing the AppHost: failed with `Changed: docker-compose.yaml`; the regenerated file was left on disk and `git diff` showed it. - `aspire do publish` after tampering: generation only, no comparison. - A custom step deleting a tracked file reported `Removed:`; a custom `targetStep`/`diffStepName` worked; two comparison targets coexisted; `--output-path` moved the compared directory. - Git-ignored output in `Auto` mode was not compared (passed silently); `Mode=FileSystem` detected it. `Mode=Git` outside a worktree failed with "Git is required to capture pipeline output...". A stale untracked file that generation doesn't touch was not reported. - `Pipeline:OutputDiff` rules and mode worked from `appsettings.json` (C# and TypeScript AppHosts) and from `Pipeline__OutputDiff__*` environment variables; invalid actions failed with "Output diff rule actions must be Include or Exclude." - All C# samples from the new page compiled together with `dotnet build apphost.cs`; the TypeScript samples passed `npx tsc -p tsconfig.apphost.json --noEmit` against the generated SDK. Repository checks (from `src/frontend`): - `pnpm install --frozen-lockfile --prefer-offline`: passed. - `pnpm exec astro sync`: passed. - `pnpm exec vitest run --config vitest.config.ts tests/unit/seo-lengths.vitest.test.ts tests/unit/apphost-examples.vitest.test.ts tests/unit/typescript-first-apphost-tabs.vitest.test.ts tests/unit/aspire-version-placeholders.vitest.test.ts tests/unit/page-metadata.vitest.test.ts tests/unit/redirects.vitest.test.ts tests/unit/twoslash-blocks.vitest.test.ts tests/unit/filetree-format.vitest.test.ts`: 8 files, 93 tests passed. - `pnpm test:unit:twoslash-blocks`: passed. - `pnpm exec eslint config/sidebar/deployment.topics.ts config/sidebar/reference.topics.ts` and `pnpm exec prettier --check` on the same files: passed. - Rendered the new pages with `pnpm exec astro dev` and checked them with `playwright-cli` (HTTP 200, tabs, tables, steps, and the new sidebar entry). - Not run: `pnpm build` (CI only, per repository policy). --------- Co-authored-by: Copilot App <[email protected]> Co-authored-by: Matt Kotsenas <[email protected]>
Description
Fixes #18833
Users sometimes add their generated assets to source control. Those assets can drift from the code that generates them, leading to stale deployments or deployed files that do not match the versioned artifacts.
To support these workflows, this PR adds an opt-in check that regenerates pipeline output from the current source and fails when selected artifacts are added, changed or removed.
Diffing hooks the publish step by default. Run
aspire do publish-and-diffto generate and compare. Ordinaryaspire do publishremains generation-only. Diffing can be configured to target any step.The differ captures existing output before selected step actions, including prerequisite and build writers. It compares that capture with output after the comparison step's dependencies and action finish. The default differ checks the global directory returned by
IPipelineOutputService.When a usable Git worktree is available, the default differ uses Git membership and content semantics, including attributes and clean filters. Otherwise it uses filesystem membership and streaming XxHash3.
Pipeline:OutputDiffconfigures ordered glob rules and whether Git is automatic, required or disabled. CustomIPipelineOutputDifferandIPipelineOutputFileHasherimplementations use ordinary host DI.See
docs/specs/pipeline-output.mdfor capture boundaries, postprocessing timing, link handling and extension contracts.Security considerations
I checked 'Yes' for security assumptions, because enabling git trusts the Git executable and configuration.
Checklist
<remarks />and<code />elements on your triple slash comments?