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 new file mode 100644 index 0000000..4120d63 --- /dev/null +++ b/Justfile @@ -0,0 +1,30 @@ +default: fmt test + +fmt: + cargo +nightly-2024-09-11 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/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" 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,