Ocelot-Social/.travis.yml
Robert Schäfer c37f35a7da Fix #470
Define env variables $BRANCH and $CYPRESS_RETRIES

Source: https://graysonkoonce.com/getting-the-current-branch-name-during-a-pull-request-in-travis-ci/

------

Cypress is looking for a env var by default. See: https://docs.cypress.io/guides/guides/command-line.html#cypress-run

So I guess, all what we have to do is to give the env var another name.
I also added a measure to avoid running out of quota: Disable recording
if dependabot just updates dependencies.
2019-06-12 23:09:13 +02:00

73 lines
2.3 KiB
YAML

dist: xenial
language: generic
addons:
apt:
packages:
- libgconf-2-4
snaps:
- docker
- chromium
before_install:
- yarn global add wait-on
# Install Codecov
- yarn global add codecov
- yarn install
- cp cypress.env.template.json cypress.env.json
install:
- docker-compose -f docker-compose.yml -f docker-compose.travis.yml up --build -d
# avoid "Database constraints have changed after this transaction started"
- wait-on http://localhost:7474
script:
- export CYPRESS_RETRIES=1
- export BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
- echo "TRAVIS_BRANCH=$TRAVIS_BRANCH, PR=$PR, BRANCH=$BRANCH"
# Backend
- docker-compose exec backend yarn run lint
- docker-compose exec backend yarn run test:jest --ci --verbose=false --coverage
- docker-compose exec backend yarn run db:reset
- docker-compose exec backend yarn run db:seed
- docker-compose exec backend yarn run test:cucumber
- docker-compose exec backend yarn run db:reset
- docker-compose exec backend yarn run db:seed
# Frontend
- docker-compose exec webapp yarn run lint
- docker-compose exec webapp yarn run test --ci --verbose=false --coverage
- docker-compose exec -d backend yarn run test:before:seeder
# Fullstack
# Disable recording cypress tests if we just update dependencies. This is to
# avoid running out of quota.
- if [[ $BRANCH == *"dependabot"* ]]; then yarn run cypress:run; else yarn run cypress:run --record; fi
# Coverage
- codecov
after_success:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh success $WEBHOOK_URL
- if [ $TRAVIS_BRANCH == "master" ] && [ $TRAVIS_EVENT_TYPE == "push" ]; then
wget https://raw.githubusercontent.com/Human-Connection/Discord-Bot/develop/tester.sh &&
chmod +x tester.sh &&
./tester.sh staging $WEBHOOK_URL;
fi
after_failure:
- wget https://raw.githubusercontent.com/DiscordHooks/travis-ci-discord-webhook/master/send.sh
- chmod +x send.sh
- ./send.sh failure $WEBHOOK_URL
before_deploy:
- ./scripts/setup_kubernetes.sh
deploy:
- provider: script
script: scripts/docker_push.sh
on:
branch: master
- provider: script
script: scripts/deploy.sh
on:
branch: master