Skip to content

Commit 3e67cfd

Browse files
authored
feat(compile): add compact repos: front-matter syntax with codemod auto-rewrite (#478)
1 parent 64bbc73 commit 3e67cfd

10 files changed

Lines changed: 1038 additions & 83 deletions

File tree

docs/front-matter.md

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,17 @@ engine: copilot # Engine identifier. Defaults to copilot. Currently only 'copilo
1616
# id: copilot
1717
# model: claude-opus-4.7
1818
# timeout-minutes: 30
19-
workspace: repo # Optional: "root", "repo" (alias: "self"), or a checked-out repository alias. If not specified, defaults to "root" when no additional repositories are listed in `checkout:`, and to "repo" when one or more additional repos are checked out. See "Workspace Defaults" below.
19+
workspace: repo # Optional: "root", "repo" (alias: "self"), or a checked-out repository alias. If not specified, defaults to "root" when no additional repositories are listed in `repos:`, and to "repo" when one or more additional repos are checked out. See "Workspace Defaults" below.
2020
pool: AZS-1ES-L-MMS-ubuntu-22.04 # Agent pool name (string format). Defaults to AZS-1ES-L-MMS-ubuntu-22.04.
2121
# pool: # Alternative object format (required for 1ES if specifying os)
2222
# name: AZS-1ES-L-MMS-ubuntu-22.04
2323
# os: linux # Operating system: "linux" or "windows". Defaults to "linux".
24-
repositories: # a list of repository resources available to the pipeline (for pre/post jobs, templates, etc.)
25-
- repository: reponame
26-
type: git
27-
name: my-org/my-repo
28-
- repository: another-repo
29-
type: git
30-
name: my-org/another-repo
31-
checkout: # optional list of repository aliases for the agent to checkout and work with (must be subset of repositories)
32-
- reponame # only checkout reponame, not another-repo
24+
repos: # compact repository declarations (replaces repositories: + checkout:)
25+
- my-org/my-repo # shorthand: alias="my-repo", type=git, ref=refs/heads/main, checkout=true
26+
- reponame=my-org/another-repo # shorthand with explicit alias
27+
- name: my-org/templates # object form for full control
28+
ref: refs/heads/release/2.x
29+
checkout: false # declared as resource only, not checked out by the agent
3330
tools: # optional tool configuration
3431
bash: ["cat", "ls", "grep"] # bash command allow-list (defaults to safe built-in list)
3532
edit: true # enable file editing tool (default: true)
@@ -152,19 +149,83 @@ Build the project and run all tests...
152149
## Workspace Defaults
153150

154151
The `workspace:` field controls which directory the agent runs in. When it is
155-
not set explicitly, the compiler chooses a default based on the `checkout:`
156-
list:
152+
not set explicitly, the compiler chooses a default based on which repositories
153+
are checked out (entries in `repos:` with `checkout: true`, which is the
154+
default):
157155

158-
- If `checkout:` is empty (i.e. only the pipeline's own repository is checked
159-
out via the implicit `self`), `workspace:` defaults to **`root`** — the
160-
agent runs in the pipeline's working directory root.
161-
- If `checkout:` lists one or more additional repository aliases,
162-
`workspace:` defaults to **`repo`** — the agent runs inside the first
163-
checked-out repository's directory.
156+
- If no additional repositories are checked out (i.e. only the pipeline's own
157+
repository is checked out via the implicit `self`), `workspace:` defaults to
158+
**`root`** — the agent runs in the pipeline's working directory root.
159+
- If one or more additional repositories are checked out, `workspace:` defaults
160+
to **`repo`** — the agent runs inside the trigger repository's directory.
164161

165162
Set `workspace:` explicitly to `root`, `repo` (alias `self`), or a specific
166163
checked-out repository alias to override this behavior.
167164

165+
## Repositories (`repos:`)
166+
167+
The `repos:` field provides a compact way to declare additional repository
168+
resources and control which ones the agent checks out. It replaces the legacy
169+
`repositories:` + `checkout:` pair.
170+
171+
Each entry can be:
172+
173+
| Form | Syntax | Description |
174+
|------|--------|-------------|
175+
| **Shorthand** | `- org/repo` | Alias derived from last segment, type=git, ref=refs/heads/main, checkout=true |
176+
| **Shorthand with alias** | `- alias=org/repo` | Explicit alias before `=` |
177+
| **Object** | `- name: org/repo` | Full control over all fields |
178+
179+
Object fields:
180+
181+
| Field | Default | Description |
182+
|------------|------------------------|-------------|
183+
| `name` | *(required)* | Full `org/repo` name (maps to ADO `name:`) |
184+
| `alias` | last segment of `name` | Repository alias (maps to ADO `repository:`) |
185+
| `type` | `git` | ADO repository resource type |
186+
| `ref` | `refs/heads/main` | Branch or tag reference |
187+
| `checkout` | `true` | Whether the agent job clones this repo |
188+
189+
### Examples
190+
191+
Three repos, all checked out (most common case):
192+
193+
```yaml
194+
repos:
195+
- my-org/tools
196+
- my-org/schemas
197+
- my-org/docs
198+
```
199+
200+
Mixed: two checked out, one resource-only (used by templates):
201+
202+
```yaml
203+
repos:
204+
- my-org/tools
205+
- my-org/schemas
206+
- name: my-org/pipeline-templates
207+
checkout: false
208+
```
209+
210+
Custom ref and explicit alias:
211+
212+
```yaml
213+
repos:
214+
- name: my-org/docs
215+
alias: docs-v2
216+
ref: refs/heads/release/2.x
217+
```
218+
219+
### Legacy syntax (auto-rewritten)
220+
221+
The legacy `repositories:` + `checkout:` fields are auto-converted to
222+
`repos:` by the [`repos_unified` codemod](codemods.md). On the next
223+
`ado-aw compile`, any source that still uses the legacy fields is
224+
rewritten in place to the new shape — each `repositories:` entry
225+
becomes a `repos:` entry, with `checkout: false` added for entries
226+
that weren't listed under `checkout:`. Mixing the legacy fields with
227+
an existing `repos:` block is rejected; pick one shape.
228+
168229
## Filter Validation
169230

170231
The compiler validates filter configurations at compile time and will emit

0 commit comments

Comments
 (0)