-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathworkspace-run-integration-tests.yaml
135 lines (119 loc) · 4.5 KB
/
workspace-run-integration-tests.yaml
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
args:
- name: version
desc: "The version of the integration tests to use"
required: true
- name: namespace
desc: "The namespace to run the integration test against"
required: true
- name: testPattern
desc: "The test file pattern to filter the tests to run"
required: false
pod:
serviceAccount: werft
nodeSelector:
dev/workload: builds
imagePullSecrets:
- name: eu-gcr-io-pull-secret
volumes:
- name: gcp-sa
secret:
secretName: gcp-sa-gitpod-dev-deployer
- name: integration-test-user
secret:
secretName: integration-test-user
- name: config
emptyDir: {}
initContainers:
- name: gcloud
image: eu.gcr.io/gitpod-core-dev/dev/dev-environment:cw-werft-cred.0
workingDir: /workspace
imagePullPolicy: IfNotPresent
volumeMounts:
- name: gcp-sa
mountPath: /mnt/secrets/gcp-sa
readOnly: true
- name: config
mountPath: /config
readOnly: false
command:
- bash
- -c
- |
echo "[prep] preparing config."
gcloud auth activate-service-account --key-file /mnt/secrets/gcp-sa/service-account.json
cp -R /home/gitpod/.config/gcloud /config/gcloud
cp /home/gitpod/.kube/config /config/kubeconfig
echo "[prep] copied config..."
containers:
- name: tests
image: eu.gcr.io/gitpod-core-dev/build/integration-tests:{{ .Annotations.version }}
workingDir: /workspace
imagePullPolicy: Always
volumeMounts:
- name: config
mountPath: /config
readOnly: true
env:
- name: USERNAME
valueFrom:
secretKeyRef:
name: integration-test-user
key: username
- name: USER_TOKEN
valueFrom:
secretKeyRef:
name: integration-test-user
key: token
- name: ROBOQUAT_TOKEN
valueFrom:
secretKeyRef:
name: github-roboquat-automatic-changelog
key: token
- name: SLACK_NOTIFICATION_PATH
valueFrom:
secretKeyRef:
name: slack-webhook-urls
key: workspace_jobs
command:
- /bin/bash
- -c
- |
set -euo
printf '{{ toJson .Annotations }}' > context.json
echo "[prep] receiving config..."
export GOOGLE_APPLICATION_CREDENTIALS="/config/gcloud/legacy_credentials/[email protected]/adc.json"
echo "[prep] received config."
echo "[prep] using username: $USERNAME"
TEST_PATTERN="{{ .Annotations.testPattern }}"
if [[ "$TEST_PATTERN" == "<no value>" ]]; then
TEST_PATTERN=""
fi
echo "[prep] using testPattern: $TEST_PATTERN"
args=()
[[ "$TEST_PATTERN" != "" ]] && args+=( "-testPattern=$TEST_PATTERN" )
args+=( '-kubeconfig=/config/kubeconfig' )
args+=( "-namespace={{ .Annotations.namespace }}" )
[[ "$USERNAME" != "" ]] && args+=( "-username=$USERNAME" )
echo "[prep|DONE]"
/entrypoint.sh "${args[@]}" 2>&1 | tee entrypoint.sh.log | ts "[int-tests] "
RC=${PIPESTATUS[0]}
context_name={{ .Name }}
context_repo={{ .Repository.Repo }}
werftJobUrl="https://werft.gitpod-dev.com/job/${context_name}"
if [ $RC -eq 1 ]; then
title=":x: *Workspace integration test fail*"
title=$title"\n_Repo:_ ${context_repo}\n_Build:_ ${context_name}\n_TestPattern_: {{ .Annotations.testPattern }}"
errors=$(grep "\-\-\- FAIL: " entrypoint.sh.log)
BODY="{\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"${title}\"},\"accessory\":{\"type\":\"button\",\"text\":{\"type\":\"plain_text\",\"text\":\":werft: Go to Werft\",\"emoji\":true},\"value\":\"click_me_123\",\"url\":\"${werftJobUrl}\",\"action_id\":\"button-action\"}},{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"\`\`\`\\n${errors}\\n\`\`\`\"}}]}"
echo "[int-tests|FAIL]"
else
title=":white_check_mark: *Workspace integration test pass*"
title=$title"\n_Repo:_ ${context_repo}\n_Build:_ ${context_name}\n_TestPattern_: {{ .Annotations.testPattern }}"
BODY="{\"blocks\":[{\"type\":\"section\",\"text\":{\"type\":\"mrkdwn\",\"text\":\"${title}\"},\"accessory\":{\"type\":\"button\",\"text\":{\"type\":\"plain_text\",\"text\":\":werft: Go to Werft\",\"emoji\":true},\"value\":\"click_me_123\",\"url\":\"${werftJobUrl}\",\"action_id\":\"button-action\"}}]}"
echo "[int-tests|DONE]"
fi
curl -X POST \
-H 'Content-type: application/json' \
-d "${BODY}" \
"https://hooks.slack.com/${SLACK_NOTIFICATION_PATH}"
exit $RC