1
- #! / bin/bash
1
+ #! /usr/ bin/env bash
2
2
3
3
# run script/test -h for help
4
4
5
+ # COLORS
6
+ OFF=' \033[0m'
7
+ RED=' \033[0;31m'
8
+ GREEN=' \033[0;32m'
9
+ BLUE=' \033[0;34m'
10
+
5
11
set -e
6
12
7
13
function usage()
8
14
{
9
15
echo -e " \t ================== script/test usage =================="
10
16
echo -e " \t-h --help : displays help message"
17
+ echo -e " \t-k --no-linter : disables linting tests"
11
18
echo -e " \t-d --disable-bootstrap : disables bootstrap"
12
- echo -e " \n\t Suggested flags for development: script/test -d"
19
+ echo -e " \n\t Suggested flags for development: script/test -d -s "
13
20
}
14
21
15
22
while [ " $1 " != " " ]; do
@@ -35,42 +42,64 @@ while [ "$1" != "" ]; do
35
42
shift
36
43
done
37
44
38
- DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && cd .. && pwd ) "
39
-
40
- export PATH=/usr/share/rbenv/shims:$PATH
41
- export RBENV_VERSION=" $( cat " ${DIR} /.ruby-version" ) "
42
-
43
- TRASHDIR=$( mktemp -d /tmp/cibuild.XXXXXXXXXXXXXXXXXX)
44
- cleanup () {
45
- rm -rf " $TRASHDIR "
46
- }
47
- trap cleanup EXIT
48
-
49
- cd " $DIR "
50
- . " ${DIR} /script/lib/fold.sh"
45
+ # setup
46
+ export DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && cd .. && pwd ) "
47
+ [ -z " $RBENV_VERSION " ] && export RBENV_VERSION=$( cat " $DIR /.ruby-version" )
51
48
52
49
if [[ -z $no_bootstrap ]]; then
53
50
# bootstrap
54
- begin_fold " Bootstrapping"
55
- ./script/bootstrap
56
- end_fold
51
+ echo -e " \n🥾 ${BLUE} Bootstrapping: $( date " +%H:%M:%S" ) ${OFF} \n"
52
+ echo " %%%FOLD {bootstrap}%%%"
53
+ cd " $DIR "
54
+ script/bootstrap
55
+ echo " %%%END FOLD%%%"
57
56
else
58
- echo -e " \nBypass Bootstrap"
57
+ echo -e " \n⏩ ${BLUE} Skipping Bootstrap${OFF} "
59
58
fi
60
59
61
- bundle exec rspec spec/unit && rspec_exit=$? || rspec_exit=$?
60
+ # Run Rubocop
61
+ if [[ -z $no_linter ]]; then
62
+ echo -e " \n🤖 ${BLUE} Running Rubocop: $( date " +%H:%M:%S" ) ${OFF} \n"
63
+ bundle exec rubocop -c .rubocop.yml lib/ spec/
64
+ else
65
+ echo -e " \n⏩ ${BLUE} Skipping Rubocop${OFF} "
66
+ fi
67
+
68
+ # run tests
69
+ echo -e " \n🧪 ${BLUE} Running tests: $( date " +%H:%M:%S" ) ${OFF} \n"
70
+ cd " $( dirname $0 ) /.."
62
71
63
- cat " $DIR /coverage/coverage.txt"
64
- grep -q " You're all set, friend" " $DIR /coverage/coverage.txt" && cov_exit=0 || cov_exit=1
72
+ bundle exec bin/rspec spec/unit && rspec_exit=$? || rspec_exit=$?
73
+
74
+ total_coverage=$( cat " $DIR /coverage/total-coverage.txt" )
75
+
76
+ if grep -q " 100.0" " $DIR /coverage/total-coverage.txt" ; then
77
+ cov_exit=0
78
+ echo -e " \n✅ Total Coverage: ${GREEN} $total_coverage ${OFF} "
79
+ else
80
+ cov_exit=1
81
+ echo -e " \n❌ Total Coverage: ${RED} $total_coverage ${OFF} "
82
+ fi
65
83
66
84
echo " "
67
85
echo " ---------------------------------------"
68
- echo " Summary Results"
86
+ echo " 📊 Summary Results"
69
87
echo " ---------------------------------------"
70
88
echo " "
71
- echo " rspec: exitcode=${rspec_exit} "
72
- echo " coverage: exitcode=${cov_exit} "
89
+
90
+ if [[ $rspec_exit == 0 ]]; then
91
+ echo -e " ✅ ${GREEN} rspec: exitcode=${rspec_exit}${OFF} "
92
+ else
93
+ echo -e " ❌ ${RED} rspec: exitcode=${rspec_exit}${OFF} "
94
+ fi
95
+
96
+ if [[ $cov_exit == 0 ]]; then
97
+ echo -e " ✅ \033[0;32mcoverage: exitcode=${cov_exit} \033[0m"
98
+ else
99
+ echo -e " ❌ \033[0;31mcoverage: exitcode=${cov_exit} \033[0m"
100
+ fi
73
101
74
102
[ $rspec_exit -gt 0 ] && exit 1
75
103
[ $cov_exit -gt 0 ] && exit 1
104
+
76
105
exit 0
0 commit comments