-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
91 lines (80 loc) · 3.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
language: node_js
node_js:
- "8"
cache:
npm: true
yarn: true
directories:
- $HOME/google-cloud-sdk
- $HOME/terraform
env:
global:
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
before_install:
- openssl aes-256-cbc -K $[your-key] -iv $[your-iv] -in google_key.json.enc -out google_key.json -d
- |
if [ ! -d "$HOME/terraform/bin" ]; then
rm -rf "$HOME/terraform"
mkdir -p $HOME/terraform/bin
wget https://releases.hashicorp.com/terraform/0.12.6/terraform_0.12.6_linux_amd64.zip
unzip terraform_0.12.6_linux_amd64.zip -d $HOME/terraform/bin/
fi
- export PATH=$PATH:$HOME/terraform/bin
- 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 [ -d "$PWD/$DIRECTORY" ];
then
cp google_key.json $PWD/$DIRECTORY
cd $PWD/$DIRECTORY
fi
- gcloud auth activate-service-account --key-file=google_key.json
# Install codeclimate
- |
if [ ! -d "$HOME/cc-test-reporter/bin" ]; then
rm -rf "$HOME/cc-test-reporter";
mkdir -p $HOME/cc-test-reporter/bin;
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $HOME/cc-test-reporter/bin/cc-test-reporter;
chmod +x $HOME/cc-test-reporter/bin/cc-test-reporter
fi
- export PATH=$PATH:$HOME/cc-test-reporter/bin
install:
- yarn
after_script:
- cd $TRAVIS_BUILD_DIR
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then cc-test-reporter format-coverage -t lcov -o ./coverage/codeclimate.$TRAVIS_JOB_NUMBER.json ./*/coverage/*.info; fi
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then gsutil cp -r coverage/ gs://lcc3108-nodejs-test-bucket/coverage/$TRAVIS_BUILD_NUMBER; fi
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then gsutil cp -r gs://lcc3108-nodejs-test-bucket/coverage/$TRAVIS_BUILD_NUMBER coverage/; fi
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then cc-test-reporter sum-coverage --parts 1 coverage/*.json; fi
- if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then cc-test-reporter upload-coverage --id $CC_TEST_REPORTER_ID; fi
jobs:
include:
# Backend test
- stage: test
env: DIRECTORY=backend
before_script:
- openssl aes-256-cbc -K $encrypted_3390520961c0_key -iv $encrypted_3390520961c0_iv -in .env.enc -out .env -d
- cc-test-reporter before-build
script:
- yarn lint
- yarn type-check
- yarn coverage
- yarn build
# Deployment
- stage: deploy
before_script:
- gsutil rm -r gs://lcc3108-nodejs-test-bucket/coverage
- openssl aes-256-cbc -K $encrypted_3390520961c0_key -iv $encrypted_3390520961c0_iv -in backend/.env.enc -out backend/.env -d
script:
- yarn build
before_deploy:
- terraform init
- gsutil cp gs://lcc3108-nodejs-test-bucket/terraform.tfstate ./terraform.tfstate
deploy:
- provider: script
script: yarn deploy
skip_cleanup: true
on:
branch: master
after_deploy:
- gsutil cp ./terraform.tfstate gs://lcc3108-nodejs-test-bucket/