From 31c3c96a89626a4d0a72d2dc526669f84fc2f472 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 18:12:06 +0000 Subject: [PATCH 01/10] Initial plan From 97e11e29627980c54cf3279d16849d046b3f1974 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 18:21:28 +0000 Subject: [PATCH 02/10] Add copilot-setup-steps.yml for GitHub Copilot Coding Agent Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- copilot-setup-steps.yml | 57 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 copilot-setup-steps.yml diff --git a/copilot-setup-steps.yml b/copilot-setup-steps.yml new file mode 100644 index 0000000000..d16635ebdd --- /dev/null +++ b/copilot-setup-steps.yml @@ -0,0 +1,57 @@ +# GitHub Copilot setup steps for OpenVMM development environment +# Based on the devcontainer configuration and getting started documentation + +steps: + - name: Install Rust with required targets + run: | + # Install Rust using rustup (tracks latest stable as per project requirements) + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable + source ~/.cargo/env + + # Install all required targets for OpenVMM cross-compilation + rustup target add aarch64-apple-darwin + rustup target add aarch64-unknown-linux-musl + rustup target add x86_64-pc-windows-msvc + rustup target add x86_64-unknown-linux-gnu + rustup target add x86_64-unknown-linux-musl + rustup target add x86_64-unknown-none + + - 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 + + - name: Set up development tools + run: | + # Install git hooks for automatic formatting (recommended) + cargo xtask install-git-hooks --pre-push --with-fmt=yes + + - name: Verify installation + run: | + # Verify that Rust and required tools are installed + rustc --version + cargo --version + + # Check that required targets are installed + rustup target list --installed + + # Run formatting checks to ensure environment is set up correctly + cargo xtask fmt + + # Test that basic workspace check works + cargo check --workspace From 9c25f106cb7e9e93e1aa437106789b6edeec8d32 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 18:46:06 +0000 Subject: [PATCH 03/10] Address PR feedback: add copyright header, remove git hooks and verification steps Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- copilot-setup-steps.yml | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/copilot-setup-steps.yml b/copilot-setup-steps.yml index d16635ebdd..e7092d92ee 100644 --- a/copilot-setup-steps.yml +++ b/copilot-setup-steps.yml @@ -1,3 +1,6 @@ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. + # GitHub Copilot setup steps for OpenVMM development environment # Based on the devcontainer configuration and getting started documentation @@ -35,23 +38,3 @@ steps: # This includes protoc (Protocol Buffers compiler), mu_msvm UEFI firmware, # test Linux kernels, and other build artifacts cargo xflowey restore-packages - - - name: Set up development tools - run: | - # Install git hooks for automatic formatting (recommended) - cargo xtask install-git-hooks --pre-push --with-fmt=yes - - - name: Verify installation - run: | - # Verify that Rust and required tools are installed - rustc --version - cargo --version - - # Check that required targets are installed - rustup target list --installed - - # Run formatting checks to ensure environment is set up correctly - cargo xtask fmt - - # Test that basic workspace check works - cargo check --workspace From 22b8382c4fe73f9091b4bc85cf80e461edc033af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 19:50:21 +0000 Subject: [PATCH 04/10] Simplify Rust target installation to match host architecture only Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- copilot-setup-steps.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/copilot-setup-steps.yml b/copilot-setup-steps.yml index e7092d92ee..c43336c79c 100644 --- a/copilot-setup-steps.yml +++ b/copilot-setup-steps.yml @@ -11,13 +11,13 @@ steps: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable source ~/.cargo/env - # Install all required targets for OpenVMM cross-compilation - rustup target add aarch64-apple-darwin - rustup target add aarch64-unknown-linux-musl - rustup target add x86_64-pc-windows-msvc - rustup target add x86_64-unknown-linux-gnu - rustup target add x86_64-unknown-linux-musl - rustup target add x86_64-unknown-none + # 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: | From d2abb454c303c8b344ef6f7d7c64b1d0b67ec412 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 19:58:32 +0000 Subject: [PATCH 05/10] Add cargo-nextest installation to copilot setup steps Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- copilot-setup-steps.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/copilot-setup-steps.yml b/copilot-setup-steps.yml index c43336c79c..caf2d387f0 100644 --- a/copilot-setup-steps.yml +++ b/copilot-setup-steps.yml @@ -38,3 +38,6 @@ steps: # 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 + cargo install cargo-nextest --locked From c194e8e2c3d509f3a5854cad49ee6b5ff0598e7b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:19:15 +0000 Subject: [PATCH 06/10] Implement flowey-generated copilot-setup-steps.yml with version management Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- copilot-setup-steps.yml | 14 ++-- flowey/flowey_cli/src/cli/regen.rs | 26 +++++++ .../src/pipelines/copilot_setup_generator.rs | 76 +++++++++++++++++++ flowey/flowey_hvlite/src/pipelines/mod.rs | 10 +++ 4 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs diff --git a/copilot-setup-steps.yml b/copilot-setup-steps.yml index caf2d387f0..1c6301165d 100644 --- a/copilot-setup-steps.yml +++ b/copilot-setup-steps.yml @@ -1,14 +1,18 @@ +############################## +# 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 -# Based on the devcontainer configuration and getting started documentation +# Generated by flowey_hvlite - DO NOT EDIT MANUALLY steps: - name: Install Rust with required targets run: | - # Install Rust using rustup (tracks latest stable as per project requirements) - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable + # 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 @@ -39,5 +43,5 @@ steps: # test Linux kernels, and other build artifacts cargo xflowey restore-packages - # Install cargo-nextest for running unit tests - cargo install cargo-nextest --locked + # Install cargo-nextest for running unit tests (version managed by flowey) + cargo install cargo-nextest --version 0.9.96 --locked diff --git a/flowey/flowey_cli/src/cli/regen.rs b/flowey/flowey_cli/src/cli/regen.rs index 6a396b5a56..82040de66a 100644 --- a/flowey/flowey_cli/src/cli/regen.rs +++ b/flowey/flowey_cli/src/cli/regen.rs @@ -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 + ); + } + if error { anyhow::bail!("encountered one or more errors") } @@ -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(()) +} diff --git a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs new file mode 100644 index 0000000000..4721e25b20 --- /dev/null +++ b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs @@ -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 { + format!( + 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 + + - 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 + ) +} diff --git a/flowey/flowey_hvlite/src/pipelines/mod.rs b/flowey/flowey_hvlite/src/pipelines/mod.rs index 54865221e2..2117b979bd 100644 --- a/flowey/flowey_hvlite/src/pipelines/mod.rs +++ b/flowey/flowey_hvlite/src/pipelines/mod.rs @@ -1,6 +1,7 @@ // 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; @@ -8,6 +9,7 @@ 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; @@ -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), @@ -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), } From 68b67a001f7fd3af5b2950c4b0e5a6c4a8a678ea Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 21:39:12 +0000 Subject: [PATCH 07/10] Address PR feedback: move to .github/workflows/, use template approach, extract CI patterns Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- .../workflows/copilot-setup-steps.yml | 10 ++-- .../src/pipelines/copilot_setup_generator.rs | 57 ++++--------------- .../copilot_setup_steps_template.rs | 22 +++++++ .../copilot_setup_steps_template.yml | 42 ++++++++++++++ .../flowey_hvlite/src/pipelines_shared/mod.rs | 1 + 5 files changed, 82 insertions(+), 50 deletions(-) rename copilot-setup-steps.yml => .github/workflows/copilot-setup-steps.yml (84%) create mode 100644 flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.rs create mode 100644 flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml diff --git a/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml similarity index 84% rename from copilot-setup-steps.yml rename to .github/workflows/copilot-setup-steps.yml index 1c6301165d..f8048f77c7 100644 --- a/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -12,7 +12,7 @@ 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 + 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 @@ -25,13 +25,15 @@ steps: - name: Install system dependencies run: | - # Update package lists - sudo apt-get update + # 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 install -y \ + sudo apt-get -o DPkg::Lock::Timeout=60 install -y \ binutils \ build-essential \ + gcc \ gcc-aarch64-linux-gnu \ libssl-dev \ pkg-config diff --git a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs index 4721e25b20..71f49b753c 100644 --- a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs +++ b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs @@ -9,68 +9,33 @@ 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 output_file = repo_root.join(".github/workflows/copilot-setup-steps.yml"); + + // 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 copilot-setup-steps.yml"); + println!("Generated .github/workflows/copilot-setup-steps.yml"); Ok(()) } } fn generate_copilot_setup_steps() -> String { - format!( - r#"############################## + let header = 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 + let template_content = crate::pipelines_shared::copilot_setup_steps_template::get_template(); - - 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 - ) + format!("{}{}", header, template_content) } diff --git a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.rs b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.rs new file mode 100644 index 0000000000..0c33b29257 --- /dev/null +++ b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.rs @@ -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, + ) +} diff --git a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml new file mode 100644 index 0000000000..d90fb988cc --- /dev/null +++ b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml @@ -0,0 +1,42 @@ +# 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={{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: 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 diff --git a/flowey/flowey_hvlite/src/pipelines_shared/mod.rs b/flowey/flowey_hvlite/src/pipelines_shared/mod.rs index 7cdfce2dfc..ea624f09dd 100644 --- a/flowey/flowey_hvlite/src/pipelines_shared/mod.rs +++ b/flowey/flowey_hvlite/src/pipelines_shared/mod.rs @@ -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; From 8fae20467a625df7e999b01407133bdcf1e8489a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 8 Jul 2025 22:49:21 +0000 Subject: [PATCH 08/10] Address PR feedback: move copyright header to template Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- flowey/flowey_cli/src/cli/regen.rs | 26 ------------------- .../src/pipelines/copilot_setup_generator.rs | 13 +--------- .../copilot_setup_steps_template.yml | 7 +++++ 3 files changed, 8 insertions(+), 38 deletions(-) diff --git a/flowey/flowey_cli/src/cli/regen.rs b/flowey/flowey_cli/src/cli/regen.rs index 82040de66a..6a396b5a56 100644 --- a/flowey/flowey_cli/src/cli/regen.rs +++ b/flowey/flowey_cli/src/cli/regen.rs @@ -100,17 +100,6 @@ 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 - ); - } - if error { anyhow::bail!("encountered one or more errors") } @@ -208,18 +197,3 @@ 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(()) -} diff --git a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs index 71f49b753c..d169802b9c 100644 --- a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs +++ b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs @@ -26,16 +26,5 @@ impl CopilotSetupGeneratorCli { } fn generate_copilot_setup_steps() -> String { - let header = r#"############################## -# THIS FILE IS AUTOGENERATED # -# DO NOT MANUALLY EDIT # -############################## -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. - -"#; - - let template_content = crate::pipelines_shared::copilot_setup_steps_template::get_template(); - - format!("{}{}", header, template_content) + crate::pipelines_shared::copilot_setup_steps_template::get_template() } diff --git a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml index d90fb988cc..510853c191 100644 --- a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml +++ b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml @@ -1,3 +1,10 @@ +############################## +# 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 From fedeea88c5968473761145d1d47cd9645edcb68a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 15 Jul 2025 21:15:02 +0000 Subject: [PATCH 09/10] Transform copilot-setup-steps.yml to proper GitHub Actions workflow format Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- .github/workflows/copilot-setup-steps.yml | 102 +++++++++++------- .../copilot_setup_steps_template.yml | 102 +++++++++++------- 2 files changed, 126 insertions(+), 78 deletions(-) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index f8048f77c7..298b966b92 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -8,42 +8,66 @@ # 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 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: 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 +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.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +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: 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 diff --git a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml index 510853c191..8953a91d37 100644 --- a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml +++ b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml @@ -8,42 +8,66 @@ # 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={{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: 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 +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.yml + pull_request: + paths: + - .github/workflows/copilot-setup-steps.yml + +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: 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 From 790779a1f7420513e3b54a6803a68716c41241af Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 18 Jul 2025 07:35:32 +0000 Subject: [PATCH 10/10] Add checkout step before restore-packages in copilot setup workflow Co-authored-by: mattkur <13772048+mattkur@users.noreply.github.com> --- .../{copilot-setup-steps.yml => copilot-setup-steps.yaml} | 7 +++++-- .../flowey_hvlite/src/pipelines/copilot_setup_generator.rs | 4 ++-- .../src/pipelines_shared/copilot_setup_steps_template.yml | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) rename .github/workflows/{copilot-setup-steps.yml => copilot-setup-steps.yaml} (94%) diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yaml similarity index 94% rename from .github/workflows/copilot-setup-steps.yml rename to .github/workflows/copilot-setup-steps.yaml index 298b966b92..662b6e613f 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yaml @@ -16,10 +16,10 @@ on: workflow_dispatch: push: paths: - - .github/workflows/copilot-setup-steps.yml + - .github/workflows/copilot-setup-steps.yaml pull_request: paths: - - .github/workflows/copilot-setup-steps.yml + - .github/workflows/copilot-setup-steps.yaml jobs: # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. @@ -62,6 +62,9 @@ jobs: libssl-dev \ pkg-config + - name: Checkout repository + uses: actions/checkout@v4 + - name: Restore OpenVMM build dependencies run: | # Restore external dependencies required for building OpenVMM diff --git a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs index d169802b9c..edd2bd081b 100644 --- a/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs +++ b/flowey/flowey_hvlite/src/pipelines/copilot_setup_generator.rs @@ -9,7 +9,7 @@ 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.yml"); + let output_file = repo_root.join(".github/workflows/copilot-setup-steps.yaml"); // Ensure the output directory exists if let Some(parent) = output_file.parent() { @@ -20,7 +20,7 @@ impl CopilotSetupGeneratorCli { std::fs::write(&output_file, content)?; - println!("Generated .github/workflows/copilot-setup-steps.yml"); + println!("Generated .github/workflows/copilot-setup-steps.yaml"); Ok(()) } } diff --git a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml index 8953a91d37..4663af0f8d 100644 --- a/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml +++ b/flowey/flowey_hvlite/src/pipelines_shared/copilot_setup_steps_template.yml @@ -16,10 +16,10 @@ on: workflow_dispatch: push: paths: - - .github/workflows/copilot-setup-steps.yml + - .github/workflows/copilot-setup-steps.yaml pull_request: paths: - - .github/workflows/copilot-setup-steps.yml + - .github/workflows/copilot-setup-steps.yaml jobs: # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot. @@ -62,6 +62,9 @@ jobs: libssl-dev \ pkg-config + - name: Checkout repository + uses: actions/checkout@v4 + - name: Restore OpenVMM build dependencies run: | # Restore external dependencies required for building OpenVMM