<commit_before>#!/usr/bin/env bash

set -eu

export PROJECT_NAME=akvo-lumen

if [[ "${TRAVIS_BRANCH}" != "issue-1243/k8s-tests" ]] && [[ "${TRAVIS_BRANCH}" != "master" ]]; then
    exit 0
fi

if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
    exit 0
fi

# Making sure gcloud and kubectl are installed and up to date
gcloud components install kubectl
gcloud components update
gcloud version
which gcloud kubectl

# Authentication with gcloud and kubectl
gcloud auth activate-service-account --key-file ci/gcloud-service-account.json
gcloud config set project akvo-lumen
gcloud config set container/cluster europe-west1-d
gcloud config set compute/zone europe-west1-d
gcloud config set container/use_client_certificate True

if [[ "${TRAVIS_BRANCH}" == "master" ]]; then
    gcloud container clusters get-credentials lumen
else
    gcloud container clusters get-credentials test
fi

# Pushing images
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-backend
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-client
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-maps

# Deploying
sed -e "s/\${BUILD_HASH}/$TRAVIS_COMMIT/" ci/deployment.yaml.template > deployment.yaml

kubectl apply -f deployment.yaml
kubectl apply -f ci/redis-master-windshaft.yaml

./ci/wait-for-k8s-deployment-to-be-ready.sh

./ci/e2e-test.sh script-test.js akvolumenci http://t1.lumen.local/ $USERNAME $PASSWORD
./ci/e2e-test.sh clean-all.js akvolumenci http://t1.lumen.local/ $USERNAME $PASSWORD<commit_msg>[#1243] Some logging during deployment<commit_after>#!/usr/bin/env bash

set -eu

function log {
   echo "`date +"%T"` - INFO - $@"
}

export PROJECT_NAME=akvo-lumen

if [[ "${TRAVIS_BRANCH}" != "issue-1243/k8s-tests" ]] && [[ "${TRAVIS_BRANCH}" != "master" ]]; then
    exit 0
fi

if [[ "${TRAVIS_PULL_REQUEST}" != "false" ]]; then
    exit 0
fi

log Making sure gcloud and kubectl are installed and up to date
gcloud components install kubectl
gcloud components update
gcloud version
which gcloud kubectl

log Authentication with gcloud and kubectl
gcloud auth activate-service-account --key-file ci/gcloud-service-account.json
gcloud config set project akvo-lumen
gcloud config set container/cluster europe-west1-d
gcloud config set compute/zone europe-west1-d
gcloud config set container/use_client_certificate True

if [[ "${TRAVIS_BRANCH}" == "master" ]]; then
    log Environment is production
    gcloud container clusters get-credentials lumen
else
    log Environement is test
    gcloud container clusters get-credentials test
fi

log Pushing images
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-backend
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-client
gcloud docker -- push eu.gcr.io/${PROJECT_NAME}/lumen-maps

log Deploying
sed -e "s/\${BUILD_HASH}/$TRAVIS_COMMIT/" ci/deployment.yaml.template > deployment.yaml

kubectl apply -f deployment.yaml
kubectl apply -f ci/redis-master-windshaft.yaml

log Waiting for k8s to finish
./ci/wait-for-k8s-deployment-to-be-ready.sh

log Running end to end tests
./ci/e2e-test.sh script-test.js akvolumenci http://t1.lumen.local/ $USERNAME $PASSWORD
log Cleaning up environment
./ci/e2e-test.sh clean-all.js akvolumenci http://t1.lumen.local/ $USERNAME $PASSWORD
{'fraction_non_alphanumeric': 0.11988847583643122, 'fraction_numerical': 0.010223048327137546, 'mean_word_length': 4.29344262295082, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3040990', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1138, 'n_words': 301}