-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBUILD.sh
executable file
·96 lines (71 loc) · 2.99 KB
/
BUILD.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -e
# valid arguments are:
# - --fast: build only the containers
FAST=false
# parse arguments
for arg in "$@"
do
case $arg in
--fast)
FAST=true
shift
;;
*)
echo "Unknown argument: $arg"
exit 1
;;
esac
done
# if .env file exists, load it
if [ -f .env ]; then
set -o allexport
source .env
set +o allexport
fi
YELLOW='\033[1;33m'
RED='\033[0;31m'
BLUE='\033[0;34m'
NORMAL='\033[0m'
GREEN='\033[0;32m'
# comma separated list of features to use for the container build
FEATURES="${FEATURES:-}"
echo -e "${YELLOW}FEATURES: ${FEATURES}${NORMAL}\n"
# test if tools are installed
if ! command -v cargo > /dev/null 2>&1; then
echo "${RED}Cargo is not installed. Please install it first.${NORMAL}"
exit 1
fi
if ! command -v docker > /dev/null 2>&1; then
echo "${RED}Docker is not installed. Please install it first.${NORMAL}"
exit 1
fi
# if not FAST, run tests, build containers, etc.
if [ "$FAST" = false ]; then
echo -e "${BLUE}Testing...${NORMAL}"
cargo test --all --all-features --workspace || (echo -e "$RED [Tests failed] $NORMAL" && exit 1)
echo -e "${BLUE}Building...${NORMAL}"
cargo build --all --all-features --workspace || (echo -e "$RED [Build failed] $NORMAL" && exit 1)
echo -e "${BLUE}Testing...${NORMAL}"
cargo test --all --no-default-features --workspace || (echo -e "$RED [Tests (no default) failed] $NORMAL" && exit 1)
echo -e "${BLUE}Building...${NORMAL}"
cargo build --all --no-default-features --workspace || (echo -e "$RED [Build (no default) failed] $NORMAL" && exit 1)
echo -e "${BLUE}Checking...${NORMAL}"
cargo check --all --all-features --tests --benches --examples --workspace || (echo -e "$RED [Check failed] $NORMAL" && exit 1)
echo -e "${BLUE}Clippying...${NORMAL}"
cargo clippy --all --all-features --tests --benches --examples --workspace -- -D clippy::all || (echo -e "$RED [Clippy failed] $NORMAL" && exit 1)
echo -e "${BLUE}Formatting...${NORMAL}"
cargo fmt --all -- --check || (echo -e "$RED [Format failed] $NORMAL" && exit 1)
echo -e "${BLUE}Licensing...${NORMAL}"
cargo deny check || (echo -e "$RED [License check failed] $NORMAL" && exit 1)
echo -e "${BLUE}Machete...${NORMAL}"
cargo machete || (echo -e "$RED [Machete failed] $NORMAL" && exit 1)
#echo -e "${BLUE}Benchmarking...${NORMAL}"
#cargo criterion --all --features=unstable
#open target/criterion/reports/index.html
fi
echo -e "${BLUE}Build containers...${NORMAL}"
docker build --target sapiens_cli -t sapiens_cli --build-arg FEATURES="${FEATURES}" . || (echo -e "$RED [CLI Container build failed] $NORMAL" && exit 1)
docker build --target sapiens_bot -t sapiens_bot --build-arg FEATURES="${FEATURES}" . || (echo -e "$RED [BOT Container build failed] $NORMAL" && exit 1)
docker build --target sapiens_exp -t sapiens_exp --build-arg FEATURES="${FEATURES}" . || (echo -e "$RED [EXP Container build failed] $NORMAL" && exit 1)
echo -e "$GREEN === OK === $NORMAL"