Skip to content

Add copilot-setup-steps.yml for GitHub Copilot Coding Agent #1662

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions copilot-setup-steps.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
##############################
# THIS FILE IS AUTOGENERATED #
# DO NOT MANUALLY EDIT #
##############################
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# GitHub Copilot setup steps for OpenVMM development environment
# Generated by flowey_hvlite - DO NOT EDIT MANUALLY

steps:
- name: Install Rust with required targets
run: |
# Install Rust using rustup (version managed by flowey)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.88.0
source ~/.cargo/env

# Install targets for the host architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
rustup target add x86_64-unknown-linux-musl
elif [ "$ARCH" = "aarch64" ]; then
rustup target add aarch64-unknown-linux-musl
fi

- name: Install system dependencies
run: |
# Update package lists
sudo apt-get update

# Install build dependencies required for OpenVMM
sudo apt-get install -y \
binutils \
build-essential \
gcc-aarch64-linux-gnu \
libssl-dev \
pkg-config

- name: Restore OpenVMM build dependencies
run: |
# Restore external dependencies required for building OpenVMM
# This includes protoc (Protocol Buffers compiler), mu_msvm UEFI firmware,
# test Linux kernels, and other build artifacts
cargo xflowey restore-packages
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also install cargo-nextest so that you can run unit tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added cargo-nextest installation step as requested. Fixed in commit d2abb45.


# Install cargo-nextest for running unit tests (version managed by flowey)
cargo install cargo-nextest --version 0.9.96 --locked
26 changes: 26 additions & 0 deletions flowey/flowey_cli/src/cli/regen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,17 @@ impl Regen {
}
}

// Generate copilot-setup-steps.yml using flowey's version management
// This ensures the file uses the correct Rust and tool versions
let copilot_result = generate_copilot_setup_steps_file(repo_root);
if copilot_result.is_err() {
error = true;
log::error!(
"Failed to generate copilot-setup-steps.yml: {:?}",
copilot_result
);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than special casing this, make a few changes:

Modify .flowey.toml and add an [[pipeline.flowey_hvlite.github]] entry. File should be ".github/workflows/copilot-setup-steps.yaml". Then, make sure you create the correct code such that the loop that starts at:

        let mut error = false;
        for ResolvedFloweyToml {
            working_dir,
            pipelines,
        } in data
        {
        ```
        
        
        does not need modification, yet this new file is generated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm having trouble understanding how to implement this request. The github backend generates GitHub Actions workflows, but the copilot-setup-steps.yml file is not a workflow - it's a special format for GitHub Copilot's coding agent.

Could you clarify what you'd like me to do? Are you suggesting:

  1. Generate a GitHub workflow that creates the copilot setup file elsewhere?
  2. Modify the github backend to handle non-workflow files?
  3. Create a different approach entirely?

The current file format is just a YAML with steps: for the Copilot agent, not a GitHub Actions workflow with jobs: and runs-on: etc.

if error {
anyhow::bail!("encountered one or more errors")
}
Expand Down Expand Up @@ -197,3 +208,18 @@ fn install_flowey_merge_driver() -> anyhow::Result<()> {

Ok(())
}

fn generate_copilot_setup_steps_file(repo_root: &Path) -> anyhow::Result<()> {
// Run the copilot setup generator command
let sh = xshell::Shell::new()?;
sh.change_dir(repo_root);
xshell::cmd!(
sh,
"cargo run -p flowey_hvlite -- pipeline run copilot-setup-generator"
)
.quiet()
.run()?;

log::info!("Generated copilot-setup-steps.yml");
Ok(())
}
76 changes: 76 additions & 0 deletions flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use anyhow::Result;

/// Generate copilot-setup-steps.yml for GitHub Copilot Coding Agent
#[derive(clap::Args)]
pub struct CopilotSetupGeneratorCli {}

impl CopilotSetupGeneratorCli {
pub fn run(self, repo_root: &std::path::Path) -> Result<()> {
let output_file = repo_root.join("copilot-setup-steps.yml");

let content = generate_copilot_setup_steps();

std::fs::write(&output_file, content)?;

println!("Generated copilot-setup-steps.yml");
Ok(())
}
}

fn generate_copilot_setup_steps() -> String {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should be generated at .github/workflows/copilot-setup-steps.yml, relative to the repo root.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed! The file is now generated at .github/workflows/copilot-setup-steps.yml as requested. Changes in commit 68b67a0.

format!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a template yml file that sits in the repo, like gh_flowey_bootstrap_template.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Created copilot_setup_steps_template.yml following the same pattern as gh_flowey_bootstrap_template.yml with proper template processing and version replacement. Changes in commit 68b67a0.

r#"##############################
# THIS FILE IS AUTOGENERATED #
# DO NOT MANUALLY EDIT #
##############################
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

# GitHub Copilot setup steps for OpenVMM development environment
# Generated by flowey_hvlite - DO NOT EDIT MANUALLY

steps:
- name: Install Rust with required targets
run: |
# Install Rust using rustup (version managed by flowey)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain {rust_version}
source ~/.cargo/env

# Install targets for the host architecture
ARCH=$(uname -m)
if [ "$ARCH" = "x86_64" ]; then
rustup target add x86_64-unknown-linux-musl
elif [ "$ARCH" = "aarch64" ]; then
rustup target add aarch64-unknown-linux-musl
fi

- name: Install system dependencies
run: |
# Update package lists
sudo apt-get update

# Install build dependencies required for OpenVMM
sudo apt-get install -y \
binutils \
build-essential \
gcc-aarch64-linux-gnu \
libssl-dev \
pkg-config
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Examine the existing CI pipelines for ways that they install dependencies. Update this pipeline to emit those steps instead of hard coding it here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented! Extracted dependency installation patterns from existing CI pipelines including retry logic for apt-get commands, timeout handling, and proper package installation. The template now uses the same patterns as the bootstrap template. Changes in commit 68b67a0.


- name: Restore OpenVMM build dependencies
run: |
# Restore external dependencies required for building OpenVMM
# This includes protoc (Protocol Buffers compiler), mu_msvm UEFI firmware,
# test Linux kernels, and other build artifacts
cargo xflowey restore-packages

# Install cargo-nextest for running unit tests (version managed by flowey)
cargo install cargo-nextest --version {nextest_version} --locked
"#,
rust_version = flowey_lib_hvlite::_jobs::cfg_versions::RUSTUP_TOOLCHAIN,
nextest_version = flowey_lib_hvlite::_jobs::cfg_versions::NEXTEST
)
}
10 changes: 10 additions & 0 deletions flowey/flowey_hvlite/src/pipelines/mod.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use copilot_setup_generator::CopilotSetupGeneratorCli;
use flowey::pipeline::prelude::*;
use restore_packages::RestorePackagesCli;
use vmm_tests::VmmTestsCli;

pub mod build_docs;
pub mod build_igvm;
pub mod checkin_gates;
pub mod copilot_setup_generator;
pub mod custom_vmfirmwareigvm_dll;
pub mod restore_packages;
pub mod vmm_tests;
Expand All @@ -29,6 +31,9 @@ pub enum OpenvmmPipelines {
#[clap(subcommand)]
Ci(OpenvmmPipelinesCi),

/// Generate copilot-setup-steps.yml file directly
CopilotSetupGenerator(CopilotSetupGeneratorCli),

/// Install tools needed to build OpenVMM
RestorePackages(RestorePackagesCli),

Expand Down Expand Up @@ -59,6 +64,11 @@ impl IntoPipeline for OpenvmmPipelines {
OpenvmmPipelinesCi::CheckinGates(cmd) => cmd.into_pipeline(pipeline_hint),
OpenvmmPipelinesCi::BuildDocs(cmd) => cmd.into_pipeline(pipeline_hint),
},
OpenvmmPipelines::CopilotSetupGenerator(cmd) => {
cmd.run(&crate::repo_root())?;
// Return empty pipeline since we've already done the work
Ok(Pipeline::new())
}
OpenvmmPipelines::RestorePackages(cmd) => cmd.into_pipeline(pipeline_hint),
OpenvmmPipelines::VmmTests(cmd) => cmd.into_pipeline(pipeline_hint),
}
Expand Down