-
Notifications
You must be signed in to change notification settings - Fork 21
/
.travis.yml
189 lines (188 loc) · 7.85 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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
os: linux
dist: focal
addons:
apt:
sources:
- sourceline: 'deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable'
packages:
- docker
- docker-compose
if: fork = false
language: generic
notifications:
email:
recipients:
- team-public-cloud@dynatrace.com
if: branch = master
on_success: never
on_failure: always
slack:
secure: IG7blrkCS9NWE75A2s72okTxp/6wowyJIVMatD6yNaToGGTStmXCGrNoPska2Vvd6FLMsnfHerZwndDeS0VOJ3/5hmfW8znVB03cfW+rzin5lSecNNYztwO0Cm2p5M3a31+xOs8Nlxh4rckp6hRxMAn0G09aZt6hdqH8OD0Z5LN1NATkhIj4NK67ItnUxULyCZ9ecfJey1bf+kJJyLVTZcn5J17evJgGxReiiOIoUMdpDLBJiFSG8nyi5aVUeHfVlLBqecyCfqR96SIfWSz2gmg9Rwdpq6dwVNjKubXcOX72iYSFHXDx1cGNZGJ5a34LTDRUa7sgFt4euJnCygeUYSG2N+I23O24IjamQZYD4r4ueP97Yi/FkNVr847As/3gANhcL65/IcKILyL6ytfgBmgNjp1qSVv+lpAHYxngiWJXgfhgsby3CUkUC6JrKIzHE7FHNq5L9kDIKlYowk6iF7YArYIjBgmL2dWvuwLTiMsJu/0MCYLmsWW2t5PF7WR1hS62tDsJt6DD1Hm30wqI73+JhvfmKChLuNrYWVCb1/yDPGCxcbI7njJR3+hBfoa7P2EugkiJme+2xegag9/x05xnJ5CxaxohitdA4LriLxED2HUUVnQehp1hempZkpaWTqr5C+R6NyzDSKUz+K8wJHEI9rlpUE4wJxwE39Asr2Y=
if: branch = master
on_success: never
on_failure: always
template:
- "Build has failed:"
- "%{repository_name}: <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) by %{author} %{result} in %{duration}"
- "On branch %{branch}, after commit: %{commit_message}"
- "Travis message: %{message}"
stages:
- shellcheck
- tests
- build
- e2e-helm-deployment-test
- github-deploy
- docker-deploy
env:
global:
- TAG=$TRAVIS_TAG
- VERSION_TAG=/^release-.*
- DOCKER_CLI_EXPERIMENTAL=enabled
- GCP_PROJECT_ID="dt-gcp-extension-k8s-test"
- ARTIFACT_REGISTRY_NAME="europe-central2-docker.pkg.dev/${GCP_PROJECT_ID}/dt-artifacts/dynatrace-gcp-monitor"
jobs:
include:
- stage: shellcheck
name: CheckStyle
language: generic
script: |
status=0
for script in $(find . -iname "*.sh");
do
echo "Checking $script";
shellcheck -x "$script";
if [ $? -ne 0 ]; then
echo "ERROR: shellcheck failed at $script";
status=1;
fi;
done;
exit $status
- stage: tests
name: Tests
language: python
python:
- "3.8"
env:
- PYTHONPATH="$TRAVIS_BUILD_DIR/src:$TRAVIS_BUILD_DIR/tests"
addons:
apt:
packages:
- default-jre
cache:
directories:
- "$HOME/.cache/pip"
- "$HOME/.wgetcache"
install:
- pip install -r src/requirements.txt
- pip install -r tests/requirements.txt
script:
- pytest tests/unit -v
- pytest tests/integration/logs -v
# The cd is executed due to the fact that the wiremock instance initialized in the test is using
# the mappings (folder mappings) and the files ( __files) in the current execution dir.
- |
cd tests/integration/metrics
pytest -v
- stage: build
name: Build
language: python
python:
- "3.8"
cache:
directories:
- "$HOME/.cache/pip"
- "$HOME/.wgetcache"
env:
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
- E2E=true
before_script:
# Install GCP SDK if not already cached
- 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
- gcloud version
- openssl aes-256-cbc -K $encrypted_8f1c78bcf079_key -iv $encrypted_8f1c78bcf079_iv -in tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json.enc -out tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json -d
- gcloud auth activate-service-account --key-file tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json
- gcloud auth configure-docker europe-central2-docker.pkg.dev
script:
# Put correct Version into files
- ./build/version.sh
- ./build/get_ext_tools.sh
- ./ext_tools/yq_linux_x64 e -i ".dockerImage |= \"${ARTIFACT_REGISTRY_NAME}:e2e-travis-test-${TRAVIS_BUILD_ID}\"" k8s/helm-chart/dynatrace-gcp-monitor/values.yaml
- ./build/helm-package.sh
- ./build/docker-deploy.sh
- gsutil -m cp ./artefacts/* gs://travis-e2e-dt-gcp-extension-k8s-test/commit-${TRAVIS_COMMIT}_build-${TRAVIS_BUILD_ID}/
- stage: docker-deploy
name: Docker Hub deploy
if: tag =~ /^release-.*
language: generic
script:
- ./build/version.sh
- ./build/docker-deploy.sh
env: PUSH=true
- stage: github-deploy
name: GitHub deploy
sudo: required
if: tag =~ /^release-.*
language: generic
cache:
directories:
- "$HOME/.wgetcache"
before_deploy:
- ./build/version.sh
- ./build/get_ext_tools.sh
- ./build/helm-package.sh
deploy:
provider: releases
file_glob: true
api_key: $GITHUB_RELEASE_API_KEY
file: "./artefacts/*"
skip_cleanup: true
on:
tags: true
- stage: e2e-helm-deployment-test
name: E2E GCP helm deployment test
sudo: required
if: (tag =~ /^release-.*/) OR (branch = master) OR (type = pull_request)
language: python
python:
- "3.8"
cache:
directories:
- "$HOME/.wgetcache"
- "$HOME/google-cloud-sdk/"
- "$HOME/.cache/pip"
env:
- CLOUDSDK_CORE_DISABLE_PROMPTS=1
- PUBSUB_TOPIC="e2e_test_topic_${TRAVIS_BUILD_ID}"
- PUBSUB_SUBSCRIPTION="e2e_test_subscription_${TRAVIS_BUILD_ID}"
- IAM_SERVICE_ACCOUNT="e2e-test-sa-${TRAVIS_BUILD_ID}"
- LOG_ROUTER="e2e_test_log_router_${TRAVIS_BUILD_ID}"
- IAM_ROLE_PREFIX="e2e_test_${TRAVIS_BUILD_ID}"
- K8S_CLUSTER="e2e-test-master"
- K8S_CLUSTER_REGION="europe-central2"
- E2E=true
- CLOUD_FUNCTION_NAME="e2e_test_sample_app"
- GCP_PROJECT_2_ID="dynatrace-gcp-extension-2"
- CLOUD_RUN_REVISION_NAME="e2e-test-sample-service-00002-bif"
- DYNATRACE_URL=${DYNATRACE_URL_E2E}
- DYNATRACE_ACCESS_KEY=${DYNATRACE_ACCESS_KEY_E2E}
- secure: "pmnIVxqixHvgidZRXXmWKUfuyAeBun1eOzhP79onCFTazGRnMG+Lv+c4422nHUDA9KsmYPezjk3ESfd8EGlfL0ZFQbL45eQp3oGcbN9to6wDj8g6xyrr+tG9GJ4jirO5DlLZ5I0y3WywmE+anzbFdjV0+sWTe1QWxtzqbySCwewPThBvn/iOdJMaPh7S328W7WxkD095ZCC2pQx42Mwfforw+1Jg6yd2ZI3W4b0+KsrTBveeyfj0A7F3e7uTrA+zXst26sYY37zlT/IYT5hgpQiGqbWpnoTrYLvgjdnLxSz43zWKY/YDxFU7DY1t0HIKC4N9vWynjcx1R8VjWT4SCy5f1TPHNvNt5zJUBJ59zUBuTL8Yi6FfMqDqHRLq6W8/bMJe0QSrjJFocWIs+YD+AlCbTS6rhpynzsrbS/GHo6KjVkFhXIRVjp798IFLHsJQ2JonO8McWdaldQszu8O/rB1v8B9tXsUoc5e0pJFSXI9qVwPYAAMOx1bmDPOBQoapx5ciwUh0U2rPZyGDQVh+iDcGlGX1ttWlF83vaRYbzBYqzLzcckNSnHlva6F/ZwcTQsbrZSM5Trz3OUk7fWJMRuf7XjKFAEWzASFLYpdZ1EVP+vUmxpT8OzA9kUn3XMFd9sTm9v5GZ0zQscM+/WSmJsPPGwlQZRX5CtHbq7mySJ0="
install:
# Install GCP SDK if not already cached
- 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
- gcloud version
- pip install -r tests/requirements.txt
- ./tests/e2e/helm-preinstall.sh
before_script:
- openssl aes-256-cbc -K $encrypted_8f1c78bcf079_key -iv $encrypted_8f1c78bcf079_iv -in tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json.enc -out tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json -d
- gcloud auth activate-service-account --key-file tests/e2e/dt-gcp-extension-k8s-test-8f1c78bcf079.json
- ./build/get_ext_tools.sh
- ./tests/e2e/before-deployment-test-helm-cleanup.sh
- ./tests/e2e/before-deployment-test-extensions-cleanup.sh
- gcloud components install gke-gcloud-auth-plugin; export USE_GKE_GCLOUD_AUTH_PLUGIN=True; gcloud components update;
script:
- mkdir -p ./artefacts/ && gsutil cp gs://travis-e2e-dt-gcp-extension-k8s-test/commit-${TRAVIS_COMMIT}_build-${TRAVIS_BUILD_ID}/helm-deployment-package.tar ./artefacts/
- travis_wait 120 ./tests/e2e/execute-tests.sh
after_script:
- ./tests/e2e/deployment-test-cleanup.sh