fix(compile): allow external dependsOn/condition on job and stage template targets#823
Conversation
…plate targets
target: stage and target: job produce ADO templates. ADO's stages.template
and jobs.template schemas only permit `template:` and `parameters:` at a
template call site, so the previously documented recipe of writing
`dependsOn:`/`condition:` as bare keys on a `- template:` line is rejected
by ADO.
Surface external ordering as two auto-injected template parameters
(dependsOn: object default [], condition: string default '') and apply
them inside the template with ADO conditional expressions, preserving
ADO's native defaults when the caller omits them. For target: job, merge
the caller's params with the agent's existing internal Setup dependency
and internal condition expression (PR/pipeline gates) via dual-branch
${{ if eq/ne }} blocks, since ADO permits only one dependsOn:/
condition: key per job.
Reject user front-matter that declares parameters named dependsOn or
condition for template targets — those names are reserved.
Standalone and 1ES targets are unchanged.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Looks good — fixes a real ADO schema correctness bug with a well-reasoned implementation. A couple of minor observations below. Findings
|
Summary
target: stageandtarget: jobproduce ADO templates. The previousdocumentation and the generated header comments instructed users to
write:
…but ADO's
stages.templateand
jobs.templateschemas only permit
template:andparameters:at a template callsite. ADO rejects
dependsOn:/condition:as bare keys there. As aresult the documented external-ordering recipe never actually worked.
This PR fixes the recipe by surfacing external ordering as two
auto-injected template parameters (
dependsOn,condition) andapplying them inside the template with ADO conditional template
expressions, preserving ADO's native defaults when the caller omits
them.
Behaviour
build_parametersnow takesis_template_target: booland, when true,auto-injects:
dependsOn(object, default[])condition(string, default'')It also rejects user-declared front-matter parameters whose names
collide with the two reserved names.
For
target: stage: the inner- stage:block conditionally emitsdependsOn:/condition:via${{ if ne(...) }}blocks. Emptydefaults preserve ADO's implicit "depends on previous stage" and
succeeded()behaviour.For
target: job: the Agent job's existing internaldependsOn: Setupandcondition:(PR/pipeline gates) must merge with theexternal parameters because ADO only permits one
dependsOn:/onecondition:per job.generate_agentic_depends_ongained anis_jobs_template_targetflag that emits mutually-exclusive${{ if eq/ne }}branches:dependsOnempty branch ⇒ existingdependsOn: Setup(zerobehavioural change today)
dependsOnnon-empty branch ⇒${{ each }}mergesSetup+ thecaller's deps into one list
conditionempty branch ⇒ the existing internal expressionverbatim
conditionnon-empty branch ⇒ the existing expression with thecaller's clause ANDed as an additional term
Standalone and 1ES targets are untouched (their
parameters:block isruntime UI parameters, not template-invocation parameters).
Usage after the fix
Test plan
cargo build✓cargo test✓ — 1644 unit tests + 118 compiler integration tests + 9 new integration tests + 9 new unit tests, all greencargo clippy --all-targets --all-features✓cargo test --test bash_lint_tests✓target: stagefixture — conditional blocks render with correct indentation and ADO-template-expression syntaxtarget: jobfixture with PR filters — dual-branchdependsOn(each-merge withSetup) and dual-branchcondition(existing PR-gate expression preserved verbatim in the empty branch; ANDed with${{ parameters.condition }}in the non-empty branch)New tests
test_stage_target_auto_injects_depends_on_and_condition_paramstest_stage_target_emits_conditional_blocks_on_inner_stagetest_job_target_auto_injects_depends_on_and_condition_paramstest_job_target_minimal_emits_non_empty_only_branchestest_job_target_with_setup_emits_dual_branch_dependson_with_eachtest_standalone_target_does_not_auto_inject_template_paramstest_1es_target_does_not_auto_inject_template_paramstest_template_target_rejects_reserved_depends_on_parameter_nametest_template_target_rejects_reserved_condition_parameter_namebuild_parametersunit tests + 3 newgenerate_agentic_depends_onunit tests insrc/compile/common.rsCo-authored-by: Copilot 223556219+Copilot@users.noreply.github.com