Skip to content

Commit 97f364c

Browse files
committed
CI: add ci workflow for Sandbox
For a better scheduled validation of the Sandbox files, we introduce a weekly validation workflow. The workflow will: - Run every Monday at 02:00 UTC (weekly validation) - Allow manual trigger for testing - Run on changes to sandbox files
1 parent 8407190 commit 97f364c

1 file changed

Lines changed: 226 additions & 0 deletions

File tree

Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
# --------------------------------------------------------------------
2+
#
3+
# Licensed to the Apache Software Foundation (ASF) under one or more
4+
# contributor license agreements. See the NOTICE file distributed
5+
# with this work for additional information regarding copyright
6+
# ownership. The ASF licenses this file to You under the Apache
7+
# License, Version 2.0 (the "License"); you may not use this file
8+
# except in compliance with the License. You may obtain a copy of the
9+
# License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
16+
# implied. See the License for the specific language governing
17+
# permissions and limitations under the License.
18+
#
19+
# --------------------------------------------------------------------
20+
21+
name: Sandbox Weekly Validation
22+
23+
on:
24+
# Run every Monday at 02:00 UTC (weekly validation)
25+
schedule:
26+
- cron: '0 2 * * 1'
27+
28+
# Allow manual trigger for testing
29+
workflow_dispatch:
30+
inputs:
31+
test_type:
32+
description: 'Type of test to run'
33+
required: false
34+
default: 'all'
35+
type: choice
36+
options:
37+
- all
38+
- single-node
39+
- multi-node
40+
41+
# Run on changes to sandbox files
42+
push:
43+
paths:
44+
- 'devops/sandbox/**'
45+
- '.github/workflows/sandbox-validation.yml'
46+
47+
pull_request:
48+
paths:
49+
- 'devops/sandbox/**'
50+
- '.github/workflows/sandbox-validation.yml'
51+
52+
env:
53+
DOCKER_BUILDKIT: 1
54+
COMPOSE_DOCKER_CLI_BUILD: 1
55+
56+
jobs:
57+
58+
test-single-node-build:
59+
name: Test Single Node Build
60+
runs-on: ubuntu-latest
61+
if: github.event.inputs.test_type == 'all' || github.event.inputs.test_type == 'single-node' || github.event.inputs.test_type == '' || github.event_name == 'schedule'
62+
63+
strategy:
64+
matrix:
65+
version: ['main', '2.0.0']
66+
67+
steps:
68+
- name: Checkout code
69+
uses: actions/checkout@v4
70+
71+
- name: Set up Docker Buildx
72+
uses: docker/setup-buildx-action@v3
73+
74+
- name: Clean Docker resources
75+
run: |
76+
docker system prune -af
77+
docker volume prune -f
78+
79+
- name: Test single node deployment
80+
run: |
81+
cd devops/sandbox
82+
./run.sh -c ${{ matrix.version }}
83+
84+
# Wait for deployment to complete successfully
85+
echo "Waiting for Apache Cloudberry deployment to complete..."
86+
timeout 600 bash -c 'until docker logs cbdb-cdw 2>&1 | grep -q "DEPLOYMENT SUCCESSFUL"; do sleep 10; echo "Still waiting for deployment..."; done'
87+
echo "Deployment completed successfully!"
88+
89+
# Test basic database operations
90+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT version()'"
91+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * from gp_segment_configuration'"
92+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM pg_available_extensions'"
93+
94+
echo "✅ Single node test (${{ matrix.version }}) completed successfully"
95+
timeout-minutes: 30
96+
97+
- name: Check container logs on failure
98+
if: failure()
99+
run: |
100+
echo "=== Container Status ==="
101+
docker ps -a || true
102+
echo "=== Container Logs (last 100 lines) ==="
103+
docker logs --tail 100 cbdb-cdw || true
104+
echo "=== Container Resource Usage ==="
105+
docker stats --no-stream cbdb-cdw || true
106+
107+
- name: Cleanup
108+
if: always()
109+
run: |
110+
docker rm -f cbdb-cdw || true
111+
docker system prune -af || true
112+
113+
test-multi-node-build:
114+
name: Test Multi Node Build
115+
runs-on: ubuntu-latest
116+
if: github.event.inputs.test_type == 'all' || github.event.inputs.test_type == 'multi-node' || github.event.inputs.test_type == '' || github.event_name == 'schedule'
117+
118+
strategy:
119+
matrix:
120+
version: ['main', '2.0.0']
121+
122+
steps:
123+
- name: Checkout code
124+
uses: actions/checkout@v4
125+
126+
- name: Set up Docker Buildx
127+
uses: docker/setup-buildx-action@v3
128+
129+
- name: Clean Docker resources
130+
run: |
131+
docker system prune -af
132+
docker volume prune -f
133+
134+
- name: Test multi-node deployment
135+
run: |
136+
cd devops/sandbox
137+
./run.sh -c ${{ matrix.version }} -m
138+
139+
# Wait for deployment to complete successfully (longer timeout for multi-node)
140+
echo "Waiting for Apache Cloudberry multi-node deployment to complete..."
141+
timeout 900 bash -c 'until docker logs cbdb-cdw 2>&1 | grep -q "DEPLOYMENT SUCCESSFUL"; do sleep 15; echo "Still waiting for multi-node deployment..."; done'
142+
echo "Multi-node deployment completed successfully!"
143+
144+
# Test basic database operations
145+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT version()'"
146+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * from gp_segment_configuration'"
147+
docker exec -u gpadmin cbdb-cdw bash -l -c "psql -c 'SELECT * FROM pg_available_extensions'"
148+
149+
echo "✅ Multi-node test (${{ matrix.version }}) completed successfully"
150+
timeout-minutes: 45
151+
152+
- name: Check all container logs on failure
153+
if: failure()
154+
run: |
155+
echo "=== All Container Status ==="
156+
docker ps -a || true
157+
echo "=== Coordinator Logs (last 100 lines) ==="
158+
docker logs --tail 100 cbdb-cdw || true
159+
echo "=== Standby Coordinator Logs (last 50 lines) ==="
160+
docker logs --tail 50 cbdb-scdw || true
161+
echo "=== Segment 1 Logs (last 50 lines) ==="
162+
docker logs --tail 50 dw1 || true
163+
echo "=== Segment 2 Logs (last 50 lines) ==="
164+
docker logs --tail 50 cbdb-sdw2 || true
165+
echo "=== Network Status ==="
166+
docker network ls || true
167+
168+
- name: Cleanup
169+
if: always()
170+
run: |
171+
cd devops/sandbox
172+
docker compose -f docker-compose-rockylinux9.yml down -v || true
173+
docker system prune -af || true
174+
175+
notify-results:
176+
name: Notify Results
177+
runs-on: ubuntu-latest
178+
needs: [test-single-node-build, test-multi-node-build]
179+
if: always()
180+
181+
steps:
182+
- name: Generate Summary Report
183+
run: |
184+
# Determine status icons
185+
single_node_icon="❌"
186+
multi_node_icon="❌"
187+
overall_status="❌ FAILED"
188+
189+
if [[ "${{ needs.test-single-node-build.result }}" == "success" ]]; then
190+
single_node_icon="✅"
191+
fi
192+
193+
if [[ "${{ needs.test-multi-node-build.result }}" == "success" ]]; then
194+
multi_node_icon="✅"
195+
fi
196+
197+
if [[ "${{ needs.test-single-node-build.result }}" == "success" ]] && \
198+
[[ "${{ needs.test-multi-node-build.result }}" == "success" ]]; then
199+
overall_status="✅ PASSED"
200+
fi
201+
202+
# Generate GitHub Actions Summary
203+
cat >> $GITHUB_STEP_SUMMARY << EOF
204+
# 🧪 Apache Cloudberry Sandbox Validation Report
205+
206+
**Overall Status:** $overall_status
207+
208+
| Test Type | Status | Versions Tested |
209+
|-----------|--------|-----------------|
210+
| Single Node | $single_node_icon ${{ needs.test-single-node-build.result }} | main, 2.0.0 |
211+
| Multi Node | $multi_node_icon ${{ needs.test-multi-node-build.result }} | main, 2.0.0 |
212+
213+
**Generated on:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')
214+
EOF
215+
216+
# Also output to console for logs
217+
echo "Validation Results:"
218+
echo "- Single node test: ${{ needs.test-single-node-build.result }}"
219+
echo "- Multi node test: ${{ needs.test-multi-node-build.result }}"
220+
echo "- Overall status: $overall_status"
221+
222+
# Set exit code based on results
223+
if [[ "${{ needs.test-single-node-build.result }}" == "failure" ]] || \
224+
[[ "${{ needs.test-multi-node-build.result }}" == "failure" ]]; then
225+
exit 1
226+
fi

0 commit comments

Comments
 (0)