This repository has been archived by the owner on Aug 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
/
.travis.yml
93 lines (82 loc) · 4.1 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
sudo: required
language: python
services:
- docker
cache:
directories:
- $HOME/postgresql
env:
global:
- GREP_TIMEOUT=360
- REGISTRY_USER=rapidproautomation
# NOTE: this is generated with `travis encrypt REGISTRY_PASS="the-password"`
# which is decrypted by Travis CI and set as environment variables
- secure: "ftzg9S+hYbPRWVoXmhaZiOTqed4u63Lw90okq6w2AOs5T9LKuf1PVtvjGj7cfJCJqd/nANxedgxTvPeQXRc37rwLnJIikCA/D4e7XfQVOx66SbdyQxDwGtDxaWzR+cZw5yMc3pi4bl53/rXE3Gq0Hsetg7N/6YGBuxVPqIzidRHHo9zbSvb9gwB96bCPWOdtBDsZITHlxS0fNiWhuWi4m4qHlGtDUVaA47ZGfz3heXCnC79kjmJCLuSQvP+wNTOWeFSZ+Ajn0eE5RxqD4nfBRFkdhVJw52RfJqwvJdjnp4gTbHUtZ8fKQIbh+SXdBIXb7KSzhIVGsSl3ixzBvExgAnI6YxtLuzCfDi9D1uZQHWLne2Iexa2za7Y01OaQsLGedU0y5ioigXGayx9wirPCHMKTtzdWZ6G5E5i/DAAHciGW6BM0u/Vk9/Wf3ACxwdbe+pe7hsfPgCxb7KZ8mZmtH9Zx6qjWpqup69hMNaUYIIIY1hDJanO/rC4+6Zpznk/c3YF/AOwpkOsoT/uudnSWTauaDc6nw0PDMTHKdtPm6yjBN+T52Jb7YowlAjVneS+Ej9WHcSXoxjMeuK/RbFWCULX7ywGW0wqOLSD1qmR21A2ur6YRd9aSWVYCirDBHm2dEHEwl8by/Cs6P0oVXF+DA01VA1tBcT+xLCGbwFuNrMo="
matrix:
- IMAGE="rapidpro/rapidpro" VERSION="" REPO="rapidpro/rapidpro"
- IMAGE="rapidpro/rapidpro" VERSION="master" REPO="rapidpro/rapidpro"
# Update Docker Engine
before_install:
- sudo apt-get update
- sudo apt-get install -qy -o Dpkg::Options::="--force-confold" docker-ce coreutils
before_cache:
- docker exec --user=postgres postgresql pg_dump rapidpro > $HOME/postgresql/rapidpro.sql
before_script:
- echo "https://api.github.com/repos/$REPO/tags"
- jq --version
- curl -s https://api.github.com/repos/$REPO/tags | tee ./tags.json
- head ./tags.json
- LATEST_TAG=$(cat ./tags.json | jq -r '.[0].name')
- VERSION=${VERSION:-$LATEST_TAG}
install:
- echo "preventing default pip install here"
script:
# Setup postgresql and load sql dump if exists
- docker pull mdillon/postgis:9.6
- docker run -d --name postgresql -e POSTGRES_DB=rapidpro mdillon/postgis:9.6
- timeout $GREP_TIMEOUT grep -m 1 'PostgreSQL init process complete; ready for start up.' <(docker logs --follow postgresql 2>&1)
# Load the cached postgresql dump to speed up migrations
- if [[ -f $HOME/postgresql/rapidpro.sql ]]; then cat $HOME/postgresql/rapidpro.sql | docker exec -i --user=postgres postgresql psql rapidpro; fi
# Setup redis
- docker pull redis:alpine
- docker run -d --name redis redis:alpine
- timeout $GREP_TIMEOUT grep -m 1 'Ready to accept connections' <(docker logs --follow redis 2>&1)
# Build RapidPro and run it
- docker pull rapidpro/rapidpro-base:v4
# This can fail if this is the first run and a :latest tag doesn't exist yet.
- docker pull "$IMAGE" || true
- >
docker build --pull \
--tag "$IMAGE" \
--build-arg RAPIDPRO_VERSION=$VERSION \
--build-arg RAPIDPRO_REPO=$REPO \
.
- >
docker run --name rapidpro \
--env-file docker.envfile \
--link redis \
--link postgresql \
--publish 8000:8000 \
--detach \
"$IMAGE"
- timeout $GREP_TIMEOUT grep -m 1 'static files copied' <(docker logs --follow rapidpro 2>&1)
- timeout $GREP_TIMEOUT grep -m 1 'Compressing... done' <(docker logs --follow rapidpro 2>&1)
- timeout $GREP_TIMEOUT grep -m 1 'Running migrations' <(docker logs --follow rapidpro 2>&1)
# See docker.envfile for the switch to turn this off. Defaults to on because of historical reasons.
# Calls are subject to GitHub's rate limiting of Travis CI IPs and therefor can result in build failures.
- timeout $GREP_TIMEOUT grep -m 1 'Downloading geojson for relation_ids 192796' <(docker logs --follow rapidpro 2>&1)
- timeout $GREP_TIMEOUT grep -m 1 'Imported geojson for relation_ids 192796' <(docker logs --follow rapidpro 2>&1)
- timeout $GREP_TIMEOUT grep -m 1 'spawned uWSGI http 1' <(docker logs --follow rapidpro 2>&1)
- docker exec rapidpro /venv/bin/python /rapidpro/manage.py check
after_script:
- docker logs rapidpro
- docker images
before_deploy:
- pip install docker-ci-deploy==0.3.0
- docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASS"
deploy:
provider: script
skip_cleanup: true
script: dcd --tag-version "$VERSION" --tag-semver --tag-latest "$IMAGE"
on:
branch: master