mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 00:06:34 +00:00
Fix OSDK CI bugs & Build OSDK with stable channel in CI
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
69abc09f5a
commit
32b1fb3723
4
.github/workflows/osdk_test.yml
vendored
4
.github/workflows/osdk_test.yml
vendored
@ -30,7 +30,7 @@ jobs:
|
|||||||
# of actions/checkout@v4
|
# of actions/checkout@v4
|
||||||
- name: Unit test
|
- name: Unit test
|
||||||
id: unit_test
|
id: unit_test
|
||||||
run: cd osdk && cargo build && RUSTUP_HOME=/root/.rustup cargo test
|
run: cd osdk && RUSTUP_HOME=/root/.rustup cargo +stable build && RUSTUP_HOME=/root/.rustup cargo test
|
||||||
|
|
||||||
# Test OSDK in the same environment
|
# Test OSDK in the same environment
|
||||||
# as described in the OSDK User Guide in the Asterinas Book.
|
# as described in the OSDK User Guide in the Asterinas Book.
|
||||||
@ -50,5 +50,5 @@ jobs:
|
|||||||
# So the RUSTUP_HOME needs to be set here.
|
# So the RUSTUP_HOME needs to be set here.
|
||||||
# This only breaks when we invoke Cargo in the integration test of OSDK
|
# This only breaks when we invoke Cargo in the integration test of OSDK
|
||||||
# since the OSDK toolchain is not nightly.
|
# since the OSDK toolchain is not nightly.
|
||||||
run: cd osdk && cargo build && RUSTUP_HOME=/root/.rustup cargo test
|
run: cd osdk && RUSTUP_HOME=/root/.rustup cargo +stable build && RUSTUP_HOME=/root/.rustup cargo test
|
||||||
|
|
||||||
|
@ -1,2 +0,0 @@
|
|||||||
[toolchain]
|
|
||||||
channel = "stable"
|
|
@ -1,4 +1,4 @@
|
|||||||
project_type = "lib"
|
project_type = "library"
|
||||||
|
|
||||||
[boot]
|
[boot]
|
||||||
method = "qemu-direct"
|
method = "qemu-direct"
|
||||||
|
@ -7,7 +7,9 @@ use crate::{
|
|||||||
base_crate::new_base_crate,
|
base_crate::new_base_crate,
|
||||||
cli::TestArgs,
|
cli::TestArgs,
|
||||||
config::{scheme::ActionChoice, Config},
|
config::{scheme::ActionChoice, Config},
|
||||||
util::{get_cargo_metadata, get_current_crate_info, get_target_directory},
|
util::{
|
||||||
|
get_cargo_metadata, get_current_crate_info, get_target_directory, parse_package_id_string,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn execute_test_command(config: &Config, args: &TestArgs) {
|
pub fn execute_test_command(config: &Config, args: &TestArgs) {
|
||||||
@ -81,12 +83,9 @@ fn get_workspace_default_members() -> Vec<String> {
|
|||||||
default_members
|
default_members
|
||||||
.iter()
|
.iter()
|
||||||
.map(|value| {
|
.map(|value| {
|
||||||
// The default member is in the form of "<crate_name> <crate_version> (path+file://<crate_path>)"
|
|
||||||
let default_member = value.as_str().unwrap();
|
let default_member = value.as_str().unwrap();
|
||||||
let path = default_member.split(' ').nth(2).unwrap();
|
let crate_info = parse_package_id_string(default_member);
|
||||||
path.trim_start_matches("(path+file://")
|
crate_info.path
|
||||||
.trim_end_matches(')')
|
|
||||||
.to_string()
|
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -163,25 +163,29 @@ pub fn get_current_crate_info() -> CrateInfo {
|
|||||||
let metadata = get_cargo_metadata(None::<&str>, None::<&[&str]>).unwrap();
|
let metadata = get_cargo_metadata(None::<&str>, None::<&[&str]>).unwrap();
|
||||||
|
|
||||||
let default_member = get_default_member(&metadata);
|
let default_member = get_default_member(&metadata);
|
||||||
// Prior 202403 (Rust 1.77.1), the default member string here is in the form of
|
parse_package_id_string(default_member)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn parse_package_id_string(package_id: &str) -> CrateInfo {
|
||||||
|
// Prior to 202403 (Rust 1.77.1), the package id string here is in the form of
|
||||||
// "<crate_name> <crate_version> (path+file://<crate_path>)".
|
// "<crate_name> <crate_version> (path+file://<crate_path>)".
|
||||||
// After that, it's
|
// After that, it's
|
||||||
// "path+file://<crate_path>#<crate_name>@<crate_version>", in which the crate
|
// "path+file://<crate_path>#<crate_name>@<crate_version>", in which the crate
|
||||||
// name might not exist if it is the last component of the path.
|
// name might not exist if it is the last component of the path.
|
||||||
if default_member.starts_with("path+file://") {
|
if package_id.starts_with("path+file://") {
|
||||||
// After 1.77.1
|
// After 1.77.1
|
||||||
if default_member.contains('@') {
|
if package_id.contains('@') {
|
||||||
let default_member = default_member.split(['#', '@']).collect::<Vec<&str>>();
|
let package_id_segments = package_id.split(['#', '@']).collect::<Vec<&str>>();
|
||||||
CrateInfo {
|
CrateInfo {
|
||||||
name: default_member[1].to_string(),
|
name: package_id_segments[1].to_string(),
|
||||||
version: default_member[2].to_string(),
|
version: package_id_segments[2].to_string(),
|
||||||
path: default_member[0]
|
path: package_id_segments[0]
|
||||||
.trim_start_matches("path+file://")
|
.trim_start_matches("path+file://")
|
||||||
.to_string(),
|
.to_string(),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let default_member = default_member.split(['#']).collect::<Vec<&str>>();
|
let package_id_segments = package_id.split(['#']).collect::<Vec<&str>>();
|
||||||
let path = default_member[0]
|
let path = package_id_segments[0]
|
||||||
.trim_start_matches("path+file://")
|
.trim_start_matches("path+file://")
|
||||||
.to_string();
|
.to_string();
|
||||||
CrateInfo {
|
CrateInfo {
|
||||||
@ -191,13 +195,13 @@ pub fn get_current_crate_info() -> CrateInfo {
|
|||||||
.to_str()
|
.to_str()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.to_string(),
|
.to_string(),
|
||||||
version: default_member[1].to_string(),
|
version: package_id_segments[1].to_string(),
|
||||||
path,
|
path,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Before 1.77.1
|
// Before 1.77.1
|
||||||
let default_member = default_member.split(' ').collect::<Vec<&str>>();
|
let default_member = package_id.split(' ').collect::<Vec<&str>>();
|
||||||
CrateInfo {
|
CrateInfo {
|
||||||
name: default_member[0].to_string(),
|
name: default_member[0].to_string(),
|
||||||
version: default_member[1].to_string(),
|
version: default_member[1].to_string(),
|
||||||
|
@ -50,7 +50,7 @@ fn create_and_test_library() {
|
|||||||
|
|
||||||
let mut command = cargo_osdk(&["test"]);
|
let mut command = cargo_osdk(&["test"]);
|
||||||
command.current_dir(&module_dir);
|
command.current_dir(&module_dir);
|
||||||
command.output().unwrap();
|
command.ok().unwrap();
|
||||||
|
|
||||||
fs::remove_dir_all(&module_dir).unwrap();
|
fs::remove_dir_all(&module_dir).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ fn work_in_workspace() {
|
|||||||
assert!(stdout.contains("The available memory is"));
|
assert!(stdout.contains("The available memory is"));
|
||||||
|
|
||||||
// Run subcommand test
|
// Run subcommand test
|
||||||
cargo_osdk(&["test"]).output().unwrap();
|
cargo_osdk(&["test"]).ok().unwrap();
|
||||||
|
|
||||||
// Remove the directory
|
// Remove the directory
|
||||||
fs::remove_dir_all(&workspace_dir).unwrap();
|
fs::remove_dir_all(&workspace_dir).unwrap();
|
||||||
|
Reference in New Issue
Block a user