Fixes to name handling

This commit is contained in:
Luke Parker 2023-11-27 02:00:16 -05:00
parent 292263b21e
commit 9da1d714b3
No known key found for this signature in database
2 changed files with 22 additions and 16 deletions

View file

@ -16,4 +16,4 @@ rustdoc-args = ["--cfg", "docsrs"]
[dependencies] [dependencies]
chrono = "0.4" chrono = "0.4"
tokio = { version = "1", default-features = false, features = ["sync", "rt"] } tokio = { version = "1", default-features = false, features = ["sync"] }

View file

@ -38,13 +38,15 @@ pub async fn build(name: String) {
let mut orchestration_path = repo_path.clone(); let mut orchestration_path = repo_path.clone();
orchestration_path.push("orchestration"); orchestration_path.push("orchestration");
let name_without_serai_dev = name.split("serai-dev-").nth(1).unwrap_or(&name);
// If this Docker image was created after this repo was last edited, return here // If this Docker image was created after this repo was last edited, return here
// This should have better performance than Docker and allows running while offline // This should have better performance than Docker and allows running while offline
if let Ok(res) = Command::new("docker") if let Ok(res) = Command::new("docker")
.arg("inspect") .arg("inspect")
.arg("-f") .arg("-f")
.arg("{{ .Metadata.LastTagTime }}") .arg("{{ .Metadata.LastTagTime }}")
.arg(format!("serai-dev-{name}")) .arg(name.clone())
.output() .output()
.await .await
{ {
@ -60,16 +62,19 @@ pub async fn build(name: String) {
); );
let mut dockerfile_path = orchestration_path.clone(); let mut dockerfile_path = orchestration_path.clone();
if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(name.as_str()) { {
dockerfile_path = dockerfile_path.join("coins"); let name = name_without_serai_dev;
} if HashSet::from(["bitcoin", "ethereum", "monero"]).contains(&name) {
if name.contains("-processor") { dockerfile_path = dockerfile_path.join("coins");
dockerfile_path = dockerfile_path }
.join("processor") if name.contains("-processor") {
.join(name.split('-').next().unwrap()) dockerfile_path = dockerfile_path
.join("Dockerfile"); .join("processor")
} else { .join(name.split('-').next().unwrap())
dockerfile_path = dockerfile_path.join(&name).join("Dockerfile"); .join("Dockerfile");
} else {
dockerfile_path = dockerfile_path.join(name).join("Dockerfile");
}
} }
// For all services, if the Dockerfile was edited after the image was built we should rebuild // For all services, if the Dockerfile was edited after the image was built we should rebuild
@ -78,7 +83,7 @@ pub async fn build(name: String) {
// Check any additionally specified paths // Check any additionally specified paths
let meta = |path: PathBuf| (path.clone(), fs::metadata(path)); let meta = |path: PathBuf| (path.clone(), fs::metadata(path));
let mut metadatas = match name.as_str() { let mut metadatas = match name_without_serai_dev {
"bitcoin" => vec![], "bitcoin" => vec![],
"monero" => vec![], "monero" => vec![],
"message-queue" => vec![ "message-queue" => vec![
@ -152,6 +157,7 @@ pub async fn build(name: String) {
println!("Building {}...", &name); println!("Building {}...", &name);
// Version which always prints // Version which always prints
/*
if !Command::new("docker") if !Command::new("docker")
.current_dir(orchestration_path) .current_dir(orchestration_path)
.arg("compose") .arg("compose")
@ -166,15 +172,16 @@ pub async fn build(name: String) {
{ {
panic!("failed to build {name}"); panic!("failed to build {name}");
} }
*/
// Version which only prints on error // Version which only prints on error
/*
let res = Command::new("docker") let res = Command::new("docker")
.current_dir(orchestration_path) .current_dir(orchestration_path)
.arg("compose") .arg("compose")
.arg("build") .arg("build")
.arg(&name) .arg(name_without_serai_dev)
.output() .output()
.await
.unwrap(); .unwrap();
if !res.status.success() { if !res.status.success() {
println!("failed to build {name}\n"); println!("failed to build {name}\n");
@ -192,7 +199,6 @@ pub async fn build(name: String) {
); );
panic!("failed to build {name}"); panic!("failed to build {name}");
} }
*/
println!("Built!"); println!("Built!");