-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(rust): Address clippy warnings (#14)
# Motivation The code is failing the rust linter in CI. # Changes - Address clippy lints. # Tests See CI --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
a1277a0
commit a46910f
Showing
7 changed files
with
45 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,37 @@ | ||
#!/usr/bin/env bash | ||
|
||
did_file_location_from_cargo() { | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path | sub("Cargo.toml";"\($v).did")' | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path | sub("Cargo.toml";"\($v).did")' | ||
} | ||
cargo_manifest_path() { | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path")' | ||
# Warning: Does no _- conversion. | ||
cargo metadata --format-version 1 | jq -r --arg v "$1" '.packages[] | select(.name==$v) | .manifest_path")' | ||
} | ||
did_file_location_from_dfx_json() { | ||
# Warning: Does no _- conversion. | ||
jq -r --arg v "$1" '.canisters[$v].candid' dfx.json | ||
# Warning: Does no _- conversion. | ||
jq -r --arg v "$1" '.canisters[$v].candid' dfx.json | ||
} | ||
|
||
function generate_did() { | ||
local canister=$1 | ||
echo "Deriving candid file from Rust for $canister" | ||
#local manifest_path="$(cargo_manifest_path "$canister")" | ||
#local candid_file="${manifest_path%Cargo.toml}$canister.did" | ||
local candid_file="$(did_file_location_from_dfx_json "$canister")" | ||
local canister=$1 | ||
echo "Deriving candid file from Rust for $canister" | ||
#local manifest_path="$(cargo_manifest_path "$canister")" | ||
#local candid_file="${manifest_path%Cargo.toml}$canister.did" | ||
local candid_file="$(did_file_location_from_dfx_json "$canister")" | ||
|
||
test -e "target/wasm32-unknown-unknown/release/$canister.wasm" || | ||
cargo build -p "$canister" \ | ||
--target wasm32-unknown-unknown \ | ||
--release --package "$canister" | ||
test -e "target/wasm32-unknown-unknown/release/$canister.wasm" || | ||
cargo build -p "$canister" \ | ||
--target wasm32-unknown-unknown \ | ||
--release --package "$canister" | ||
|
||
# cargo install candid-extractor | ||
candid-extractor "target/wasm32-unknown-unknown/release/$canister.wasm" >"$candid_file" | ||
echo "Written: $candid_file" | ||
# cargo install candid-extractor | ||
candid-extractor "target/wasm32-unknown-unknown/release/$canister.wasm" >"$candid_file" | ||
echo "Written: $candid_file" | ||
} | ||
|
||
CANISTERS=(example_app_backend example_paid_service) | ||
|
||
for canister in ${CANISTERS[@]}; do | ||
generate_did "$canister" | ||
generate_did "$canister" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
|
||
print_help() { | ||
echo "Runs rust unit tests." | ||
} | ||
|
||
[[ "${1:-}" != "--help" ]] || print_help | ||
|
||
cargo test --lib --bins "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters