-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path.travis.yml
57 lines (51 loc) · 2.8 KB
/
.travis.yml
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
sudo: required
language: generic
services:
- docker
env:
- ENV=dev PGPORT=54321 GID=$(id -g) DOMAIN=build.orcidhub.org.nz PROD_BRANCH=prod UAT_BRANCH=prod DATABASE_URL=postgresql://orcidhub@db/orcidhub?options='-c statement_timeout=3000' PYTHONWARNINGS="ignore:Unverified HTTPS request"
before_install:
- sudo rm /usr/local/bin/docker-compose
- curl -L "https://github.com/docker/compose/releases/download/1.20.0/docker-compose-$(uname -s)-$(uname -m)" -o docker-compose
- chmod +x docker-compose
- sudo mv docker-compose /usr/local/bin
install:
- gen-keys/genkey.sh $DOMAIN
- openssl genrsa -out .keys/dkim.key 1024
- for t in sp server; do cp build-server.key .keys/${ENV}-$t.key; cp build-server.crt .keys/${ENV}-$t.crt; done
- mkdir -p pgdata data/redis archive backup
- export UID
- docker-compose up -d
# Wait for containers get started...
- for t in {1..40}; do (docker-compose ps app | grep -q ' Up ') && break ; sleep 1; done
before_script:
- docker-compose exec app coverage erase
script:
- wait_pg_up() { until docker-compose exec db psql -U postgres -l; do echo "Waiting for postgres to start..."; sleep 1; done }
- docker-compose exec app find -name '__pycache__' -exec rm -rf {} \; || true
- docker-compose exec app flake8 orcid_hub
- grep -m1 -q 'PostgreSQL init process complete; ready for start up.' <(docker-compose logs -f db); wait_pg_up
- docker-compose exec db psql -U postgres -c "SELECT 1" && echo "DB IS RUNNING"
- docker-compose exec db psql -U orcidhub -d orcidhub -c "SELECT 1" && echo "DB orcidhub IS RUNNING"
- docker-compose exec app curl -k -s https://localhost/pyinfo -o /dev/null && echo "WSGI is working..."
- docker-compose exec app w3c_validator https://localhost https://localhost/about https://localhost/faq
- docker-compose exec app ./pytest.sh
- docker-compose logs app
after_success:
- echo "*** Deploying from $(curl ipv4.icanhazip.com)"
- docker-compose exec app coverage report
- docker-compose exec app coveralls
- |
if [[ $TRAVIS_COMMIT_MESSAGE == *"[PUBLISH]"* ]] ; then
docker-compose exec app python3.6 ./setup.py sdist
docker-compose exec app twine upload -u "$PYPI_USER" -p "$PYPI_PASSWORD" --skip-existing dist/*
fi
- eval "$(ssh-agent -s)"
- openssl rsa -in .travis/.deploy.key -out .travis/deploy.key -passin env:DEPLOY_KEY_PASSPHRASE
- chmod 400 .travis/deploy.key
- ssh-add .travis/deploy.key
- git remote add deploy ssh://[email protected]/~/repo.git
- git remote add test ssh://[email protected]/~/repo.git
- git push deploy HEAD:$TRAVIS_BRANCH
- test "$TRAVIS_BRANCH" == "$UAT_BRANCH" -a "$TRAVIS_EVENT_TYPE" == "push" && git push test HEAD:$TRAVIS_BRANCH
- rm -f .travis/deploy.key