From 28a4d82f52c4f942da4294a17aae7c768a8dc2f0 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 24 Feb 2025 16:15:13 +0100 Subject: [PATCH 1/4] Update Rust to 1.84.1 Signed-off-by: Oliver Tale-Yazdi --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 614318d..5506e54 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.80.0" +channel = "1.84.1" components = [ "rustfmt", "clippy" ] profile = "minimal" From 8de8e2925f6c639331c771255873a69bbbb15a3c Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 24 Feb 2025 16:30:48 +0100 Subject: [PATCH 2/4] fixes Signed-off-by: Oliver Tale-Yazdi --- Justfile | 30 ++++++++++++++++++++++++++++++ Makefile | 20 -------------------- web/src/main.rs | 16 ++++++++++++++++ 3 files changed, 46 insertions(+), 20 deletions(-) create mode 100644 Justfile delete mode 100644 Makefile diff --git a/Justfile b/Justfile new file mode 100644 index 0000000..93481ea --- /dev/null +++ b/Justfile @@ -0,0 +1,30 @@ +default: fmt test + +fmt: + cargo fmt --all + +test: + cargo test --release --all-targets --all-features + +dev: + cargo r --release --bin subweight-web -- --endpoint 127.0.0.1 --repos polkadot-sdk --root repos --port 4000 + +publish: + #!/usr/bin/env bash + echo "Checking if crate can be published..." + + VERSION=$(shell grep -E '^version = "[0-9.]+"' Cargo.toml | cut -d'"' -f2) + TAG=v$(VERSION) + echo "Publishing version '$(VERSION)' with tag '$(TAG)'" + echo "- Publishing crate to crates.io..." + echo " - Publishing core..." + cargo publish -p subweight-core --allow-dirty -q + echo " - Publishing cli..." + cargo publish -p subweight --allow-dirty -q + echo " - Publishing web..." + cargo publish -p subweight-web --allow-dirty -q + echo "- Please sign the tag..." + git tag -s -a $(TAG) -m "Version $(VERSION)" + echo "- Pushing tag to GitHub..." + git push -f origin $(TAG) + echo "Done!" diff --git a/Makefile b/Makefile deleted file mode 100644 index 3cea13a..0000000 --- a/Makefile +++ /dev/null @@ -1,20 +0,0 @@ -.PHONY: publish - -publish: - @echo "Checking if crate can be published..." - - $(eval VERSION := $(shell grep -E '^version = "[0-9.]+"' Cargo.toml | cut -d'"' -f2)) - $(eval TAG := v$(VERSION)) - @echo "Publishing version '$(VERSION)' with tag '$(TAG)'" - @echo "- Publishing crate to crates.io..." - @echo " - Publishing core..." - @cargo publish -p subweight-core --allow-dirty -q - @echo " - Publishing cli..." - @cargo publish -p subweight --allow-dirty -q - @echo " - Publishing web..." - @cargo publish -p subweight-web --allow-dirty -q - @echo "- Please sign the tag..." - git tag -s -a $(TAG) -m "Version $(VERSION)" - @echo "- Pushing tag to GitHub..." - git push -f origin $(TAG) - @echo "Done!" diff --git a/web/src/main.rs b/web/src/main.rs index 28b9420..51575eb 100644 --- a/web/src/main.rs +++ b/web/src/main.rs @@ -107,9 +107,25 @@ async fn main() -> std::io::Result<()> { "Need at least one value to --repos", )) } + + if !cmd.root_path.exists() { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("Root path '{}' does not exist", cmd.root_path.display()), + )) + } + for repo_name in cmd.repos { // TODO check that the folder exists let path = cmd.root_path.join(&repo_name); + + if !path.exists() { + return Err(std::io::Error::new( + std::io::ErrorKind::Other, + format!("Repo directory '{}' does not exist", path.display()), + )) + } + let organization = git::get_origin_org(&path).map_err(|e| { std::io::Error::new( std::io::ErrorKind::Other, From e3b3aa97d24f2d163f1ed803f6e8b278865d0f73 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 24 Feb 2025 16:39:08 +0100 Subject: [PATCH 3/4] fix Signed-off-by: Oliver Tale-Yazdi --- Cargo.lock | 8 ++++---- Cargo.toml | 4 ++-- Justfile | 2 +- cli/src/main.rs | 4 ++-- rust-toolchain.toml | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 7ddeec5..3cd4bf5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "actix-codec" @@ -2212,7 +2212,7 @@ dependencies = [ [[package]] name = "subweight" -version = "3.4.3" +version = "3.4.4" dependencies = [ "assert_cmd", "clap", @@ -2228,7 +2228,7 @@ dependencies = [ [[package]] name = "subweight-core" -version = "3.4.3" +version = "3.4.4" dependencies = [ "clap", "criterion", @@ -2250,7 +2250,7 @@ dependencies = [ [[package]] name = "subweight-web" -version = "3.4.3" +version = "3.4.4" dependencies = [ "actix-files", "actix-web", diff --git a/Cargo.toml b/Cargo.toml index 3673f03..cc614d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [workspace.package] edition = "2021" authors = ["Oliver Tale-Yazdi "] -version = "3.4.3" +version = "3.4.4" repository = "https://github.com/ggwpez/substrate-weight-compare" readme = "README.md" keywords = [ "polkadot", "substrate", "blockchain" ] @@ -18,7 +18,7 @@ members = [ resolver = "2" [workspace.dependencies] -subweight-core = { version = "3.4.3", path = "core" } +subweight-core = { version = "3.4.4", path = "core" } clap = { version = "4.5.16", features = ["derive"] } env_logger = "0.11.5" diff --git a/Justfile b/Justfile index 93481ea..4120d63 100644 --- a/Justfile +++ b/Justfile @@ -1,7 +1,7 @@ default: fmt test fmt: - cargo fmt --all + cargo +nightly-2024-09-11 fmt --all test: cargo test --release --all-targets --all-features diff --git a/cli/src/main.rs b/cli/src/main.rs index 290f3e4..4312425 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -256,7 +256,7 @@ fn print_changes_csv( ) -> Result> { if per_extrinsic.is_empty() { print("No changes found.".into(), verbose); - return Ok(String::new()) + return Ok(String::new()); } let mut output = String::new(); @@ -306,7 +306,7 @@ fn print_changes_human( ) -> Result> { if per_extrinsic.is_empty() { print("No changes found.".into(), verbose); - return Ok(String::new()) + return Ok(String::new()); } let mut table = Table::new(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 5506e54..838ca3a 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.84.1" +channel = "+nightly-2024-09-11" components = [ "rustfmt", "clippy" ] profile = "minimal" From 29541350b599d079de37f2aa98e283ea27a751e2 Mon Sep 17 00:00:00 2001 From: Oliver Tale-Yazdi Date: Mon, 24 Feb 2025 16:39:59 +0100 Subject: [PATCH 4/4] fmt Signed-off-by: Oliver Tale-Yazdi --- cli/src/main.rs | 4 ++-- rust-toolchain.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/src/main.rs b/cli/src/main.rs index 4312425..290f3e4 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -256,7 +256,7 @@ fn print_changes_csv( ) -> Result> { if per_extrinsic.is_empty() { print("No changes found.".into(), verbose); - return Ok(String::new()); + return Ok(String::new()) } let mut output = String::new(); @@ -306,7 +306,7 @@ fn print_changes_human( ) -> Result> { if per_extrinsic.is_empty() { print("No changes found.".into(), verbose); - return Ok(String::new()); + return Ok(String::new()) } let mut table = Table::new(); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 838ca3a..5506e54 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "+nightly-2024-09-11" +channel = "1.84.1" components = [ "rustfmt", "clippy" ] profile = "minimal"