Skip to content

Commit

Permalink
Set up CI and project structure
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoblurye committed Jul 25, 2019
1 parent ad53ed6 commit dad5f81
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .env.prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CLOUD_SQL_INSTANCE_NAME: 'cidc-dfci:us-central1:cidc-postgres'
CLOUD_SQL_DB_USER: 'postgres'
CLOUD_SQL_DB_NAME: 'cidc'
GOOGLE_PROJECT_ID: 'cidc-dfci'
GOOGLE_UPLOAD_BUCKET: 'cidc-uploads-prod'
GOOGLE_UPLOAD_TOPIC: 'uploads'
6 changes: 6 additions & 0 deletions .env.staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CLOUD_SQL_INSTANCE_NAME: 'cidc-dfci-staging:us-central1:cidc-postgres'
CLOUD_SQL_DB_USER: 'postgres'
CLOUD_SQL_DB_NAME: 'cidc'
GOOGLE_PROJECT_ID: 'cidc-dfci-staging'
GOOGLE_UPLOAD_BUCKET: 'cidc-uploads-staging'
GOOGLE_UPLOAD_TOPIC: 'uploads'
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# IDE workspace configuration
.vscode

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
49 changes: 49 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
language: "python"
python:
- "3.6"
cache:
directories:
- $HOME/google-cloud-sdk/
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
script:
- pytest
- black --check functions main.py --target-version=py36

deploy:
- provider: script
script: echo "Deploy cloud functions to staging here..."
on:
branch: master
- provider: script
script: echo "Deploy cloud functions to production here..."
on:
branch: production
3 changes: 3 additions & 0 deletions functions/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""Entrypoint for CIDC cloud functions."""

from functions import *
Empty file added main.py
Empty file.
2 changes: 2 additions & 0 deletions requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
black==19.3b0
pytest==5.0.1
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# The cidc_api_models package
git+https://github.com/CIMAC-CIDC/cidc-api-gae
2 changes: 2 additions & 0 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def test_main():
pass

0 comments on commit dad5f81

Please sign in to comment.