Skip to content
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

feat(xtask): make microvm config implicit #405

Merged
merged 2 commits into from
Nov 16, 2024
Merged
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ jobs:
if: matrix.target == 'x86_64'
- name: Run VM (hello_world-microvm, dev)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_world-microvm --microvm
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm
- name: Run VM (hello_world-microvm, release)
if: matrix.target == 'x86_64' && matrix.os == 'ubuntu-latest'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_world-microvm --microvm --release
run: cargo xtask ci qemu --target ${{ matrix.target }} --microvm --release
- name: Run VM (hello_c, dev)
if: matrix.target == 'x86_64'
run: cargo xtask ci qemu --target ${{ matrix.target }} --image hello_c
Expand Down Expand Up @@ -142,14 +142,14 @@ jobs:
- name: Run QEMU (hello_world, release)
run: cargo xtask ci qemu --target x86_64 --accel --release
- name: Run QEMU (hello_world-microvm, dev)
run: cargo xtask ci qemu --target x86_64 --accel --image hello_world-microvm --microvm
run: cargo xtask ci qemu --target x86_64 --accel --microvm
- name: Run QEMU (hello_world-microvm, release)
run: cargo xtask ci qemu --target x86_64 --accel --image hello_world-microvm --microvm --release
run: cargo xtask ci qemu --target x86_64 --accel --microvm --release
- name: Run UEFI (dev)
run: cargo xtask ci qemu --target x86_64-uefi --accel
- name: Run UEFI (release)
run: cargo xtask ci qemu --target x86_64-uefi --accel --release
- name: Run Firecracker (hello_world, dev)
run: cargo xtask ci firecracker --target x86_64-fc --features fc --image hello_world-microvm
run: cargo xtask ci firecracker --target x86_64-fc
- name: Run Firecracker (hello_world, release)
run: cargo xtask ci firecracker --target x86_64-fc --features fc --image hello_world-microvm --release
run: cargo xtask ci firecracker --target x86_64-fc --release
2 changes: 1 addition & 1 deletion xtask/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::target::Target;
#[derive(Args)]
pub struct Build {
#[command(flatten)]
cargo_build: CargoBuild,
pub cargo_build: CargoBuild,
}

impl Build {
Expand Down
6 changes: 4 additions & 2 deletions xtask/src/ci/firecracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ pub struct Firecracker {
#[command(flatten)]
build: Build,

#[arg(long, default_value_t = String::from("hello_world"))]
#[arg(long, default_value_t = String::from("hello_world-microvm"))]
image: String,
}

impl Firecracker {
pub fn run(self) -> Result<()> {
pub fn run(mut self) -> Result<()> {
self.build.cargo_build.features.push("fc".to_string());

self.build.run()?;

let sh = crate::sh()?;
Expand Down
24 changes: 17 additions & 7 deletions xtask/src/ci/qemu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,20 @@ pub struct Qemu {
#[command(flatten)]
build: Build,

#[arg(long, default_value_t = String::from("hello_world"))]
image: String,
#[arg(long)]
image: Option<String>,
}

impl Qemu {
pub fn run(self) -> Result<()> {
pub fn run(mut self) -> Result<()> {
let default_image = if self.microvm {
"hello_world-microvm"
} else {
"hello_world"
};

self.image.get_or_insert_with(|| default_image.to_string());

if super::in_ci() {
eprintln!("::group::cargo build")
}
Expand All @@ -45,7 +53,7 @@ impl Qemu {
sh.create_dir("target/esp/efi/boot")?;
sh.copy_file(self.build.dist_object(), "target/esp/efi/boot/bootx64.efi")?;
sh.copy_file(
self.build.ci_image(&self.image),
self.build.ci_image(self.image.as_deref().unwrap()),
"target/esp/efi/boot/hermit-app",
)?;
}
Expand Down Expand Up @@ -128,7 +136,7 @@ impl Qemu {
cpu_args.push("-initrd".to_string());
cpu_args.push(
self.build
.ci_image(&self.image)
.ci_image(self.image.as_deref().unwrap())
.into_os_string()
.into_string()
.unwrap(),
Expand Down Expand Up @@ -168,7 +176,9 @@ impl Qemu {
cpu_args.push("-device".to_string());
cpu_args.push(format!(
"guest-loader,addr=0x48000000,initrd={}",
self.build.ci_image(&self.image).display()
self.build
.ci_image(self.image.as_deref().unwrap())
.display()
));
cpu_args
}
Expand All @@ -190,7 +200,7 @@ impl Qemu {
cpu_args.push("-initrd".to_string());
cpu_args.push(
self.build
.ci_image(&self.image)
.ci_image(self.image.as_deref().unwrap())
.into_os_string()
.into_string()
.unwrap(),
Expand Down
Loading