-
Notifications
You must be signed in to change notification settings - Fork 71
135 lines (126 loc) · 4.88 KB
/
Copy pathdeploy-test.yml
File metadata and controls
135 lines (126 loc) · 4.88 KB
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
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
name: Deployment Test
on:
push:
tags:
- v*
branches:
- main
paths:
- charts/devlake/**
- .github/workflows/deploy-test.yml
pull_request:
paths:
- charts/devlake/**
- .github/workflows/deploy-test.yml
- "!**.md"
workflow_dispatch:
jobs:
deploy-with-helm:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database_type: ["mysql-builtin", "mysql-external"]
steps:
- name: Creating kind cluster
uses: container-tools/kind-action@v1
- name: Cluster information
run: |
kubectl cluster-info
kubectl get nodes
kubectl get pods -n kube-system
helm version
kubectl version
kubectl get storageclasses
- name: Checkout
uses: actions/checkout@v2
- name: Helm install devlake
if: matrix.database_type == 'mysql-external'
run: |
helm repo add grafana https://grafana.github.io/helm-charts
kubectl run mysql --image=mysql:8.0 \
--env="MYSQL_ROOT_PASSWORD=admin" \
--env="MYSQL_DATABASE=lake" \
--env="MYSQL_USER=merico" \
--env="MYSQL_PASSWORD=merico" \
--port=3306
kubectl expose pod mysql --port=3306
kubectl wait --for=condition=ready pod/mysql --timeout=300s
helm dep build charts/devlake
helm install --debug --wait --timeout 600s deploy-test charts/devlake \
--set service.uiPort=30000 \
--set mysql.useExternal=true \
--set mysql.externalServer=mysql \
--set grafana.persistence.enabled=false \
--set lake.encryptionSecret.secret=$(openssl rand -base64 2000 | tr -dc 'A-Z' | fold -w 128 | head -n 1) \
|| { kubectl get pods -o wide; kubectl describe pods; kubectl get events --sort-by='.lastTimestamp'; exit 1; }
- name: Helm install devlake
if: matrix.database_type == 'mysql-builtin'
run: |
helm repo add grafana https://grafana.github.io/helm-charts
helm dep build charts/devlake
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
echo Node IP: ${NODE_IP}
helm install --debug --wait --timeout 600s deploy-test charts/devlake \
--set service.uiPort=30000 \
--set mysql.image.tag=8-debian \
--set grafana.persistence.enabled=false \
--set lake.encryptionSecret.secret=$(openssl rand -base64 2000 | tr -dc 'A-Z' | fold -w 128 | head -n 1) \
|| { kubectl get pods -o wide; kubectl describe pods; kubectl get events --sort-by='.lastTimestamp'; exit 1; }
- name: List cluster resources
if: ${{ always() }}
run: |
kubectl get pods -o wide
kubectl get services -o wide
kubectl get deployments -o wide
kubectl get cm
kubectl get secrets
kubectl get pvc
# TODO: using some e2e test code to replace it
- name: Curl with endpoints
run: |
export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
failed=0
for retry in {1..10} ; do
failed=0
# home
curl --fail http://${NODE_IP}:30000 || failed=1
# API for devlake
curl --fail http://${NODE_IP}:30000/api/ping || failed=1
# API for grafana
curl --fail http://${NODE_IP}:30000/grafana/api/health || failed=1
if [ $failed -eq 0 ] ; then
break
else
sleep 3
fi
done
if [ $failed -ne 0 ] ; then
echo 'Test apis failed, please check logs from the PODS'
exit 1
fi
- name: Show logs for pods
if: ${{ always() }}
run: |
for pod in $(kubectl get pods -o jsonpath='{.items[*].metadata.name}') ; do
echo describe for $pod
kubectl describe pod $pod
echo logs for $pod
kubectl logs $pod || echo ""
done