-
Notifications
You must be signed in to change notification settings - Fork 87
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Martin Kröning <[email protected]>
- Loading branch information
Showing
13 changed files
with
966 additions
and
205 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
use std::path::PathBuf; | ||
|
||
use anyhow::Result; | ||
use clap::Args; | ||
use xshell::cmd; | ||
|
||
use crate::cargo_build::{CargoBuild, CmdExt}; | ||
|
||
/// Build hermit-rs images. | ||
#[derive(Args)] | ||
#[command(next_help_heading = "Build options")] | ||
pub struct Build { | ||
#[command(flatten)] | ||
pub cargo_build: CargoBuild, | ||
|
||
/// Package to build (see `cargo help pkgid`) | ||
#[arg(short, long, id = "SPEC")] | ||
pub package: String, | ||
} | ||
|
||
impl Build { | ||
pub fn run(&self) -> Result<()> { | ||
if super::in_ci() { | ||
eprintln!("::group::cargo build") | ||
} | ||
|
||
let sh = crate::sh()?; | ||
|
||
cmd!(sh, "cargo build --manifest-path ../Cargo.toml") | ||
.args(self.cargo_build.artifact.arch.ci_cargo_args()) | ||
.cargo_build_args(&self.cargo_build) | ||
.args(&["--package", self.package.as_str()]) | ||
.run()?; | ||
|
||
if super::in_ci() { | ||
eprintln!("::endgroup::") | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
pub fn image(&self) -> PathBuf { | ||
self.cargo_build.artifact.ci_image(&self.package) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use std::path::Path; | ||
|
||
use anyhow::Result; | ||
use clap::Args; | ||
use xshell::cmd; | ||
|
||
use super::build::Build; | ||
|
||
/// Run hermit-rs images on Firecracker. | ||
#[derive(Args)] | ||
pub struct Firecracker { | ||
#[command(flatten)] | ||
build: Build, | ||
} | ||
|
||
impl Firecracker { | ||
pub fn run(self) -> Result<()> { | ||
self.build.run()?; | ||
|
||
let sh = crate::sh()?; | ||
|
||
let config = format!( | ||
include_str!("firecracker_vm_config.json"), | ||
kernel_image_path = "../rusty-loader-x86_64-fc", | ||
initrd_path = self.build.image().display() | ||
); | ||
eprintln!("firecracker config"); | ||
eprintln!("{config}"); | ||
let config_path = Path::new("firecracker_vm_config.json"); | ||
sh.write_file(config_path, config)?; | ||
|
||
let log_path = Path::new("firecracker.log"); | ||
sh.write_file(log_path, "")?; | ||
cmd!(sh, "firecracker --no-api --config-file {config_path} --log-path {log_path} --level Info --show-level --show-log-origin").run()?; | ||
let log = sh.read_file(log_path)?; | ||
|
||
eprintln!("firecracker log"); | ||
eprintln!("{log}"); | ||
|
||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{{ | ||
"boot-source": {{ | ||
"kernel_image_path": "{kernel_image_path}", | ||
"initrd_path": "{initrd_path}", | ||
"boot_args": "" | ||
}}, | ||
"drives": [], | ||
"machine-config": {{ | ||
"vcpu_count": 1, | ||
"mem_size_mib": 256, | ||
"smt": false | ||
}} | ||
}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use anyhow::Result; | ||
use clap::Subcommand; | ||
|
||
mod build; | ||
mod firecracker; | ||
mod qemu; | ||
mod uhyve; | ||
|
||
/// Run CI tasks. | ||
#[derive(Subcommand)] | ||
pub enum Ci { | ||
Build(build::Build), | ||
Firecracker(firecracker::Firecracker), | ||
Qemu(qemu::Qemu), | ||
Uhyve(uhyve::Uhyve), | ||
} | ||
|
||
impl Ci { | ||
pub fn run(self) -> Result<()> { | ||
match self { | ||
Self::Build(build) => build.run(), | ||
Self::Firecracker(firecracker) => firecracker.run(), | ||
Self::Qemu(qemu) => qemu.run(), | ||
Self::Uhyve(uhyve) => uhyve.run(), | ||
} | ||
} | ||
} | ||
|
||
fn in_ci() -> bool { | ||
std::env::var_os("CI") == Some("true".into()) | ||
} |
Oops, something went wrong.