-
Notifications
You must be signed in to change notification settings - Fork 0
302 lines (243 loc) · 9.88 KB
/
ci.yml
File metadata and controls
302 lines (243 loc) · 9.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
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: CI
on:
push:
branches: [main, develop, 'feature/**', 'bugfix/**']
pull_request:
branches: [main, develop]
workflow_dispatch:
permissions:
contents: read
security-events: write
jobs:
validate:
name: Validate Configuration
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Validate Docker Compose files
run: |
echo "Validating: docker/docker-compose.standalone.yml"
docker compose -f docker/docker-compose.standalone.yml config -q
echo "OK: docker/docker-compose.standalone.yml"
echo "Validating: docker/docker-compose.lan.yml"
docker compose -f docker/docker-compose.lan.yml config -q
echo "OK: docker/docker-compose.lan.yml"
for f in docker/docker-compose.advanced.yml docker/docker-compose.sso.yml; do
echo "Checking scaffold: $f"
docker compose -f "$f" config --no-interpolate -q 2>&1 && echo "OK: $f" \
|| echo "WARN: $f has placeholder variables (scaffold — not yet built out)"
done
echo "Validating: docker/docker-compose.integration.yml"
docker compose -f docker/docker-compose.integration.yml config -q
echo "OK: docker/docker-compose.integration.yml"
echo "Validating: docker/docker-compose.production.yml"
docker compose -f docker/docker-compose.production.yml config -q
echo "OK: docker/docker-compose.production.yml"
- name: ShellCheck — lab test scripts
run: |
sudo apt-get install -y shellcheck -qq
shellcheck --severity=error tests/labs/*.sh
- name: Validate module manifest
run: |
python3 -c "
import sys, re
with open('it-stack-redis.yml') as f:
content = f.read()
required = ['module:', 'version:', 'phase:', 'category:', 'ports:']
missing = [k for k in required if k not in content]
if missing:
print('Missing fields:', missing); sys.exit(1)
print('Manifest valid')
"
security-scan:
name: Security Scan
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v4
- name: Trivy — scan Dockerfile
uses: aquasecurity/trivy-action@0.28.0
with:
scan-type: config
scan-ref: .
exit-code: '0'
severity: CRITICAL,HIGH
- name: Trivy — SARIF output
uses: aquasecurity/trivy-action@0.28.0
with:
scan-type: config
scan-ref: .
format: sarif
output: trivy-results.sarif
- name: Upload SARIF to GitHub Security
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: trivy-results.sarif
lab-01-smoke:
name: Lab 01 — Smoke Test
runs-on: ubuntu-latest
needs: validate
continue-on-error: true # scaffold stubs; full lab runs on real VMs
steps:
- uses: actions/checkout@v4
- name: Install Redis client tools
run: sudo apt-get install -y redis-tools netcat-openbsd
- name: Start standalone stack
run: docker compose -f docker/docker-compose.standalone.yml up -d
- name: Wait for Redis to be ready
run: |
echo "Waiting for Redis..."
timeout 60 bash -c '
until redis-cli -h localhost -p 6379 -a "Lab01Password!" --no-auth-warning PING 2>/dev/null | grep -q PONG; do
sleep 2
done'
echo "Redis is ready"
docker compose -f docker/docker-compose.standalone.yml ps
- name: Run Lab 04-01 test script
run: bash tests/labs/test-lab-04-01.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.standalone.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.standalone.yml down -v
lab-02-smoke:
name: Lab 02 — Sentinel HA
runs-on: ubuntu-latest
needs: validate
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install Redis client tools
run: sudo apt-get install -y redis-tools netcat-openbsd
- name: Start LAN stack (master + 2 replicas + 3 sentinels)
run: docker compose -f docker/docker-compose.lan.yml up -d
- name: Wait for Redis master
run: |
timeout 90 bash -c '
until redis-cli -h localhost -p 6379 -a "Lab02Password!" --no-auth-warning PING 2>/dev/null | grep -q PONG; do
sleep 3
done'
echo "Master is ready"
- name: Wait for sentinels to stabilise
run: sleep 30
- name: Run Lab 04-02 test script
env:
REDIS_PASS: "Lab02Password!"
run: bash tests/labs/test-lab-04-02.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.lan.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.lan.yml down -v
lab-03-smoke:
name: Lab 03 — Redis Cluster (6 nodes)
runs-on: ubuntu-latest
needs: validate
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install Redis client tools
run: sudo apt-get install -y redis-tools netcat-openbsd
- name: Start advanced stack (6-node cluster)
run: docker compose -f docker/docker-compose.advanced.yml up -d
- name: Wait for all 6 nodes
run: |
for port in 7001 7002 7003 7004 7005 7006; do
timeout 60 bash -c "until redis-cli -p $port -a 'Lab03Password!' --no-auth-warning PING 2>/dev/null | grep -q PONG; do sleep 2; done"
echo "Node :$port ready"
done
- name: Wait for cluster init to complete
run: sleep 20
- name: Run Lab 04-03 test script
env:
REDIS_PASS: "Lab03Password!"
run: bash tests/labs/test-lab-04-03.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.advanced.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.advanced.yml down -v
lab-04-smoke:
name: Lab 04 — Keycloak OIDC SSO + Redis Commander oauth2-proxy
runs-on: ubuntu-latest
needs: validate
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get install -y redis-tools netcat-openbsd curl
- name: Start SSO stack (KC + redis + redis-commander + oauth2-proxy)
run: docker compose -f docker/docker-compose.sso.yml up -d
- name: Wait for Keycloak
run: timeout 200 bash -c 'until curl -sf http://localhost:8080/health/ready | grep -q UP; do sleep 5; done'
- name: Wait for Redis
run: timeout 60 bash -c 'until redis-cli -p 6379 -a "Lab04Password!" --no-auth-warning PING | grep -q PONG; do sleep 3; done'
- name: Run Lab 04-04 test script
env:
KC_PASS: "Lab04Password!"
run: bash tests/labs/test-lab-04-04.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.sso.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.sso.yml down -v
lab-05-smoke:
name: Lab 05 -- Redis cache+session+LRU + PG + Keycloak + Traefik
runs-on: ubuntu-latest
needs: validate
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get install -y redis-tools postgresql-client curl netcat-openbsd
- name: Start integration stack
run: docker compose -f docker/docker-compose.integration.yml up -d
- name: Wait for Keycloak
run: timeout 200 bash -c 'until curl -sf http://localhost:8080/health/ready | grep -q UP; do sleep 5; done'
- name: Wait for Redis
run: timeout 60 bash -c 'until redis-cli -h localhost ping 2>/dev/null | grep -q PONG; do sleep 3; done'
- name: Wait for PostgreSQL
run: timeout 60 bash -c 'until pg_isready -h localhost -p 5432 -U labapp; do sleep 3; done'
- name: Run Lab 04-05 test script
env:
REDIS_PASS: "Lab05Password!"
KC_PASS: "Lab05Password!"
run: bash tests/labs/test-lab-04-05.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.integration.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.integration.yml down -v
lab-06-smoke:
name: Lab 06 — Redis Production HA (master+2 replicas+3 sentinels+exporter)
runs-on: ubuntu-latest
needs: validate
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Install tools
run: sudo apt-get install -y redis-tools curl
- name: Start production stack
run: docker compose -f docker/docker-compose.production.yml up -d
- name: Wait for Redis master
run: timeout 60 bash -c 'until redis-cli -p 6379 -a "Lab06Password!" --no-auth-warning PING | grep -q PONG; do sleep 3; done'
- name: Wait for Redis replicas
run: timeout 60 bash -c 'until redis-cli -p 6380 -a "Lab06Password!" --no-auth-warning PING | grep -q PONG && redis-cli -p 6381 -a "Lab06Password!" --no-auth-warning PING | grep -q PONG; do sleep 3; done'
- name: Wait for Sentinels
run: timeout 60 bash -c 'until redis-cli -p 26379 PING | grep -q PONG; do sleep 3; done'
- name: Run Lab 04-06 test script
env:
REDIS_PASS: "Lab06Password!"
run: bash tests/labs/test-lab-04-06.sh
- name: Collect logs on failure
if: failure()
run: docker compose -f docker/docker-compose.production.yml logs
- name: Cleanup
if: always()
run: docker compose -f docker/docker-compose.production.yml down -v