Skip to content

Commit 06328f2

Browse files
jstarksmoor-coding
authored andcommitted
Add Copilot coding agent setup steps and inner loop guidance (microsoft#3099)
Add .github/workflows/copilot-setup-steps.yml to give the Copilot coding agent a working Rust toolchain, cargo-nextest, and restore-packages (protoc + build deps) so it can validate changes locally before pushing.
1 parent bd66c9b commit 06328f2

4 files changed

Lines changed: 94 additions & 15 deletions

File tree

‎.github/copilot-instructions.md‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,28 @@ This project uses the **Rust 2024 edition** (`edition = "2024"` in root
117117
hand-edit them. Run `cargo xflowey regen` to regenerate.
118118
- **flowey nodes**: Use `flowey::shell_cmd!` and `rt.sh` inside flowey
119119
nodes — not `xshell::cmd!` or `xshell::Shell::new`.
120+
121+
## Autonomous Agent Inner Loop
122+
123+
When running as a coding agent (GitHub Copilot coding agent or similar),
124+
follow this validation loop **before pushing each commit**. This covers
125+
the common early CI failures (including the fmt + clippy checks from job0)
126+
locally, avoiding slow push-and-wait cycles.
127+
128+
1. **Identify modified packages.** For each file you changed, find the
129+
crate's `Cargo.toml` and note the package name.
130+
2. **Check compilation:** `cargo check -p <package>` — fast type-check.
131+
3. **Clippy:** `cargo clippy --all-targets -p <package>` — lint.
132+
4. **Doc:** `cargo doc --no-deps -p <package>` — catch doc errors.
133+
5. **Unit tests:** `cargo nextest run -p <package>` — run the crate's
134+
tests. If nextest is not installed, use `cargo test -p <package>`.
135+
6. **Formatting:** `cargo xtask fmt --fix` — run last, since earlier
136+
fixes may introduce formatting changes.
137+
138+
If any step fails, fix the issue and re-run from that step. Do not push
139+
until all six steps pass.
140+
141+
**Cost notes:** Steps 2–5 are scoped to the modified package (`-p`),
142+
so they are fast even in this large workspace. Step 6 runs workspace-wide
143+
but is also fast. The full cycle typically takes under 2 minutes for
144+
a single-crate change.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: "Copilot Setup Steps"
2+
3+
# Validate the setup steps when they change, and allow manual testing.
4+
on:
5+
workflow_dispatch:
6+
push:
7+
paths:
8+
- .github/workflows/copilot-setup-steps.yml
9+
pull_request:
10+
paths:
11+
- .github/workflows/copilot-setup-steps.yml
12+
13+
jobs:
14+
# This job name is required — the Copilot coding agent looks for it by name.
15+
copilot-setup-steps:
16+
runs-on: ubuntu-latest
17+
permissions:
18+
contents: read
19+
steps:
20+
- name: Checkout code
21+
uses: actions/checkout@v6
22+
23+
# Install the exact Rust toolchain used by CI.
24+
- name: Install Rust toolchain
25+
run: |
26+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
27+
| sh -s -- --default-toolchain=1.94.0 -y
28+
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
29+
30+
# Install cargo-nextest so the agent can run unit tests.
31+
# Keep this version in sync with NEXTEST in
32+
# flowey/flowey_lib_hvlite/src/_jobs/cfg_versions.rs
33+
- name: Install cargo-nextest
34+
run: |
35+
curl -LsSf https://get.nexte.st/0.9.101/linux | tar zxf - -C "$HOME/.cargo/bin"
36+
37+
# Restore protoc and other build dependencies via the canonical
38+
# flowey pipeline. This compiles flowey_hvlite first, then downloads
39+
# protoc, sysroots, firmware, and test kernels.
40+
- name: Restore packages
41+
run: cargo xflowey restore-packages --no-compat-igvm

‎flowey/flowey_hvlite/src/pipelines/restore_packages.rs‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ pub struct RestorePackagesCli {
1212
///
1313
/// If none are specified, defaults to just the current host architecture.
1414
arch: Vec<CommonArchCli>,
15+
16+
/// Skip downloading released OpenHCL IGVM files used for compatibility testing.
17+
///
18+
/// This avoids the need for `gh` CLI authentication.
19+
#[clap(long)]
20+
no_compat_igvm: bool,
1521
}
1622

1723
impl IntoPipeline for RestorePackagesCli {
@@ -21,7 +27,11 @@ impl IntoPipeline for RestorePackagesCli {
2127
);
2228

2329
let mut pipeline = Pipeline::new();
24-
let (pub_last_release_igvm_files, _) = pipeline.new_artifact("last-release-igvm-files");
30+
let pub_last_release_igvm_files = if self.no_compat_igvm {
31+
None
32+
} else {
33+
Some(pipeline.new_artifact("last-release-igvm-files").0)
34+
};
2535
let mut job = pipeline
2636
.new_job(
2737
FlowPlatform::host(backend_hint),
@@ -59,7 +69,7 @@ impl IntoPipeline for RestorePackagesCli {
5969
|ctx| flowey_lib_hvlite::_jobs::local_restore_packages::Request {
6070
arches,
6171
done: ctx.new_done_handle(),
62-
release_artifact: ctx.publish_artifact(pub_last_release_igvm_files),
72+
release_artifact: pub_last_release_igvm_files.map(|a| ctx.publish_artifact(a)),
6373
},
6474
);
6575
job.finish();

‎flowey/flowey_lib_hvlite/src/_jobs/local_restore_packages.rs‎

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ flowey_request! {
1111
pub struct Request{
1212
pub arches: Vec<CommonArch>,
1313
pub done: WriteVar<SideEffect>,
14-
pub release_artifact: ReadVar<PathBuf>,
14+
/// If `None`, skip downloading OpenHCL IGVM release files.
15+
pub release_artifact: Option<ReadVar<PathBuf>>,
1516
}
1617
}
1718

@@ -85,18 +86,20 @@ impl SimpleFlowNode for Node {
8586
}
8687
}
8788

88-
deps.push(
89-
ctx.reqv(
90-
|v| crate::init_openvmm_magicpath_release_openhcl_igvm::resolve::Request {
91-
arch,
92-
release_version:
93-
crate::download_release_igvm_files_from_gh::OpenhclReleaseVersion::latest(),
94-
release_artifact:release_artifact.clone(),
95-
done: v,
96-
},
97-
)
98-
.into_side_effect(),
99-
);
89+
if let Some(release_artifact) = &release_artifact {
90+
deps.push(
91+
ctx.reqv(
92+
|v| crate::init_openvmm_magicpath_release_openhcl_igvm::resolve::Request {
93+
arch,
94+
release_version:
95+
crate::download_release_igvm_files_from_gh::OpenhclReleaseVersion::latest(),
96+
release_artifact: release_artifact.clone(),
97+
done: v,
98+
},
99+
)
100+
.into_side_effect(),
101+
);
102+
}
100103
}
101104

102105
ctx.emit_side_effect_step(deps, [done]);

0 commit comments

Comments
 (0)