Skip to content

feat(ir): add typed builder for PythonScript@0#1128

Merged
jamesadevine merged 1 commit into
mainfrom
feat/ir-python-script-task-dc11c4327081c086
Jun 21, 2026
Merged

feat(ir): add typed builder for PythonScript@0#1128
jamesadevine merged 1 commit into
mainfrom
feat/ir-python-script-task-dc11c4327081c086

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Summary

Adds a typed builder struct for PythonScript@0 to the ado-aw IR, following the typestate pattern established by PowerShell@2.

Motivation

Previously, any code that needed to emit a PythonScript@0 step had to hand-craft TaskStep::new(...) with raw string input keys. This PR introduces two distinct typestate builders — PythonScriptFile and PythonScriptInline — so the two modes (scriptSource: filePath vs scriptSource: inline) each expose only their valid inputs. In particular, arguments (which is passed to the script via sys.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: new PythonScript zero-size entry-point struct with PythonScriptFile / PythonScriptInline typestate builders, a private Shared struct for optionals common to both modes, a shared_python_script_setters! macro, and 6 #[cfg(test)] unit tests
  • src/compile/ir/tasks/mod.rs: pub mod python_script; declaration (alphabetical order, between powershell and publish_build_artifacts)

ADO Task Reference

  • Task: PythonScript@0
  • Docs: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/python-script-v0
  • Required inputs: scriptSource (radio: filePath | inline), then scriptPath (file mode) or script (inline mode)
  • Optional inputs: arguments (file mode only), pythonInterpreter, workingDirectory, failOnStderr

Usage

// File mode — run a script file with arguments
Step::Task(
    PythonScript::file("scripts/analyze.py")
        .arguments("--config release")
        .working_directory("$(Build.SourcesDirectory)")
        .into_step()
)

// Inline mode — run a short Python block
Step::Task(
    PythonScript::inline("import sys; print(sys.version)")
        .python_interpreter("python3.11")
        .into_step()
)

Validation

  • cargo build --all-targets
  • cargo test (2068 + integration tests, all passing)
  • cargo clippy --all-targets --all-features --workspace -- -D warnings

Created 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.com
  • spsprodweu4.vssps.visualstudio.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "spsprodeus21.vssps.visualstudio.com"
    - "spsprodweu4.vssps.visualstudio.com"

See Network Configuration for more information.

Generated by ADO Task IR Contributor · 926 AIC · ⌖ 30 AIC · ⊞ 38.1K ·

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>
@jamesadevine jamesadevine marked this pull request as ready for review June 21, 2026 07:37
@jamesadevine jamesadevine merged commit 6315119 into main Jun 21, 2026
@jamesadevine jamesadevine deleted the feat/ir-python-script-task-dc11c4327081c086 branch June 21, 2026 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant