-
Notifications
You must be signed in to change notification settings - Fork 1
/
build_examples.sh
executable file
·59 lines (49 loc) · 1.03 KB
/
build_examples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
if [ -n "$1" ]; then
echo "Building examples with tests"
BUILD_TESTS=true
else
echo "Building examples without tests"
BUILD_TESTS=false
fi
IGNORED_DIRS=(
"./examples/test_helpers"
"./examples/test_helpers/"
)
ignore_dir() {
local element
for element in "${@:2}"; do
[[ "$element" == "$1" ]] && return 0
done
return 1
}
process_directory() {
local dir=$1
if ignore_dir "$dir" "${IGNORED_DIRS[@]}"; then
echo "Ignoring $dir"
return
fi
if [ -f "${dir}/Cargo.toml" ]; then
cd "$dir" || exit
echo "Building contract in $dir"
cargo contract build --release || exit
if [ "$BUILD_TESTS" = true ]; then
echo "Running e2e-tests in $dir"
cargo test --features e2e-tests --release || exit
fi
cd - || exit
else
for inner in "$dir"/*/; do
if [[ -d $inner ]]; then
process_directory "$inner"
fi
done
fi
}
for pattern in "./examples"; do
for dir in $pattern; do
if [[ -d $dir ]]; then
process_directory "$dir"
fi
done
done