84 lines
1.1 KiB
Bash
Executable File
84 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
setup() {
|
|
remove_coverage
|
|
print_ruby_version
|
|
install_gems
|
|
}
|
|
|
|
remove_coverage() {
|
|
if [ -d coverage ]; then
|
|
rm -rf coverage
|
|
fi
|
|
}
|
|
|
|
print_ruby_version() {
|
|
echo "Using $(ruby -v)"
|
|
echo
|
|
}
|
|
|
|
install_gems() {
|
|
bundle install
|
|
}
|
|
|
|
run_code_quality_checks() {
|
|
bundle exec rubocop .
|
|
}
|
|
|
|
run_unit_tests() {
|
|
bundle exec rake spec:unit
|
|
}
|
|
|
|
run_isolation_tests() {
|
|
local pwd=$PWD
|
|
local root="$pwd/spec/isolation"
|
|
|
|
run_tests $root
|
|
}
|
|
|
|
run_integration_tests() {
|
|
local pwd=$PWD
|
|
local root="$pwd/spec/integration"
|
|
|
|
run_tests $root
|
|
}
|
|
|
|
run_tests() {
|
|
local root=$1
|
|
|
|
for test in $(find $root -name '*_spec.rb')
|
|
do
|
|
run_test $test
|
|
|
|
if [ $? -ne 0 ]; then
|
|
local exit_code=$?
|
|
echo "Failing test: $test"
|
|
exit $exit_code
|
|
fi
|
|
done
|
|
}
|
|
|
|
run_test() {
|
|
local test=$1
|
|
local hash="$(shasum "$test" | cut -b 1-40)"
|
|
|
|
printf "\n\n\nRunning: $test\n"
|
|
SIMPLECOV_COMMAND_NAME=$hash bundle exec rspec $test
|
|
}
|
|
|
|
upload_code_coverage() {
|
|
bundle exec rake codecov:upload
|
|
}
|
|
|
|
main() {
|
|
setup
|
|
run_unit_tests
|
|
run_isolation_tests
|
|
run_integration_tests
|
|
upload_code_coverage
|
|
}
|
|
|
|
main
|