-
Notifications
You must be signed in to change notification settings - Fork 6
166 lines (148 loc) · 5.51 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
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
name: CI
on:
- push
- workflow_dispatch
env:
GO_VERSION: "1.21.5"
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.18.0
- 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/v7.2.4-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 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
- name: Create role
timeout-minutes: 5
run: |
curl --insecure "${TEST_DB_URL}/v1/roles" \
--header "Content-Type: application/json" \
-u "${TEST_USERNAME}:${TEST_PASSWORD}" \
--data "{
\"name\": \"DB Member\",
\"management\": \"db_member\"
}"
- name: Create ACL
timeout-minutes: 5
run: |
curl --insecure "${TEST_DB_URL}/v1/redis_acls" \
--header "Content-Type: application/json" \
-u "${TEST_USERNAME}:${TEST_PASSWORD}" \
--data "{
\"name\": \"Not Dangerous\",
\"acl\": \"+@all -@dangerous ~*\"
}"
- name: Install database
timeout-minutes: 5
run: |
cat <<EOF |
apiVersion: app.redislabs.com/v1alpha1
kind: RedisEnterpriseDatabase
metadata:
name: mydb
spec:
memorySize: 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"}'
# 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