-
Notifications
You must be signed in to change notification settings - Fork 4
/
.travis.yml
103 lines (92 loc) · 3.97 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
94
95
96
97
98
99
100
101
102
103
os:
- linux
dist: bionic
language: python
python:
- 3.7
services:
- mysql
- redis
before_install:
- openssl aes-256-cbc -K $encrypted_3c84dcdc6bbe_key -iv $encrypted_3c84dcdc6bbe_iv -in .env.enc -out .env -d
# login to github registry
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin docker.pkg.github.com
jobs:
include:
- stage: Build Backend
script:
# build image
- docker build -t docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT . -f backend.Dockerfile
after_success:
# push image
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT
- stage: Build Frontend
script:
# build image
- docker build -t docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:$TRAVIS_COMMIT . -f frontend.Dockerfile
after_success:
# push image
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:$TRAVIS_COMMIT
- stage: Build Workers
script:
# build image
- docker build -t docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:$TRAVIS_COMMIT . -f workers.Dockerfile
after_success:
# push image
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:$TRAVIS_COMMIT
- stage: Test API
install:
- wget https://repo.mysql.com//mysql-apt-config_0.8.15-1_all.deb
- sudo dpkg -i mysql-apt-config_0.8.15-1_all.deb
- sudo apt-get update -q
- sudo apt-get install -q -y --allow-unauthenticated -o Dpkg::Options::=--force-confnew mysql-server
- sudo systemctl restart mysql
- sudo mysql_upgrade
- npm install -g newman
before_script:
- node --version
- npm --version
- newman --version
- mysql --version
- mysql -e 'CREATE DATABASE pymatcha;'
- mysql -u root pymatcha < mysql_dump/users-dump.sql
# pull image
- docker pull docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT
script:
# Run the backend api
- docker run -d -p 5000:5000 --restart always --env-file .env --network="host" docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT
# Wait for docker to be up
- sleep 10
# run newman tests
- newman run --color on 'PyMatchaV2.postman_collection.json'
after_script:
# stop and remove docker to prevent them from block port at next iteration/test
- docker stop $(docker ps -a -q)
- docker rm $(docker ps -a -q)
- stage: Lint Backend
before_script:
- pip install -r backend/requirements.txt
script:
- black --check backend/
- flake8 backend/
- stage: Tag new releases
if: branch = dev
script:
- docker pull docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT
- docker pull docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:$TRAVIS_COMMIT
- docker pull docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:$TRAVIS_COMMIT
# Tag images
- docker tag docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:$TRAVIS_COMMIT docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:latest
- docker tag docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:$TRAVIS_COMMIT docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:latest
- docker tag docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:$TRAVIS_COMMIT docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:latest
# push image
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-backend:latest
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-frontend:latest
- docker push docker.pkg.github.com/seluj78/pymatcha/pymatcha-workers:latest
notifications:
email:
recipients:
on_success: change
on_failure: always