mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-12 00:26:29 +01:00
Add misc/scripts
Signed-off-by: Yuki Kishimoto <yukikishimoto@protonmail.com>
This commit is contained in:
11
justfile
11
justfile
@@ -9,6 +9,17 @@ alias t := test
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Execute a partial check (MSRV is not checked)
|
||||
precommit:
|
||||
@bash misc/scripts/precommit.sh
|
||||
|
||||
# Format the entire Rust code
|
||||
fmt:
|
||||
@bash misc/scripts/check-fmt.sh
|
||||
|
||||
# Check if the Rust code is formatted
|
||||
check-fmt:
|
||||
@bash misc/scripts/check-fmt.sh check
|
||||
|
||||
# run `cargo build` on everything
|
||||
build *ARGS="--workspace --all-targets":
|
||||
|
||||
46
misc/scripts/check-crates.sh
Executable file
46
misc/scripts/check-crates.sh
Executable file
@@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# MSRV
|
||||
msrv="1.70.0"
|
||||
|
||||
is_msrv=false
|
||||
version=""
|
||||
|
||||
# Check if "msrv" is passed as an argument
|
||||
if [[ "$#" -gt 0 && "$1" == "msrv" ]]; then
|
||||
is_msrv=true
|
||||
version="+$msrv"
|
||||
fi
|
||||
|
||||
# Check if MSRV
|
||||
if [ "$is_msrv" == true ]; then
|
||||
# Install MSRV
|
||||
rustup install $msrv
|
||||
rustup component add clippy --toolchain $msrv
|
||||
rustup target add wasm32-unknown-unknown --toolchain $msrv
|
||||
fi
|
||||
|
||||
buildargs=(
|
||||
"-p cashu"
|
||||
"-p cashu --no-default-features"
|
||||
"-p cashu --no-default-features --features wallet"
|
||||
"-p cashu --no-default-features --features mint"
|
||||
"-p cashu-sdk"
|
||||
"-p cashu-sdk --no-default-features"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
if [[ $version == "" ]]; then
|
||||
echo "Checking '$arg' [default]"
|
||||
else
|
||||
echo "Checking '$arg' [$version]"
|
||||
fi
|
||||
cargo $version check $arg
|
||||
if [[ $arg != *"--target wasm32-unknown-unknown"* ]]; then
|
||||
cargo $version test $arg
|
||||
fi
|
||||
cargo $version clippy $arg -- -D warnings
|
||||
echo
|
||||
done
|
||||
14
misc/scripts/check-docs.sh
Executable file
14
misc/scripts/check-docs.sh
Executable file
@@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
buildargs=(
|
||||
"-p cashu"
|
||||
"-p cashu-sdk"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
echo "Checking '$arg' docs"
|
||||
cargo doc $arg --all-features
|
||||
echo
|
||||
done
|
||||
17
misc/scripts/check-fmt.sh
Executable file
17
misc/scripts/check-fmt.sh
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
flags=""
|
||||
|
||||
# Check if "check" is passed as an argument
|
||||
if [[ "$#" -gt 0 && "$1" == "check" ]]; then
|
||||
flags="--check"
|
||||
fi
|
||||
|
||||
# Install toolchain
|
||||
rustup install nightly-2024-01-11
|
||||
rustup component add rustfmt --toolchain nightly-2024-01-11
|
||||
|
||||
# Check workspace crates
|
||||
cargo +nightly-2024-01-11 fmt --all -- --config format_code_in_doc_comments=true $flags
|
||||
11
misc/scripts/check.sh
Executable file
11
misc/scripts/check.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
"${DIR}/check-fmt.sh" check # Check if Rust code is formatted
|
||||
"${DIR}/check-crates.sh" # Check all crates
|
||||
"${DIR}/check-crates.sh" msrv # Check all crates MSRV
|
||||
#"${DIR}/check-bindings.sh" # Check all bindings
|
||||
"${DIR}/check-docs.sh" # Check Rust docs
|
||||
10
misc/scripts/precommit.sh
Executable file
10
misc/scripts/precommit.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
"${DIR}/check-fmt.sh" # Format the code
|
||||
"${DIR}/check-crates.sh" # Check all crates
|
||||
#"${DIR}/check-bindings.sh" # Check all bindings
|
||||
"${DIR}/check-docs.sh" # Check Rust docs
|
||||
Reference in New Issue
Block a user