-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.travis.yml
49 lines (45 loc) · 2.21 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
# We are using docker, so we need sudo.
# We need docker service to be pre-installed as soon as we try to run our
# build because we need Travis to run our builds and test container after that.
sudo: required
services:
- docker
# 1st env gets the SHA of a commit to be used inside deploy.sh
# 2nd env tells the Google Cloud SDK to not display any prompts that require user input
env:
global:
- GIT_SHA=$(git rev-parse HEAD)
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
# Commands run before the tests
# 1. Unencrypt service-account.json file
# 2. Download and install Google Cloud SDK
# 3. Look at the default install directory and source the file
# 4. Install kubectl inside our Travis env
# 5. Authorize gcloud to execute stuff (Service Account is similar to AIM used in AWS)
# 6. Set project on GCP
# 7. Set the zone of the project
# 8. Tell to reach cluster and work with our cluster "multi-cluster"
# 9. Log in to the docker hub. The echo command sends the value of env variable and then
# essentially emit that over stdin as input to the next command (after pipe)
before_install:
- openssl aes-256-cbc -K $encrypted_0c35eebf403c_key -iv $encrypted_0c35eebf403c_iv -in service-account.json.enc -out service-account.json -d
- curl https://sdk.cloud.google.com | bash > /dev/null;
- source $HOME/google-cloud-sdk/path.bash.inc
- gcloud components update kubectl
- gcloud auth activate-service-account --key-file service-account.json
- gcloud config set project multi-k8s-249701
- gcloud config set compute/zone southamerica-east1-a
- gcloud container clusters get-credentials multi-cluster
- echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_ID" --password-stdin
- docker build -t ricardosouzamorais/client-tests -f ./client/Dockerfile.dev ./client
# It always expects that the tests run and terminates, not keep the terminal opened.
# Using Travis, we need to make sure the tests exit after running and don't cause our builds to fail.
# -- --coverage => has not worked as before
script:
- docker run -e CI=true ricardosouzamorais/client-tests npm run test
# Travis does not have a built-in script to run for K8S, so we need to do it through script
deploy:
provider: script
script: bash ./deploy.sh
on:
branch: master