-
Notifications
You must be signed in to change notification settings - Fork 6
141 lines (126 loc) · 4.8 KB
/
ci.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
name: CI
on: [push]
env:
GO_VERSION: "1.16"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/[email protected]
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout Repository
uses: actions/[email protected]
- name: Module and build cache
uses: actions/[email protected]
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: ${{ runner.os }}-go-${{ env.GO_VERSION }}-pkg-mod-${{ hashFiles('go.sum') }}
restore-keys: |
${{ runner.os }}-go-${{ env.GO_VERSION }}
- name: Set up Kubernetes using kind
uses: engineerd/[email protected]
with:
config: bootstrap/kind-config.yml
version: v0.11.1
- name: Test Kubernetes
run: kubectl cluster-info
- name: Install Redis Enterprise operator
run: |
curl --silent --fail https://raw.githubusercontent.com/RedisLabs/redis-enterprise-k8s-docs/v6.0.20-12/bundle.yaml | kubectl apply -f -
kubectl rollout status deployment/redis-enterprise-operator --watch --timeout=5m || kubectl describe pod -lname=redis-enterprise-operator
- name: Install cluster
timeout-minutes: 10
run: |
cat <<EOF |
apiVersion: "app.redislabs.com/v1"
kind: "RedisEnterpriseCluster"
metadata:
name: "test-cluster"
spec:
nodes: 3
redisEnterpriseNodeResources:
limits:
cpu: 1000m
memory: 2Gi
requests:
cpu: 25m
memory: 2Gi
EOF
kubectl apply -f -
while [[ "$(kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status.state}')" != "Running" ]]; do
echo "waiting for the cluster to be running"
kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status}{"\n"}'
sleep 5;
done
echo "waiting loop has finished."
sleep 5;
kubectl get redisenterpriseclusters.app.redislabs.com test-cluster --output jsonpath='{.status}{"\n"}'
- name: Install database
timeout-minutes: 5
run: |
cat <<EOF |
apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
name: mydb
spec:
memory: 100MB
redisEnterpriseCluster:
name: test-cluster
rolesPermissions:
- type: redis-enterprise
role: "DB Member"
acl: "Not Dangerous"
EOF
kubectl apply -f -
while [[ "$(kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status.status}')" != "active" ]]; do
echo "waiting for the database to be running"
kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status}{"\n"}'
sleep 5;
done
echo "waiting loop has finished."
sleep 5;
kubectl get redisenterprisedatabase.app.redislabs.com mydb --output jsonpath='{.status}{"\n"}'
- name: Install a service to expose the Redis cluster on a port
run: |
cat <<EOF |
apiVersion: v1
kind: Service
metadata:
labels:
app: redis-enterprise
redis.io/cluster: test-cluster
name: external-access
spec:
ports:
- name: api
port: 9443
protocol: TCP
targetPort: 9443
nodePort: 30000
selector:
app: redis-enterprise
redis.io/cluster: test-cluster
redis.io/role: node
sessionAffinity: None
type: NodePort
EOF
kubectl apply -f -
- name: Set username
run: echo "TEST_USERNAME=$(kubectl get secret test-cluster --output jsonpath='{.data.username}' | base64 -d)" >> $GITHUB_ENV
- name: Set password
run: echo "TEST_PASSWORD=$(kubectl get secret test-cluster --output jsonpath='{.data.password}' | base64 -d)" >> $GITHUB_ENV
- name: Set URL
run: echo "TEST_DB_URL=https://localhost:$(kubectl get svc external-access --output jsonpath='{.spec.ports[].nodePort}')" >> $GITHUB_ENV
# This check is ensure that the cluster is running and accessible so the CI fails fast,
# rather than waiting several minutes for all of the Go tests to eventually time out
- name: Check cluster access
timeout-minutes: 2
run: |
curl --silent --fail --insecure "${TEST_DB_URL}/v1/bdbs" --user "${TEST_USERNAME}:${TEST_PASSWORD}"
- name: Build
run: make