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 all 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
76 changes: 76 additions & 0 deletions .github/workflows/copilot-setup-steps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
##############################
# 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

name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yaml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yaml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read

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 with retry logic (from CI pipelines)
set -x
i=0; while [ $i -lt 5 ] && ! sudo apt-get update; do let "i=i+1"; sleep 1; done;

# Install build dependencies required for OpenVMM
sudo apt-get -o DPkg::Lock::Timeout=60 install -y \
binutils \
build-essential \
gcc \
gcc-aarch64-linux-gnu \
libssl-dev \
pkg-config

- name: Checkout repository
uses: actions/checkout@v4

- 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 0.9.96 --locked
30 changes: 30 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,30 @@
// 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(".github/workflows/copilot-setup-steps.yaml");

// Ensure the output directory exists
if let Some(parent) = output_file.parent() {
std::fs::create_dir_all(parent)?;
}

let content = generate_copilot_setup_steps();

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

println!("Generated .github/workflows/copilot-setup-steps.yaml");
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.

crate::pipelines_shared::copilot_setup_steps_template::get_template()
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

//! See [`get_template`]

/// Get our internal copilot setup steps template.
///
/// This template provides the steps needed to set up the OpenVMM development
/// environment for GitHub Copilot's Coding Agent.
pub fn get_template() -> String {
let template = include_str!("copilot_setup_steps_template.yml").to_string();

template
.replace(
"{{RUSTUP_TOOLCHAIN}}",
flowey_lib_hvlite::_jobs::cfg_versions::RUSTUP_TOOLCHAIN,
)
.replace(
"{{NEXTEST_VERSION}}",
flowey_lib_hvlite::_jobs::cfg_versions::NEXTEST,
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
##############################
# 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

name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yaml
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yaml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps.
# Copilot will be given its own token for its operations.
permissions:
# If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
contents: read

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={{RUSTUP_TOOLCHAIN}}
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 with retry logic (from CI pipelines)
set -x
i=0; while [ $i -lt 5 ] && ! sudo apt-get update; do let "i=i+1"; sleep 1; done;

# Install build dependencies required for OpenVMM
sudo apt-get -o DPkg::Lock::Timeout=60 install -y \
binutils \
build-essential \
gcc \
gcc-aarch64-linux-gnu \
libssl-dev \
pkg-config

- name: Checkout repository
uses: actions/checkout@v4

- 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
1 change: 1 addition & 0 deletions flowey/flowey_hvlite/src/pipelines_shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
//! Shared constants and helper functionality used across multiple pipelines.

pub mod cfg_common_params;
pub mod copilot_setup_steps_template;
pub mod gh_flowey_bootstrap_template;
pub mod gh_pools;