add check for manual migration sync that will fail on cargo build in CI

This commit is contained in:
Mark Sinclair
2025-11-12 15:18:37 +00:00
parent c2e82a0ebf
commit 67b69f655f
4 changed files with 55 additions and 1 deletions
Generated
+1
View File
@@ -5717,6 +5717,7 @@ dependencies = [
"chrono",
"clap",
"cosmrs",
"glob",
"nym-bin-common",
"nym-config",
"nym-network-defaults",
+1
View File
@@ -266,6 +266,7 @@ futures = "0.3.31"
futures-util = "0.3"
generic-array = "0.14.7"
getrandom = "0.2.10"
glob = "0.3"
handlebars = "3.5.5"
hex = "0.4.3"
hickory-resolver = "0.25"
+1
View File
@@ -46,5 +46,6 @@ utoipauto = { workspace = true }
[build-dependencies]
anyhow = { workspace = true }
glob = { workspace = true }
tokio = { workspace = true, features = ["macros", "rt-multi-thread"] }
sqlx = { workspace = true, features = ["runtime-tokio-rustls", "postgres"] }
+52 -1
View File
@@ -1,8 +1,59 @@
// Copyright 2025 - Nym Technologies SA <contact@nymtech.net>
// SPDX-License-Identifier: Apache-2.0
use glob::glob;
use std::env;
use std::path::Path;
fn main() {
fn main() -> anyhow::Result<()> {
// check if migrations in "../common/nyxd-scraper-psql/sql_migrations/* are in "nym-data-observatory/migrations"
println!("Checking common migrations...");
let manifest_dir_string = env::var("CARGO_MANIFEST_DIR").unwrap();
let common_migrations_path = Path::new(&manifest_dir_string)
.join("../common/nyxd-scraper-psql/sql_migrations/")
.canonicalize()?;
let output_path = Path::new(&manifest_dir_string)
.join("migrations")
.canonicalize()?;
println!(
"output_path: {:?} (exists = {})",
output_path,
output_path.exists()
);
let common_migrations_path = common_migrations_path.as_path();
println!(
"common_migrations_path: {:?} (exists = {})",
common_migrations_path,
common_migrations_path.exists()
);
for file in glob(&format!("{}/*", common_migrations_path.to_str().unwrap()))
.unwrap()
.flatten()
{
println!("- checking if {file:?} exists in nym-data-observatory/migrations directory...");
let filename = file
.as_path()
.file_name()
.expect("migration filename is found");
let filename = output_path.join(filename);
println!(
"- {} {file:?} => {filename:?} (exists = {})",
if filename.exists() { "" } else { "" },
filename.exists()
);
if !filename.exists() {
anyhow::bail!(
"migration {file:?} does not exist in nym-data-observatory/migrations directory, please check and copy it"
);
}
}
// sqlx
if let Ok(database_url) = std::env::var("DATABASE_URL") {
println!("cargo:rustc-env=DATABASE_URL={database_url}");
}
println!("✅ done");
Ok(())
}