Skip to content

Commit 30e48b8

Browse files
authored
Merge pull request #831 from CosmWasm/dev-scripts-to-files
Move development scripts to files; Add shell formatter
2 parents 8724cdc + 14c46da commit 30e48b8

File tree

10 files changed

+79
-42
lines changed

10 files changed

+79
-42
lines changed

README.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -322,30 +322,13 @@ nightly toolchain installed as well.
322322
**Workspace**
323323

324324
```sh
325-
cargo fmt \
326-
&& (cd packages/crypto && cargo build && cargo test && cargo clippy -- -D warnings) \
327-
&& (cd packages/std && cargo wasm-debug --features iterator && cargo test --features iterator && cargo clippy --features iterator -- -D warnings && cargo schema) \
328-
&& (cd packages/storage && cargo build && cargo test --features iterator && cargo clippy --features iterator -- -D warnings) \
329-
&& (cd packages/schema && cargo build && cargo test && cargo clippy -- -D warnings) \
330-
&& (cd packages/vm && cargo build --features iterator,stargate && cargo test --features iterator,stargate && cargo clippy --features iterator,stargate -- -D warnings)
325+
./devtools/check_workspace.sh
331326
```
332327

333328
**Contracts**
334329

335-
Step 1 (fast checks, rebuilds lock files)
336-
337-
```sh
338-
for contract_dir in contracts/*/; do (cd "$contract_dir" && cargo check --tests) || break; done
339-
```
340-
341-
Step 2 (medium fast checks)
342-
343-
```sh
344-
for contract_dir in contracts/*/; do (cd "$contract_dir" && cargo fmt && cargo check --tests && cargo wasm-debug && cargo unit-test && cargo clippy --tests -- -D warnings && cargo schema) || break; done
345-
```
346-
347-
Step 3 (slower checks)
348-
349-
```sh
350-
for contract_dir in contracts/*/; do (cd "$contract_dir" && cargo wasm && cargo integration-test) || break; done
351-
```
330+
| Step | Description | Command |
331+
| ---- | -------------------------------- | -------------------------------------- |
332+
| 1 | fast checks, rebuilds lock files | `./devtools/check_contracts_fast.sh` |
333+
| 2 | medium fast checks | `./devtools/check_contracts_medium.sh` |
334+
| 3 | slower checks | `./devtools/check_contracts_full.sh` |

devtools/check_contracts_fast.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
for contract_dir in contracts/*/; do
6+
(
7+
cd "$contract_dir"
8+
cargo fmt
9+
cargo check --tests
10+
)
11+
done

devtools/check_contracts_full.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
for contract_dir in contracts/*/; do
6+
(
7+
cd "$contract_dir"
8+
cargo fmt
9+
cargo check --tests
10+
cargo unit-test
11+
cargo clippy --tests -- -D warnings
12+
cargo schema
13+
cargo wasm
14+
cargo integration-test
15+
)
16+
done

devtools/check_contracts_medium.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
for contract_dir in contracts/*/; do
6+
(
7+
cd "$contract_dir"
8+
cargo fmt
9+
cargo check --tests
10+
cargo unit-test
11+
cargo clippy --tests -- -D warnings
12+
cargo schema
13+
cargo wasm-debug
14+
)
15+
done

devtools/check_workspace.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
cargo fmt
6+
(cd packages/crypto && cargo build && cargo test && cargo clippy -- -D warnings)
7+
(cd packages/std && cargo wasm-debug --features iterator && cargo test --features iterator && cargo clippy --features iterator -- -D warnings && cargo schema)
8+
(cd packages/storage && cargo build && cargo test --features iterator && cargo clippy --features iterator -- -D warnings)
9+
(cd packages/schema && cargo build && cargo test && cargo clippy -- -D warnings)
10+
(cd packages/vm && cargo build --features iterator,stargate && cargo test --features iterator,stargate && cargo clippy --features iterator,stargate -- -D warnings)

devtools/format_md.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
npx [email protected] --write --prose-wrap always "./**/*.md"

devtools/format_sh.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -o errexit -o nounset -o pipefail
3+
command -v shellcheck >/dev/null && shellcheck "$0"
4+
5+
shfmt -w devtools packages

devtools/format_yml.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
npx [email protected] --write "./**/*.yml"

devtools/set_version.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
set -o errexit -o nounset -o pipefail
3-
command -v shellcheck > /dev/null && shellcheck "$0"
3+
command -v shellcheck >/dev/null && shellcheck "$0"
44

55
gnused="$(command -v gsed || echo sed)"
66

@@ -11,8 +11,8 @@ function print_usage() {
1111
}
1212

1313
if [ "$#" -ne 1 ]; then
14-
print_usage
15-
exit 1
14+
print_usage
15+
exit 1
1616
fi
1717

1818
# Check repo
@@ -25,9 +25,9 @@ fi
2525
# Ensure repo is not dirty
2626
CHANGES_IN_REPO=$(git status --porcelain)
2727
if [[ -n "$CHANGES_IN_REPO" ]]; then
28-
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
29-
git status && git --no-pager diff
30-
exit 3
28+
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
29+
git status && git --no-pager diff
30+
exit 3
3131
fi
3232

3333
NEW="$1"

packages/vm/examples/module_size.sh

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ PROFILE="release"
1111
MEM_UTIL="valgrind --tool=massif --max-snapshots=$MAX_SNAPSHOTS"
1212
SUM_UTIL="ms_print"
1313

14-
PROG=`basename $0 .sh`
15-
BASE_DIR=`dirname $0`/..
14+
PROG=$(basename $0 .sh)
15+
BASE_DIR=$(dirname $0)/..
1616

1717
# Look for the useful info
1818
FNS="module_compile module_deserialize"
@@ -22,8 +22,7 @@ BIN="$BASE_DIR/../../target/$PROFILE/examples/$PROG"
2222
RESULTS="$BASE_DIR/$PROG.log"
2323
SUMMARY="$BASE_DIR/ms_print.log"
2424

25-
if [ "$PROFILE" = "release" ]
26-
then
25+
if [ "$PROFILE" = "release" ]; then
2726
RUSTFLAGS="-g" cargo build --release --example module_size
2827
else
2928
cargo build --example module_size
@@ -32,18 +31,16 @@ fi
3231
$MEM_UTIL --massif-out-file=$RESULTS $BIN $WASM
3332
$SUM_UTIL $RESULTS >$SUMMARY
3433

35-
for FN in $FNS
36-
do
34+
for FN in $FNS; do
3735
# Try to compute $FN() total (heap) bytes
38-
LAST_LINE=`grep -n "::$FN " $SUMMARY| tail -1 | cut -f1 -d:`
39-
if [ -z "$LAST_LINE" ]
40-
then
36+
LAST_LINE=$(grep -n "::$FN " $SUMMARY | tail -1 | cut -f1 -d:)
37+
if [ -z "$LAST_LINE" ]; then
4138
echo -n "'$FN' not found. "
4239
[ $MAX_SNAPSHOTS -lt 1000 ] && echo "Try increasing MAX_SNAPSHOTS (current: $MAX_SNAPSHOTS, max: 1000). " || echo "Try again."
4340
continue
4441
fi
45-
TOTAL_LINES=`wc -l $SUMMARY | cut -f1 -d\ `
46-
START_LINE=$[TOTAL_LINES - $LAST_LINE + 1]
42+
TOTAL_LINES=$(wc -l $SUMMARY | cut -f1 -d\ )
43+
START_LINE=$((TOTAL_LINES - $LAST_LINE + 1))
4744
echo -n "module size ($FN): "
4845
tac $SUMMARY | sed -n "$START_LINE,/^ n /p" | grep "::$FN " | cut -f2 -d\( | cut -f1 -d\) | sort -u | sed 's/,//g;s/B//' | sed ':a;N;s/\n/+/;ta' | bc -l | sed 's/$/ bytes/'
4946
done

0 commit comments

Comments
 (0)