hanami-mailer/script/ci

52 lines
802 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
run_code_quality_checks() {
bundle exec rubocop .
}
run_unit_tests() {
bundle exec rake spec:coverage
}
run_isolation_tests() {
local pwd=$PWD
local root="$pwd/spec/isolation"
if [ -d $root ]; then
for test in $(find $root -name '*_spec.rb')
do
run_isolation_test $test
if [ $? -ne 0 ]; then
local exit_code=$?
echo "Failing test: $test"
exit $exit_code
fi
done
fi
}
run_isolation_test() {
local test=$1
printf "\n\n\nRunning: $test\n"
ruby $test --options spec/isolation/.rspec
}
run_test() {
local test=$1
printf "\n\n\nRunning: $test\n"
COVERAGE=true bundle exec rspec $test
}
main() {
run_code_quality_checks &&
run_unit_tests &&
run_isolation_tests
}
main