Add pipeline-scoped working directories - #3863
Conversation
|
CI diagnosis: all six failures fan out from Fast fail. The template pipeline itself succeeds, then the smoke test fails |
|
Refreshed onto current main at ccea314 after the prior Fast-fail artifact-upload failure. Current-head validation: PipelineWorkingDirectoryTests 3/3; PipelineBuilderRegistrationTests 16/16; core Release build 0 warnings / 0 errors. Please re-review current head. |
Code reviewNice cleanup — this replaces the template's 53-line One design point worth discussing before merge, plus one follow-up suggestion:
|
|
Addressed the current-head review at Revalidation: |
Code review (re-review at
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 15e9687778
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| PipelineWorkingDirectory workingDirectory, | ||
| IZipContext zip, | ||
| IChecksumContext checksum) : IFilesContext |
There was a problem hiding this comment.
Scope nested file helpers to the pipeline directory
When PipelineBuilderOptions.WorkingDirectory is set and the process CWD is somewhere else, only the top-level IFilesContext methods use _workingDirectory; the injected Zip and Checksum helpers still receive raw relative paths and resolve them against the process CWD. A module that writes relative.txt with context.Files.WriteAsync(...) and then calls context.Files.Checksum.Md5("relative.txt"), or zips to "out.zip", will fail or create artifacts outside the configured pipeline directory, so these nested helpers need the same path resolver or scoped wrappers.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 48b417c. Zip and Checksum now receive PipelineWorkingDirectory and resolve all relative ZIP input/output and checksum paths against it. The integration test writes, hashes, zips, and unzips using relative paths and asserts the configured directory.
| var sourceDirectory = Path.GetDirectoryName(sourceFilePath); | ||
| if (IsPipelineProject(sourceDirectory)) | ||
| { | ||
| return Path.GetFullPath(sourceDirectory!); |
There was a problem hiding this comment.
Walk source ancestors for project discovery
If Pipeline.CreateBuilder is called from a helper/source file under a subdirectory of the pipeline project and the pipeline is launched from a copied or published output whose AppContext.BaseDirectory is no longer under that source project, this exact-directory check misses the project root even though the caller file is inside it. The builder then falls back to the process CWD, so AddJsonFile("appsettings.json") and relative file operations use the wrong directory; start the existing ancestor search from sourceDirectory before falling back to AppContext.BaseDirectory.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 48b417c. Pipeline project discovery now walks ancestors from the source-file directory before falling back to AppContext.BaseDirectory. The regression uses a caller path nested under src/Pipeline.
| public static PipelineBuilder CreateBuilder( | ||
| string[]? args = null, | ||
| [CallerFilePath] string sourceFilePath = "") |
There was a problem hiding this comment.
Preserve the existing CreateBuilder entry point
Changing the public CreateBuilder(string[]?) method into CreateBuilder(string[]?, string) removes the one-argument IL signature that existing compiled pipeline executables reference. In the package-upgrade-without-rebuild scenario those binaries will throw MissingMethodException before source compatibility helps, so keep a binary-compatible shim or move caller-path discovery behind an additional API.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 48b417c. The exact CreateBuilder(string[]?) entry point is restored, with a reflection regression for that IL signature. Caller-path inference moved to the additional CreateBuilderFromSource API, which the template now uses.
|
@claude review |
|
@codex review |
Code review (re-review at
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48b417cc26
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| services | ||
| .AddSingleton(_commandLineOptions) | ||
| .AddSingleton(new PipelineWorkingDirectory(_environment.WorkingDirectory)) |
There was a problem hiding this comment.
Set module cache roots to the pipeline working directory
When a pipeline is created with WorkingDirectory/CreateBuilderFromSource and module caching is enabled, this new scoped directory is only registered for command/file contexts; ModuleCacheOptions.WorkingDirectory still defaults to Directory.GetCurrentDirectory() (src/ModularPipelines/Caching/ModuleCacheOptions.cs:11), and cache input/artifact resolution uses that option. In the published-output or template scenario where process CWD differs from the pipeline project, context.Files.WriteAsync("input.txt") writes under the pipeline directory but [CacheInputs("input.txt")] / [ProducesArtifact("out.txt")] fingerprint and restore under the process CWD; if the CWD has no matching input, the real input is omitted from the fingerprint and stale cache hits can be reused. Initialize the cache option from _environment.WorkingDirectory unless the user overrides it.
Useful? React with 👍 / 👎.
Closes #3770
Summary
Validation
ModularPipelines.slnxRelease build: 0 warnings, 0 errorsPipelineWorkingDirectoryTests: 3/3 passedPipelineBuilderRegistrationTests: 16/16 passedThe focused test project currently needs the unrelated stale
RunReportTestsinitializers for removedPrintLogo/PrintResultsproperties omitted locally to compile; those lines were restored and are not part of this PR.