-
Notifications
You must be signed in to change notification settings - Fork 1
/
.travis.yml
57 lines (56 loc) · 2.05 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
language: "python"
python:
- "3.6"
cache:
directories:
- $HOME/google-cloud-sdk/
services:
- postgresql
addons:
postgresql: "9.6"
env:
global:
- PYTHONPATH=$PYTHONPATH:$(pwd)/functions
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
- GOOGLE_APPLICATION_CREDENTIALS=$HOME/credentials.json
- GCLOUD_PROJECT_ID_STAGING=cidc-dfci-staging
- GCLOUD_PROJECT_ID_PROD=cidc-dfci
before_install:
# Install and configure the gcloud SDK. Values for these environment
# variables must be set in the Travis CI console for this to work:
# GCLOUD_SERVICE_ACCOUNT_JSON_STAGING
# -> base64-encoded service account JSON credentials for the staging project
# GCLOUD_SERVICE_ACCOUNT_JSON_PROD
# -> base64-encoded service account JSON credentials for the production project
- if [ ! -d ${HOME}/google-cloud-sdk/bin ]; then
rm -rf $HOME/google-cloud-sdk;
curl https://sdk.cloud.google.com | bash > /dev/null;
fi
- source $HOME/google-cloud-sdk/path.bash.inc
- if [ "$TRAVIS_BRANCH" = production ]; then
gcloud config set project $GCLOUD_PROJECT_ID_PROD;
export GCLOUD_SERVICE_ACCOUNT_JSON="$GCLOUD_SERVICE_ACCOUNT_JSON_PROD";
else
gcloud config set project $GCLOUD_PROJECT_ID_STAGING;
export GCLOUD_SERVICE_ACCOUNT_JSON="$GCLOUD_SERVICE_ACCOUNT_JSON_STAGING";
fi
- echo "$GCLOUD_SERVICE_ACCOUNT_JSON" | base64 --decode > $GOOGLE_APPLICATION_CREDENTIALS
- gcloud auth activate-service-account --key-file $GOOGLE_APPLICATION_CREDENTIALS
install:
- pip install -r requirements.txt -r requirements.dev.txt
before_script:
- psql -c "create user cidcdev with password '1234'"
- psql -c "create database cidctest"
- psql -c "grant all privileges on database cidctest to cidcdev"
script:
- pytest
- black --check functions main.py --target-version=py36
deploy:
- provider: script
script: bash deploy/pubsub.sh ingest_upload uploads .env.staging.yaml
on:
branch: master
- provider: script
script: bash deploy/pubsub.sh ingest_upload uploads .env.prod.yaml
on:
branch: production