feat(ir): add typed builder for PythonScript@0#1128
Merged
Conversation
Add `PythonScriptFile` and `PythonScriptInline` typestate builders for the `PythonScript@0` ADO utility task, plus the `PythonScript` zero-size entry-point struct that mirrors the `PowerShell@2` pattern. The two modes map to `scriptSource: filePath` and `scriptSource: inline` respectively. `arguments` is available only on the file builder (sys.argv args are only meaningful when running a script file), so passing arguments to an inline script is a compile-time error rather than a silent no-op. Shared optionals (`pythonInterpreter`, `workingDirectory`, `failOnStderr`) are available on both builders. Changes: - `src/compile/ir/tasks/python_script.rs`: new `PythonScript` builder with `PythonScriptFile` / `PythonScriptInline` typestates plus 6 unit tests - `src/compile/ir/tasks/mod.rs`: `pub mod python_script;` declaration (alphabetical order, between powershell and publish_build_artifacts) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Adds a typed builder struct for
PythonScript@0to the ado-aw IR, following the typestate pattern established byPowerShell@2.Motivation
Previously, any code that needed to emit a
PythonScript@0step had to hand-craftTaskStep::new(...)with raw string input keys. This PR introduces two distinct typestate builders —PythonScriptFileandPythonScriptInline— so the two modes (scriptSource: filePathvsscriptSource: inline) each expose only their valid inputs. In particular,arguments(which is passed to the script viasys.argv) is only available on the file builder; calling.arguments()on an inline builder is a compile-time error rather than a silent no-op.Changes
src/compile/ir/tasks/python_script.rs: newPythonScriptzero-size entry-point struct withPythonScriptFile/PythonScriptInlinetypestate builders, a privateSharedstruct for optionals common to both modes, ashared_python_script_setters!macro, and 6#[cfg(test)]unit testssrc/compile/ir/tasks/mod.rs:pub mod python_script;declaration (alphabetical order, betweenpowershellandpublish_build_artifacts)ADO Task Reference
PythonScript@0https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/python-script-v0scriptSource(radio:filePath|inline), thenscriptPath(file mode) orscript(inline mode)arguments(file mode only),pythonInterpreter,workingDirectory,failOnStderrUsage
Validation
cargo build --all-targetscargo test(2068 + integration tests, all passing)cargo clippy --all-targets --all-features --workspace -- -D warningsCreated by the ado-task-ir-contributor workflow.
Warning
Firewall blocked 2 domains
The following domains were blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comspsprodweu4.vssps.visualstudio.comSee Network Configuration for more information.