Unverified Commit 0bdbd54c authored by Michael Müller's avatar Michael Müller Committed by GitHub
Browse files

Fix scripts/check-{examples,workspace} (#533)



* [examples] Add missing accumulator/std

* Fix check-examples.sh

* Fix check-workspaces.sh

* Line up results

* Complete crates

* Update scripts/check-examples.sh
Co-authored-by: default avatarHero Bird <robin.freyler@gmail.com>

* Introduce differentiation purely_std_crate/also_wasm_crate

* Include crates lang/codegen and metadata in CI testing
Co-authored-by: default avatarHero Bird <robin.freyler@gmail.com>
parent 4f8f8f16
Pipeline #111600 passed with stages
in 5 minutes and 45 seconds
......@@ -17,7 +17,9 @@ variables:
CARGO_INCREMENTAL: 0
CARGO_HOME: "/ci-cache/${CI_PROJECT_NAME}/cargo/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
CARGO_TARGET_DIR: "/ci-cache/${CI_PROJECT_NAME}/targets/${CI_COMMIT_REF_NAME}/${CI_JOB_NAME}"
ALL_CRATES: "env storage storage/derive allocator prelude primitives lang lang/macro lang/ir"
PURELY_STD_CRATES: "lang/codegen metadata"
ALSO_WASM_CRATES: "env storage storage/derive allocator prelude primitives lang lang/macro lang/ir"
ALL_CRATES: "${PURELY_STD_CRATES $ALSO_WASM_CRATES}"
workflow:
rules:
......@@ -73,7 +75,7 @@ check-wasm:
stage: check
<<: *docker-env
script:
- for crate in ${ALL_CRATES}; do
- for crate in ${ALSO_WASM_CRATES}; do
cargo check --verbose --no-default-features --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
done
......@@ -98,7 +100,7 @@ build-wasm:
- job: check-wasm
artifacts: false
script:
- for crate in ${ALL_CRATES}; do
- for crate in ${ALSO_WASM_CRATES}; do
cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml;
done
......@@ -166,7 +168,7 @@ clippy-wasm:
- job: check-wasm
artifacts: false
script:
- for crate in ${ALL_CRATES}; do
- for crate in ${ALSO_WASM_CRATES}; do
cargo clippy --verbose --no-default-features --manifest-path crates/${crate}/Cargo.toml --target wasm32-unknown-unknown -- -D warnings;
done
......
......@@ -39,5 +39,7 @@ std = [
"scale/std",
"scale-info",
"scale-info/std",
"accumulator/std",
]
ink-as-dependency = []
......@@ -2,8 +2,8 @@
# Run this script from the workspace root!
#
# This script iterates through all examples under `examples/lang` folder
# and runs the most important actions performed on an ink! smart contract:
# This script iterates through all examples and runs the most important
# actions performed on an ink! smart contract:
#
# - compile to a Wasm blob using `no_std` environment
# - run offchain tests
......@@ -15,11 +15,15 @@
declare -A results_test
declare -A results_wasm
declare -A results_abi
declare -A results_metadata
all_checks_passed=0
for example in $(ls examples/lang); do
cargo build --release --no-default-features --target=wasm32-unknown-unknown --verbose --manifest-path examples/lang/$example/Cargo.toml
build() {
example=$1
pushd $example
cargo contract build
result_wasm=$?
let "all_checks_passed |= $result_wasm"
if [ $result_wasm -eq 0 ]
......@@ -28,7 +32,14 @@ for example in $(ls examples/lang); do
else
results_wasm[$example]="ERROR"
fi
cargo test --verbose --manifest-path examples/lang/$example/Cargo.toml
popd
}
run_tests() {
example=$1
pushd $example
cargo test --verbose
result_test=$?
let "all_checks_passed |= $result_test"
if [ $result_test -eq 0 ]
......@@ -37,24 +48,49 @@ for example in $(ls examples/lang); do
else
results_test[$example]="ERROR"
fi
cargo run --package abi-gen --manifest-path examples/lang/$example/Cargo.toml
result_abi=$?
let "all_checks_passed |= $result_abi"
if [ $result_abi -eq 0 ]
popd
}
metadata() {
example=$1
pushd $example
cargo contract generate-metadata
result_metadata=$?
let "all_checks_passed |= $result_metadata"
if [ $result_metadata -eq 0 ]
then
results_abi[$example]="ok"
results_metadata[$example]="ok"
else
results_abi[$example]="ERROR"
results_metadata[$example]="ERROR"
fi
popd
}
for example in $(ls -d examples/*/ | grep -v delegator); do
build $example
run_tests $example
metadata $example
done
# the delegator is a special case, we need to build it's sub-contracts first
for example in $(ls -d examples/delegator/{accumulator,adder,subber}/); do
build $example
run_tests $example
done
build examples/delegator/
run_tests examples/delegator/
metadata examples/delegator/
banner="---------------"
echo "Example Results"
echo "$banner"
for entry in ${!results_wasm[@]}; do
echo "- $entry (wasm): ${results_wasm[$entry]}"
echo "- $entry (test): ${results_test[$entry]}"
echo "- $entry (abi) : ${results_abi[$entry]}"
echo "- $entry (wasm): ${results_wasm[$entry]}"
echo "- $entry (test): ${results_test[$entry]}"
echo "- $entry (metadata): ${results_metadata[$entry]}"
done
echo ""
if [ $all_checks_passed -eq 0 ]
......
......@@ -17,19 +17,21 @@
declare -A results
all_crates=("core" "alloc" "utils" "model" "lang" "lang" "lang/macro" "cli")
wasm_crates=("core" "alloc" "utils" "model" "lang" "lang" "lang/macro")
purely_std_crates=("lang/codegen" "metadata")
also_wasm_crates=("env" "storage" "storage/derive" "allocator" "prelude" "primitives" "lang" "lang/macro" "lang/ir")
all_crates=("${also_wasm_crates[@]}" "${purely_std_crates[@]}")
results["check_all_features"]=true
for crate in "${all_crates[@]}"; do
cargo check --verbose --all-features --manifest-path $crate/Cargo.toml
cargo check --verbose --all-features --manifest-path crates/$crate/Cargo.toml
let "results['check_all_features'] |= $?"
cargo check --verbose --no-default-features --manifest-path $crate/Cargo.toml
let "results['check_no_defaults'] |= $?"
cargo build --verbose --all-features --release --manifest-path crates/${crate}/Cargo.toml
let "results['build_std'] |= $?"
done
for crate in "${wasm_crates[@]}"; do
cargo build --verbose --manifest-path $crate/Cargo.toml --no-default-features --release --target=wasm32-unknown-unknown
for crate in "${also_wasm_crates[@]}"; do
cargo build --verbose --no-default-features --release --target wasm32-unknown-unknown --manifest-path crates/${crate}/Cargo.toml
let "results['build_wasm'] |= $?"
done
......@@ -39,10 +41,7 @@ results["fmt"]=$?
cargo clippy --verbose --all --all-features -- -D warnings
results["clippy_all_features"]=$?
cargo clippy --verbose --all --no-default-features -- -D warnings
results["clippy_no_defaults"]=$?
cargo test --verbose --all --all-features --release
cargo test --verbose --all-features --no-fail-fast --workspace --release
results["test_all_features"]=$?
all_checks_passed=0
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment