-
-
Notifications
You must be signed in to change notification settings - Fork 106
229 lines (193 loc) · 7.41 KB
/
test-lucee7-mysql.yml
File metadata and controls
229 lines (193 loc) · 7.41 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
name: Test Lucee 7 + MySQL
on:
push:
branches:
- 'claude/**'
permissions:
contents: write
jobs:
test-lucee7-mysql:
name: Lucee 7 + MySQL
runs-on: ubuntu-latest
env:
PORT: 60007
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Start Lucee 7
run: docker compose up -d lucee7
- name: Start MySQL
run: docker compose up -d mysql
- name: Wait for MySQL to be healthy
run: |
echo "Waiting for MySQL to be ready..."
MAX_WAIT=30
WAIT_COUNT=0
while [ "$WAIT_COUNT" -lt "$MAX_WAIT" ]; do
WAIT_COUNT=$((WAIT_COUNT + 1))
echo -n "Checking MySQL (attempt ${WAIT_COUNT}/${MAX_WAIT})... "
if docker exec $(docker ps -q -f "name=mysql") mysqladmin ping -h localhost -u root -pwheelstestdb --silent 2>/dev/null; then
echo "MySQL is ready!"
break
else
echo "Not ready yet"
sleep 5
fi
done
if [ "$WAIT_COUNT" -ge "$MAX_WAIT" ]; then
echo "Warning: MySQL may not be fully ready after ${MAX_WAIT} attempts"
fi
- name: Wait for Lucee 7 to be ready
run: |
echo "Waiting for Lucee 7 to be ready..."
# Wait for container to exist
timeout 150 bash -c 'until docker ps --filter "name=lucee7" | grep -q "lucee7"; do
echo "Waiting for container to start..."
sleep 2
done'
# Wait for service to respond
MAX_WAIT=60
WAIT_COUNT=0
while [ "$WAIT_COUNT" -lt "$MAX_WAIT" ]; do
WAIT_COUNT=$((WAIT_COUNT + 1))
echo -n "Checking service (attempt ${WAIT_COUNT}/${MAX_WAIT})... "
if curl -s -o /dev/null --connect-timeout 2 --max-time 5 -w "%{http_code}" "http://localhost:${PORT}/" | grep -q "200\|404\|302"; then
echo "Service is ready!"
break
else
echo "Not ready yet"
if [ "$WAIT_COUNT" -lt "$MAX_WAIT" ]; then
sleep 5
fi
fi
done
if [ "$WAIT_COUNT" -ge "$MAX_WAIT" ]; then
echo "Warning: Service may not be fully ready after ${MAX_WAIT} attempts"
fi
- name: Run Tests
id: run-tests
run: |
TEST_URL="http://localhost:${PORT}/wheels/core/tests?db=mysql&format=json&only=failure,error"
RESULT_FILE="/tmp/lucee7-mysql-result.txt"
MAX_RETRIES=3
RETRY_COUNT=0
HTTP_CODE="000"
while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ] && [ "$HTTP_CODE" = "000" ]; do
RETRY_COUNT=$((RETRY_COUNT + 1))
echo "Test attempt ${RETRY_COUNT} of ${MAX_RETRIES}..."
HTTP_CODE=$(curl -s -o "${RESULT_FILE}" \
--max-time 900 \
--write-out "%{http_code}" \
"${TEST_URL}" || echo "000")
echo "HTTP Code: ${HTTP_CODE}"
if [ "$HTTP_CODE" = "000" ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then
echo "Connection failed, waiting 10 seconds before retry..."
sleep 10
fi
done
echo "http_code=${HTTP_CODE}" >> $GITHUB_OUTPUT
if [ -f "$RESULT_FILE" ]; then
echo "Response content:"
cat "$RESULT_FILE"
fi
if [ "$HTTP_CODE" = "200" ]; then
echo "Tests passed with HTTP 200"
exit 0
else
echo "Tests failed with HTTP code: ${HTTP_CODE}"
exit 1
fi
- name: Debug Information
if: failure()
run: |
echo "=== Docker Container Status ==="
docker ps -a
echo -e "\n=== Container Logs for lucee7 ==="
docker logs $(docker ps -aq -f "name=lucee7") 2>&1 | tail -50 || echo "Could not get logs"
echo -e "\n=== Container Logs for mysql ==="
docker logs $(docker ps -aq -f "name=mysql") 2>&1 | tail -50 || echo "Could not get logs"
echo -e "\n=== Test Result File ==="
if [ -f "/tmp/lucee7-mysql-result.txt" ]; then
cat "/tmp/lucee7-mysql-result.txt"
else
echo "Result file not found"
fi
- name: Commit workflow results to branch
if: always()
run: |
RESULTS_DIR=".github/workflow-results"
RESULTS_FILE="${RESULTS_DIR}/test-lucee7-mysql.md"
mkdir -p "$RESULTS_DIR"
# Determine status
if [ "${{ steps.run-tests.outcome }}" = "success" ]; then
STATUS="PASSED"
else
STATUS="FAILED"
fi
# Build the results file
echo "# Workflow Results: Test Lucee 7 + MySQL" > "$RESULTS_FILE"
{
echo ""
echo "**Status:** ${STATUS}"
echo "**Run:** [#${{ github.run_number }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})"
echo "**Commit:** ${{ github.sha }}"
echo "**Branch:** ${{ github.ref_name }}"
echo "**Date:** $(date -u '+%Y-%m-%d %H:%M:%S UTC')"
echo ""
echo "## Test Results"
echo ""
if [ -f "/tmp/lucee7-mysql-result.txt" ]; then
CONTENT=$(cat /tmp/lucee7-mysql-result.txt)
# Try to detect if content is JSON and format accordingly
if echo "$CONTENT" | python3 -m json.tool > /dev/null 2>&1; then
echo '```json'
echo "$CONTENT" | python3 -m json.tool 2>/dev/null || echo "$CONTENT"
echo '```'
else
echo '```'
echo "$CONTENT"
echo '```'
fi
else
echo "No test result file was generated."
fi
} >> "$RESULTS_FILE"
# Add debug info on failure
if [ "$STATUS" = "FAILED" ]; then
{
echo ""
echo "## Debug Information"
echo ""
echo "### Docker Container Status"
echo '```'
docker ps -a 2>&1 || echo "Could not get container status"
echo '```'
echo ""
echo "### Lucee 7 Container Logs (last 50 lines)"
echo '```'
docker logs $(docker ps -aq -f "name=lucee7") 2>&1 | tail -50 || echo "Could not get logs"
echo '```'
echo ""
echo "### MySQL Container Logs (last 50 lines)"
echo '```'
docker logs $(docker ps -aq -f "name=mysql") 2>&1 | tail -50 || echo "Could not get logs"
echo '```'
} >> "$RESULTS_FILE"
fi
# Commit and push results back to the branch
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "$RESULTS_FILE"
# Only commit if there are changes
if git diff --cached --quiet; then
echo "No changes to commit"
else
git commit -m "ci: add workflow results for test-lucee7-mysql [skip ci]"
git push origin HEAD:${{ github.ref_name }}
fi
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-lucee7-mysql
path: /tmp/lucee7-mysql-result.txt