forked from ShelterTechSF/askdarcel-web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtravis-testcafe.sh
executable file
·66 lines (57 loc) · 2.17 KB
/
travis-testcafe.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
58
59
60
61
62
63
64
65
66
#!/bin/bash
set -ex
cleanup() {
docker stop $(docker ps -a -q)
if [[ $WEB_PID != "" ]]; then
kill $WEB_PID
fi
}
trap cleanup EXIT
# Use master branch credentials so that build status badges are tied to only the
# master branch.
if [[ $TRAVIS_BRANCH = "master" ]]; then
export SAUCE_ACCESS_KEY=$SAUCE_MASTER_ACCESS_KEY
export SAUCE_USERNAME=$SAUCE_MASTER_USERNAME
fi
export SAUCE_JOB="all"
export SAUCE_BUILD="build-$TRAVIS_JOB_NUMBER"
docker network create --driver bridge askdarcel
docker run -d --network=askdarcel --name=db postgres:9.5
# 1) rake db:populate refuses to run in the production environment, so we
# override RAILS_ENV to development.
# 2) rake will fail to run on the development environment unless if the
# development gems are installed, so we install the development gems into the
# production image.
docker run -d \
-e DATABASE_URL=postgres://postgres@db/askdarcel_development \
-e TEST_DATABASE_URL=postgres://postgres@db/askdarcel_test \
-e SECRET_KEY_BASE=notasecret \
-e ALGOLIA_APPLICATION_ID=$ALGOLIA_APPLICATION_ID \
-e ALGOLIA_API_KEY=$ALGOLIA_API_KEY \
-e ALGOLIA_INDEX_PREFIX=$ALGOLIA_INDEX_PREFIX \
-e RAILS_ENV=development \
--network=askdarcel \
--name=api \
-p 3000:3000 \
sheltertechsf/askdarcel-api:latest bash -c 'bundle install --with=development && bundle exec rake db:setup db:populate && bundle exec rails server --binding=0.0.0.0'
npm run build
TESTCAFE_RUNNING=true npm run dev &
WEB_PID=$!
# Wait long enough for npm run dev to finish compiling and for Rails to start
# running.
sleep 60
# Print out container logs in case if an error occurs
docker logs api
# Note: The version number needs to be periodically updated as new versions come
# out.
# TODO: SauceLabs does seem to allow for the version string "latest" to be an
# alias for the latest stable release, but it appears that the TestCafe
# plugin doesn't seem to support it. See
# https://github.com/DevExpress/testcafe-browser-provider-saucelabs/issues/42
npm run testcafe -- 'saucelabs:Chrome@73.0:Windows 10' \
--quarantine-mode \
--skip-js-errors \
--assertion-timeout 50000 \
--page-load-timeout 15000 \
--selector-timeout 15000 \
testcafe/*.js