-
Notifications
You must be signed in to change notification settings - Fork 250
/
check.sh
executable file
·48 lines (39 loc) · 1.36 KB
/
check.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
#!/usr/bin/env bash
# This script is used by Makers to ensure that the challenges stay up to date.
# If you're a student, you don't need to run it. But you can if you like!
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
setup_colors() {
if [[ -t 2 ]] && [[ -z "${NO_COLOR-}" ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m' PURPLE='\033[0;35m' CYAN='\033[0;36m' YELLOW='\033[1;33m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE='' PURPLE='' CYAN='' YELLOW=''
fi
}
cleanup() {
trap - SIGINT SIGTERM ERR
die "${RED}Checks failed${NOFORMAT}"
}
msg() {
echo >&2 -e "${1-}"
}
die() {
local msg=$1
local code=${2-1} # default exit status 1
msg "$msg"
exit "$code"
}
setup_colors
msg "${BLUE}Integrity check using Ruby version ${ORANGE}$(ruby -v)${NOFORMAT}"
msg "${BLUE} • Installing bundler${NOFORMAT}"
gem install bundler
msg "${BLUE} • Running bundle install${NOFORMAT}"
bundle install
msg "${BLUE} • Running rspec${NOFORMAT}"
# We don't really want to have to set up a database in this check.
# So let's skip the test that requires that to have happened.
bundle exec rspec --exclude-pattern spec/features/test_page_spec.rb
msg "${BLUE} • Running rubocop${NOFORMAT}"
bundle exec rubocop
exit 0