|
| 1 | +name: Test Lucee 7 + MySQL |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - 'claude/**' |
| 7 | + |
| 8 | +jobs: |
| 9 | + test-lucee7-mysql: |
| 10 | + name: Lucee 7 + MySQL |
| 11 | + runs-on: ubuntu-latest |
| 12 | + env: |
| 13 | + PORT: 60007 |
| 14 | + steps: |
| 15 | + - name: Checkout Repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Start Lucee 7 |
| 19 | + run: docker compose up -d lucee7 |
| 20 | + |
| 21 | + - name: Start MySQL |
| 22 | + run: docker compose up -d mysql |
| 23 | + |
| 24 | + - name: Wait for containers to be ready |
| 25 | + run: | |
| 26 | + echo "Waiting for Lucee 7 to be ready..." |
| 27 | +
|
| 28 | + # Wait for container to exist |
| 29 | + timeout 150 bash -c 'until docker ps --filter "name=lucee7" | grep -q "lucee7"; do |
| 30 | + echo "Waiting for container to start..." |
| 31 | + sleep 2 |
| 32 | + done' |
| 33 | +
|
| 34 | + # Wait for service to respond |
| 35 | + MAX_WAIT=60 |
| 36 | + WAIT_COUNT=0 |
| 37 | +
|
| 38 | + while [ "$WAIT_COUNT" -lt "$MAX_WAIT" ]; do |
| 39 | + WAIT_COUNT=$((WAIT_COUNT + 1)) |
| 40 | + echo -n "Checking service (attempt ${WAIT_COUNT}/${MAX_WAIT})... " |
| 41 | +
|
| 42 | + if curl -s -o /dev/null --connect-timeout 2 --max-time 5 -w "%{http_code}" "http://localhost:${PORT}/" | grep -q "200\|404\|302"; then |
| 43 | + echo "Service is ready!" |
| 44 | + break |
| 45 | + else |
| 46 | + echo "Not ready yet" |
| 47 | + if [ "$WAIT_COUNT" -lt "$MAX_WAIT" ]; then |
| 48 | + sleep 5 |
| 49 | + fi |
| 50 | + fi |
| 51 | + done |
| 52 | +
|
| 53 | + if [ "$WAIT_COUNT" -ge "$MAX_WAIT" ]; then |
| 54 | + echo "Warning: Service may not be fully ready after ${MAX_WAIT} attempts" |
| 55 | + fi |
| 56 | +
|
| 57 | + - name: Run Tests |
| 58 | + id: run-tests |
| 59 | + run: | |
| 60 | + TEST_URL="http://localhost:${PORT}/wheels/core/tests?db=mysql&format=json&only=failure,error" |
| 61 | + RESULT_FILE="/tmp/lucee7-mysql-result.txt" |
| 62 | +
|
| 63 | + MAX_RETRIES=3 |
| 64 | + RETRY_COUNT=0 |
| 65 | + HTTP_CODE="000" |
| 66 | +
|
| 67 | + while [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ] && [ "$HTTP_CODE" = "000" ]; do |
| 68 | + RETRY_COUNT=$((RETRY_COUNT + 1)) |
| 69 | + echo "Test attempt ${RETRY_COUNT} of ${MAX_RETRIES}..." |
| 70 | +
|
| 71 | + HTTP_CODE=$(curl -s -o "${RESULT_FILE}" \ |
| 72 | + --max-time 900 \ |
| 73 | + --write-out "%{http_code}" \ |
| 74 | + "${TEST_URL}" || echo "000") |
| 75 | +
|
| 76 | + echo "HTTP Code: ${HTTP_CODE}" |
| 77 | +
|
| 78 | + if [ "$HTTP_CODE" = "000" ] && [ "$RETRY_COUNT" -lt "$MAX_RETRIES" ]; then |
| 79 | + echo "Connection failed, waiting 10 seconds before retry..." |
| 80 | + sleep 10 |
| 81 | + fi |
| 82 | + done |
| 83 | +
|
| 84 | + echo "http_code=${HTTP_CODE}" >> $GITHUB_OUTPUT |
| 85 | +
|
| 86 | + if [ -f "$RESULT_FILE" ]; then |
| 87 | + echo "Response content:" |
| 88 | + cat "$RESULT_FILE" |
| 89 | + fi |
| 90 | +
|
| 91 | + if [ "$HTTP_CODE" = "200" ]; then |
| 92 | + echo "Tests passed with HTTP 200" |
| 93 | + exit 0 |
| 94 | + else |
| 95 | + echo "Tests failed with HTTP code: ${HTTP_CODE}" |
| 96 | + exit 1 |
| 97 | + fi |
| 98 | +
|
| 99 | + - name: Debug Information |
| 100 | + if: failure() |
| 101 | + run: | |
| 102 | + echo "=== Docker Container Status ===" |
| 103 | + docker ps -a |
| 104 | +
|
| 105 | + echo -e "\n=== Container Logs for lucee7 ===" |
| 106 | + docker logs $(docker ps -aq -f "name=lucee7") 2>&1 | tail -50 || echo "Could not get logs" |
| 107 | +
|
| 108 | + echo -e "\n=== Container Logs for mysql ===" |
| 109 | + docker logs $(docker ps -aq -f "name=mysql") 2>&1 | tail -50 || echo "Could not get logs" |
| 110 | +
|
| 111 | + echo -e "\n=== Test Result File ===" |
| 112 | + if [ -f "/tmp/lucee7-mysql-result.txt" ]; then |
| 113 | + cat "/tmp/lucee7-mysql-result.txt" |
| 114 | + else |
| 115 | + echo "Result file not found" |
| 116 | + fi |
| 117 | +
|
| 118 | + - name: Upload Test Results |
| 119 | + if: always() |
| 120 | + uses: actions/upload-artifact@v4 |
| 121 | + with: |
| 122 | + name: test-results-lucee7-mysql |
| 123 | + path: /tmp/lucee7-mysql-result.txt |
0 commit comments