mirror of
https://github.com/aljazceru/cdk.git
synced 2026-02-02 19:55:56 +01:00
refactor: check scripts for justfile
chore: ci run examples
This commit is contained in:
31
.github/workflows/ci.yml
vendored
31
.github/workflows/ci.yml
vendored
@@ -39,7 +39,6 @@ jobs:
|
||||
-p cdk-integration-tests,
|
||||
--bin cdk-cli,
|
||||
--bin cdk-mintd,
|
||||
--examples
|
||||
]
|
||||
steps:
|
||||
- name: Checkout
|
||||
@@ -96,3 +95,33 @@ jobs:
|
||||
run: cargo build ${{ matrix.build-args }} --target wasm32-unknown-unknown
|
||||
- name: Clippy
|
||||
run: cargo clippy ${{ matrix.build-args }} --target wasm32-unknown-unknown -- -D warnings
|
||||
|
||||
run-examples:
|
||||
name: Run Examples
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
rust:
|
||||
- version: stable
|
||||
build-args:
|
||||
[
|
||||
mint-token,
|
||||
p2pk,
|
||||
proof-selection,
|
||||
wallet
|
||||
]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
- name: Cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-wasm32-${{ hashFiles('**/Cargo.toml','**/Cargo.lock') }}
|
||||
- name: Set default toolchain
|
||||
run: rustup default ${{ matrix.rust.version }}
|
||||
- name: Run
|
||||
run: cargo run --example ${{ matrix.build-args }}
|
||||
|
||||
@@ -26,7 +26,7 @@ pub async fn test_mint_double_receive() -> Result<()> {
|
||||
let mnemonic = Mnemonic::generate(12)?;
|
||||
|
||||
let wallet = Wallet::new(
|
||||
&MINT_URL,
|
||||
MINT_URL,
|
||||
CurrencyUnit::Sat,
|
||||
Arc::new(WalletMemoryDatabase::default()),
|
||||
&mnemonic.to_seed_normalized(""),
|
||||
@@ -51,7 +51,7 @@ pub async fn test_mint_double_receive() -> Result<()> {
|
||||
let mnemonic = Mnemonic::generate(12)?;
|
||||
|
||||
let wallet_two = Wallet::new(
|
||||
&MINT_URL,
|
||||
MINT_URL,
|
||||
CurrencyUnit::Sat,
|
||||
Arc::new(WalletMemoryDatabase::default()),
|
||||
&mnemonic.to_seed_normalized(""),
|
||||
|
||||
@@ -22,7 +22,7 @@ pub async fn test_p2pk_swap() -> Result<()> {
|
||||
let mnemonic = Mnemonic::generate(12)?;
|
||||
|
||||
let wallet = Wallet::new(
|
||||
&MINT_URL,
|
||||
MINT_URL,
|
||||
CurrencyUnit::Sat,
|
||||
Arc::new(WalletMemoryDatabase::default()),
|
||||
&mnemonic.to_seed_normalized(""),
|
||||
|
||||
@@ -70,7 +70,7 @@ name = "wallet"
|
||||
required-features = ["wallet"]
|
||||
|
||||
[[example]]
|
||||
name = "proof_selection"
|
||||
name = "proof-selection"
|
||||
required-features = ["wallet"]
|
||||
|
||||
[dev-dependencies]
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
name = "cdk";
|
||||
path = ./.;
|
||||
};
|
||||
paths = [ "crates/cashu" "crates/cashu-sdk" ];
|
||||
paths = [ "crates/*" ];
|
||||
};
|
||||
|
||||
targetsStd = flakeboxLib.mkStdTargets { };
|
||||
|
||||
15
justfile
15
justfile
@@ -1,4 +1,5 @@
|
||||
# THIS FILE IS AUTOGENERATED FROM FLAKEBOX CONFIGURATION
|
||||
import "./misc/justfile.custom.just"
|
||||
|
||||
alias b := build
|
||||
alias c := check
|
||||
@@ -9,18 +10,6 @@ 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":
|
||||
#!/usr/bin/env bash
|
||||
@@ -42,7 +31,7 @@ check *ARGS="--workspace --all-targets":
|
||||
|
||||
|
||||
# run all checks recommended before opening a PR
|
||||
final-check: lint clippy
|
||||
final-check: lint clippy check-wasm
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
if [ ! -f Cargo.toml ]; then
|
||||
|
||||
56
misc/justfile.custom.just
Normal file
56
misc/justfile.custom.just
Normal file
@@ -0,0 +1,56 @@
|
||||
check-wasm *ARGS="--target wasm32-unknown-unknown":
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -f Cargo.toml ]; then
|
||||
cd {{invocation_directory()}}
|
||||
fi
|
||||
|
||||
buildargs=(
|
||||
"-p cdk"
|
||||
"-p cdk --no-default-features"
|
||||
"-p cdk --no-default-features --features wallet"
|
||||
"-p cdk --no-default-features --features mint"
|
||||
"-p cdk-js"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
echo "Checking '$arg'"
|
||||
cargo check $arg {{ARGS}}
|
||||
echo
|
||||
done
|
||||
|
||||
run-examples:
|
||||
cargo r --example p2pk
|
||||
cargo r --example mint-token
|
||||
cargo r --example proof_selection
|
||||
cargo r --example wallet
|
||||
|
||||
clippy-each:
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
buildargs=(
|
||||
"-p cdk-integration-tests"
|
||||
"-p cdk"
|
||||
"-p cdk --no-default-features"
|
||||
"-p cdk --no-default-features --features wallet"
|
||||
"-p cdk --no-default-features --features mint"
|
||||
"-p cdk-redb"
|
||||
"-p cdk-redb --no-default-features --features wallet"
|
||||
"-p cdk-redb --no-default-features --features mint"
|
||||
"-p cdk-sqlite --no-default-features --features mint"
|
||||
"-p cdk-sqlite --no-default-features --features wallet"
|
||||
"-p cdk-cln"
|
||||
"-p cdk-axum"
|
||||
"-p cdk-fake-wallet"
|
||||
"-p cdk-strike"
|
||||
"--bin cdk-cli"
|
||||
"--bin cdk-mintd"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
echo "Checking '$arg'"
|
||||
cargo check $arg
|
||||
cargo clippy $arg -- -D warnings
|
||||
echo
|
||||
done
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Check bindings
|
||||
buildargs=(
|
||||
"-p cdk-js --target wasm32-unknown-unknown"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
echo "Checking '$arg'"
|
||||
|
||||
cargo build $arg
|
||||
|
||||
if [[ $arg != *"--target wasm32-unknown-unknown"* ]];
|
||||
then
|
||||
cargo test $arg
|
||||
fi
|
||||
|
||||
cargo clippy $arg -- -D warnings
|
||||
|
||||
echo
|
||||
done
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/usr/bin/env 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 cdk-integration-tests"
|
||||
"-p cdk"
|
||||
"-p cdk --no-default-features"
|
||||
"-p cdk --no-default-features --features wallet"
|
||||
"-p cdk --no-default-features --features mint"
|
||||
"-p cdk-redb"
|
||||
"-p cdk-redb --no-default-features --features wallet"
|
||||
"-p cdk-redb --no-default-features --features mint"
|
||||
"-p cdk-sqlite --no-default-features --features mint"
|
||||
"-p cdk-sqlite --no-default-features --features wallet"
|
||||
"-p cdk-cln"
|
||||
"-p cdk-axum"
|
||||
"-p cdk-fake-wallet"
|
||||
"-p cdk-strike"
|
||||
"--bin cdk-cli"
|
||||
"--bin cdk-mintd"
|
||||
"--examples"
|
||||
)
|
||||
|
||||
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
|
||||
@@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
buildargs=(
|
||||
"-p cdk"
|
||||
)
|
||||
|
||||
for arg in "${buildargs[@]}"; do
|
||||
echo "Checking '$arg' docs"
|
||||
cargo doc $arg --all-features
|
||||
echo
|
||||
done
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
flags=""
|
||||
|
||||
# Check if "check" is passed as an argument
|
||||
if [[ "$#" -gt 0 && "$1" == "check" ]]; then
|
||||
flags="--check"
|
||||
fi
|
||||
|
||||
|
||||
# Check workspace crates
|
||||
cargo fmt --all -- --config format_code_in_doc_comments=true $flags
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env 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
|
||||
@@ -1,11 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -exuo pipefail
|
||||
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
|
||||
typos
|
||||
"${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
|
||||
@@ -1,23 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
args=(
|
||||
"-p cdk"
|
||||
"-p cdk-redb"
|
||||
"-p cdk-sqlite"
|
||||
"-p cdk-rexie"
|
||||
"-p cdk-cln"
|
||||
"-p cdk-fake-wallet"
|
||||
"-p cdk-strike"
|
||||
"-p cdk-cli"
|
||||
"-p cdk-axum"
|
||||
"-p cdk-mintd"
|
||||
)
|
||||
|
||||
for arg in "${args[@]}";
|
||||
do
|
||||
echo "Publishing '$arg'"
|
||||
cargo publish "$arg"
|
||||
echo
|
||||
done
|
||||
Reference in New Issue
Block a user