-
Notifications
You must be signed in to change notification settings - Fork 36
/
build.sh
executable file
·57 lines (40 loc) · 1.17 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
#!/bin/bash
set -e
docker --version
docker compose --version
export COMPOSE_PROJECT_NAME=rollcall
export COMPOSE_FILE=docker-compose.yml:docker-compose.test.yml
export RAILS_ENV=test
# clean up containers
docker compose rm -fv
# build the containers
docker compose build
# start the containers
docker compose up -d db redis
# wait for postgres to start accepting connections
# TODO: actively check in a loop with a shorter sleep
sleep 5
set +e
# create and migrate the database
docker compose run --rm web bundle exec rake db:setup
# run the tests
docker compose run --name=$COMPOSE_PROJECT_NAME-rspec --user root --rm web bundle exec rake spec spec:javascript
rake_status=$?
docker start $COMPOSE_PROJECT_NAME-rspec
docker exec -e ENABLE_COVERAGE=true $COMPOSE_PROJECT_NAME-rspec bundle exec rake spec
rake_status=$?
docker compose run --user root --rm web bundle exec brakeman
brake_status=$?
# run cucumber tests
docker compose run --rm web bash bin/cucumber
cuke_status=$?
echo $rake_status
echo $brake_status
echo $cuke_status
if [ $rake_status != 0 -o $brake_status != 0 -o $cuke_status != 0 ]; then
test_status=1
else
test_status=0
fi
docker compose stop
exit $test_status