Skip to content

Commit 8df9682

Browse files
jamesadevineCopilotCopilot
authored
feat(compile): add target: job and target: stage for ADO template output (#519)
* feat(compile): add target: job and target: stage for ADO template output Add two new compile targets that produce reusable ADO YAML templates for embedding agentic stages into existing pipelines: - target: job — generates a job-level template (jobs: at root) that can be included in a flat pipeline or inside a user-defined stage - target: stage — generates a stage-level template (stages: wrapping jobs) for direct inclusion in multi-stage pipelines Key design decisions: - Pool is baked in from front matter (not a template parameter) - dependsOn and condition are set natively at the ADO call site - Job names are prefixed with PascalCase agent name for uniqueness (e.g., DailyReview_Agent, DailyReview_Detection, DailyReview_Execution) - Triggers (on:) are ignored with a warning in template targets - Template parameters only include clearMemory and user-defined params New files: - src/compile/job.rs — JobCompiler implementing the Compiler trait - src/compile/stage.rs — StageCompiler implementing the Compiler trait - src/data/job-base.yml — job-level template derived from base.yml - src/data/stage-base.yml — stage-level template wrapping jobs in stage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix(compile): implement review suggestions for job/stage template targets Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/fa2ca612-1703-4107-87c3-2b2ec35429b8 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com> * fix(compile): use 'template' label for job/stage targets and fix header paths - CLI now prints 'Generated job template:' and 'Generated stage template:' instead of 'Generated job pipeline:' / 'Generated stage pipeline:' since these targets produce reusable ADO templates, not standalone pipelines. - Header comments in generated job/stage templates now reference the actual output path instead of deriving a path from the input file, fixing incorrect inclusion examples (e.g. showing ./agents/x.lock.yml when the output was at ./x.lock.yml). Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 9d8f445 commit 8df9682

3 files changed

Lines changed: 19 additions & 18 deletions

File tree

src/compile/common.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2861,11 +2861,11 @@ pub async fn compile_shared(
28612861
///
28622862
/// Handles the full setup — collecting extensions, building the compile context,
28632863
/// generating the stage prefix and template parameters, computing AWF/MCPG
2864-
/// values — and delegates to [`compile_shared`]. The caller supplies:
2864+
/// values — and delegates to [`compile_shared`]. The caller supplies:
28652865
///
28662866
/// - `cfg`: target-specific settings (template string, integrity / debug flags).
28672867
/// - `header_fn`: a function that generates the leading comment block prepended
2868-
/// to the compiled YAML. The two template compilers use different header
2868+
/// to the compiled YAML. The two template compilers use different header
28692869
/// layouts, so this lets each compiler keep its own generator while sharing
28702870
/// all of the boilerplate setup.
28712871
///
@@ -2927,9 +2927,15 @@ pub async fn compile_template_target(
29272927
};
29282928

29292929
let yaml = compile_shared(
2930-
input_path, output_path, front_matter, markdown_body,
2931-
&extensions, &ctx, config,
2932-
).await?;
2930+
input_path,
2931+
output_path,
2932+
front_matter,
2933+
markdown_body,
2934+
&extensions,
2935+
&ctx,
2936+
config,
2937+
)
2938+
.await?;
29332939

29342940
let header = header_fn(input_path, output_path, front_matter);
29352941
Ok(format!("{}{}", header, yaml))

src/compile/job.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ use std::path::Path;
1414

1515
use super::Compiler;
1616
use super::common::{
17-
compile_template_target, TemplateTargetConfig,
18-
generate_header_comment,
17+
compile_template_target, generate_header_comment, TemplateTargetConfig,
1918
};
2019
use super::types::FrontMatter;
2120

@@ -52,16 +51,15 @@ impl Compiler for JobCompiler {
5251
debug_pipeline,
5352
},
5453
generate_job_header,
55-
).await
54+
)
55+
.await
5656
}
5757
}
5858

5959
/// Generate the header comment block for job-level templates.
6060
fn generate_job_header(input_path: &Path, output_path: &Path, front_matter: &FrontMatter) -> String {
6161
let base_header = generate_header_comment(input_path);
62-
let mut lock_path = output_path
63-
.to_string_lossy()
64-
.replace('\\', "/");
62+
let mut lock_path = output_path.to_string_lossy().replace('\\', "/");
6563
// Strip redundant leading "./" (same normalization as generate_header_comment)
6664
while lock_path.starts_with("./") {
6765
lock_path = lock_path[2..].to_string();
@@ -102,7 +100,6 @@ fn generate_job_header(input_path: &Path, output_path: &Path, front_matter: &Fro
102100

103101
#[cfg(test)]
104102
mod tests {
105-
use super::*;
106103
use crate::compile::common::generate_stage_prefix;
107104

108105
#[test]

src/compile/stage.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ use std::path::Path;
2222

2323
use super::Compiler;
2424
use super::common::{
25-
compile_template_target, TemplateTargetConfig,
26-
generate_header_comment,
25+
compile_template_target, generate_header_comment, TemplateTargetConfig,
2726
};
2827
use super::types::FrontMatter;
2928

@@ -60,16 +59,15 @@ impl Compiler for StageCompiler {
6059
debug_pipeline,
6160
},
6261
generate_stage_header,
63-
).await
62+
)
63+
.await
6464
}
6565
}
6666

6767
/// Generate the header comment block for stage-level templates.
6868
fn generate_stage_header(input_path: &Path, output_path: &Path, front_matter: &FrontMatter) -> String {
6969
let base_header = generate_header_comment(input_path);
70-
let mut lock_path = output_path
71-
.to_string_lossy()
72-
.replace('\\', "/");
70+
let mut lock_path = output_path.to_string_lossy().replace('\\', "/");
7371
while lock_path.starts_with("./") {
7472
lock_path = lock_path[2..].to_string();
7573
}

0 commit comments

Comments
 (0)