-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Script to check if a
integration-test
manifest is a contract (#1893)
* Add is_contract.sh script to detect if a crate is probably a contract * Add heuristic docs * Try using is_contract script in examples-contract-build * Fix * Use in examples-docs * conditional-compilation build release. * Fmt * Clippy * Fix UI tests * Find * Disable all find tests * Revert "Disable all find tests" This reverts commit 626f1b6. * Comment out tests using find command * Try examples-fmt * Split find lines * Restore examples-clippy * Restore examples-clippy-wasm * Restore examples-contract-build * Restore examples-docs * Attempt to fix up examples-docs * Comment out examples-docs * Restore examples-docs * examples-contract-build-riscv * Try just running tests on all contracts * Remove env vars * Run static buffer integration tests
- Loading branch information
Showing
4 changed files
with
78 additions
and
134 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_NAME="${BASH_SOURCE[0]}" | ||
MANIFEST_PATH=$1 | ||
|
||
function usage { | ||
cat << EOF | ||
Usage: ${SCRIPT_NAME} MANIFEST_PATH | ||
Succeeds if the crate at MANIFEST_PATH is *probably* contract crate, fails otherwise. The heuristic used is: | ||
- Find the root package of the crate | ||
- Find the source file of the root package that is a lib | ||
- Check for the presence of the `#[ink::contract]` attribute macro | ||
MANIFEST_PATH | ||
Path to the Cargo.toml manifest file for a possible contract project | ||
EXAMPLES | ||
${SCRIPT_NAME} ./Cargo.toml | ||
EOF | ||
} | ||
|
||
if [ -z "$MANIFEST_PATH" ]; then | ||
usage | ||
exit 1 | ||
fi | ||
|
||
ROOT_PACKAGE=$(cargo metadata --format-version=1 --manifest-path "$MANIFEST_PATH" | | ||
jq -r '.resolve.root') | ||
SOURCE_PATH=$(cargo metadata --format-version=1 --manifest-path "$MANIFEST_PATH" | | ||
jq -r --arg ROOT_PACKAGE "$ROOT_PACKAGE" ' | ||
.packages[] | ||
| select(.id == $ROOT_PACKAGE).targets[] | ||
| select(.kind[] | contains("lib")).src_path') | ||
|
||
if grep -q '^#\[ink::contract\]' $SOURCE_PATH; then | ||
exit 0 | ||
else | ||
exit 1 | ||
fi |