-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-run-tests
57 lines (45 loc) · 1.3 KB
/
docker-run-tests
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
#!/bin/bash
if [[ $KIND_KEEP_ORIGINAL_CLUSTER == 0 ]]; then
echo "-> removing kind cluster..."
kind delete cluster
echo "-> creating kind cluster..."
kind create cluster
exit_code=$?
if [[ $exit_code != 0 ]]; then
echo "<- failed to create kind cluster"
exit $exit_code
fi
fi
if [[ -z "$KUBECONFIG" ]]; then
# export kube config
export KUBECONFIG="$(kind get kubeconfig-path)"
fi
if [[ -n "$KIND_COPY_KUBECONFIG_TO" ]]; then
cp $KUBECONFIG $KIND_COPY_KUBECONFIG_TO
fi
echo "-> init helm..."
kubectl create serviceaccount --namespace kube-system tiller
kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
kubectl patch deploy --namespace kube-system tiller-deploy -p '{"spec":{"template":{"spec":{"serviceAccount":"tiller"}}}}'
helm init --service-account tiller --upgrade
exit_code=$?
if [[ $exit_code != 0 ]]; then
echo "<- failed to init helm"
exit $exit_code
fi
sleep 5
until timeout 5 helm version
do
echo "-> tiller is not ready yet. waiting..."
sleep 1
done
# navigate to project dir
cd /usr/app
echo "-> running tests..."
yarn test
exit_code=$?
if [[ $KIND_KEEP_GENERATED_CLUSTER == 0 ]]; then
echo "-> removing kind cluster..."
kind delete cluster
fi
exit $exit_code