This repository has been archived by the owner on Apr 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
.travis.yml
149 lines (141 loc) · 5.35 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
dist: trusty
sudo: required
matrix:
include:
- script:
- echo -e "AWS_ACCESS_KEY_ID=\"$AWS_PHOTOMY_ACCESS_KEY_ID\"\nAWS_SECRET_ACCESS_KEY=\"$AWS_PHOTOMY_SECRET_ACCESS_KEY\"\nDJANGO_SECRET_KEY=\"$DJANGO_SECRET_KEY\"\nAWS_CLOUDFRONT_DOMAIN=\"$AWS_CLOUDFRONT_DOMAIN\"\nTEST_AWS_CLOUDFRONT_DOMAIN=\"$TEST_AWS_CLOUDFRONT_DOMAIN\"\nAWS_LAMBDA_SECRET_APP_KEY=\"$AWS_LAMBDA_SECRET_APP_KEY\"\nAWS_LAMBDA_SECRET_APP_VALUE=\"$AWS_LAMBDA_SECRET_APP_VALUE\"\nEMAIL_HOST_PASSWORD=\"$EMAIL_HOST_PASSWORD\"\nEMAIL_HOST_USER=\"$EMAIL_HOST_USER\"\nAWS_STORAGE_BUCKET_NAME=\"$AWS_STORAGE_BUCKET_NAME\"\nTEST_AWS_STORAGE_BUCKET_NAME=\"$TEST_AWS_STORAGE_BUCKET_NAME\"\nPOSTGRES_PASSWORD=\"$POSTGRES_PASSWORD\"" > src/.env
- stage: test
language: python
python:
- "3.6"
cache:
directories:
- $HOME/.cache/pip
services:
- postgresql
- redis-server
- docker
env:
global:
- DJANGO_SETTINGS_MODULE=photomy.settings.test.travis
- PYTHONPATH="/home/travis/build/meemaw/photomy"
- PIP_USE_MIRRORS=true
install:
- pip install -U pip wheel
- pip install -r config/requirements.txt
before_script:
- psql -c "CREATE DATABASE travisci;" -U postgres
- cd src
- python manage.py migrate --noinput --settings=photomy.settings.test.travis
script:
- pytest --cov --ds=photomy.settings.test.travis
after_success:
- bash <(curl -s https://codecov.io/bash) -F python -t $CODECOV_UPLOAD_TOKEN
- stage: test
language: node_js
node_js:
- "node"
before_script:
- cd frontend
- yarn install
cache:
yarn: true
directories:
- $HOME/.npm
script:
- yarn lint
- yarn test-coverage
after_success:
- codecov -F javascript -t $CODECOV_UPLOAD_TOKEN
- stage: test
language: python
python:
- "3.6"
node_js:
- "9.8"
services:
- redis-server
- postgresql
cache:
yarn: true
directories:
- $HOME/e2etests/.npm
- $HOME/.cache/pip
env:
global:
- DJANGO_SETTINGS_MODULE=photomy.settings.test.travise2e
- PYTHONPATH="/home/travis/build/meemaw/photomy"
- PIP_USE_MIRRORS=true
before_install:
- export CHROME_BIN=/usr/bin/google-chrome
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sudo apt-get update
- sudo apt-get install -y libappindicator1 fonts-liberation
- wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
- sudo dpkg -i google-chrome*.deb
install:
- pip install -U pip wheel
- pip install -r config/requirements.txt
- psql -c "CREATE DATABASE travisci;" -U postgres
- cd src
- export CONTAINNER_ADDRESS=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
- python manage.py migrate --noinput --settings=photomy.settings.test.travise2e
- python manage.py populate_test_users --settings=photomy.settings.test.travise2e
- python manage.py populate_test_images --settings=photomy.settings.test.travise2e
- python manage.py runserver --settings=photomy.settings.test.travise2e 2>&1 > /dev/null &
- cd ../frontend
- yarn install
- node_modules/gulp/bin/gulp.js --gulpfile ./gulpfile.js setTravis
- BROWSER=none yarn start 2>&1 > /dev/null &
- cd e2etests
- yarn install
script:
- export PHOTOMY_URL="http://localhost:3000"
- yarn test
- cd ../../src
- python manage.py clean_images --settings=photomy.settings.test.travise2e ## To delete images from s3
- stage: build
if: branch = master
language: bash
script:
- docker build . -t meemaw/photomy:latest
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- docker push meemaw/photomy:latest
- stage: build
if: tag IS present AND tag =~ ^backend-v.*$
language: bash
script:
- RELEASE_TAG=$(echo $TRAVIS_TAG | cut -d 'v' -f 2)
- echo "Building docker image version:" $RELEASE_TAG
- docker build . -t meemaw/photomy:$RELEASE_TAG
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
- echo "Pushing docker image version:" $RELEASE_TAG
- docker push meemaw/photomy:$RELEASE_TAG
- stage: deploy
if: tag IS present AND tag =~ ^frontend-v.*$
language: node_js
node_js:
- "node"
before_script:
- RELEASE_TAG=$(echo $TRAVIS_TAG | cut -d 'v' -f 2)
- echo "Deploying frontend version:" $RELEASE_TAG
- cd frontend
- 'echo "export const VERSION_INFO = { tag: ''$RELEASE_TAG'', branch: ''$TRAVIS_BRANCH'', commit: ''$TRAVIS_COMMIT'' }" > ./src/version.js'
- yarn install
- sudo pip install --upgrade pip
- sudo pip install awscli
cache:
yarn: true
directories:
- $HOME/.npm
script:
- gulp setProd
- yarn build
- aws s3 sync build s3://photomy.si --delete
after_success:
- aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DISTRIBUTION_ID --paths "/*"
stages:
- test
- build
- deploy