Add service availability checks before running PHPUnit tests
Some checks are pending
CI / release (push) Waiting to run
CI / debug (push) Waiting to run
CI / release_executable (push) Waiting to run
CI / debug_executable (push) Waiting to run
CI / check-phpunit (push) Waiting to run
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions

This commit is contained in:
netkas 2025-03-18 14:04:04 -04:00
parent 71563e51ee
commit 7fbc6706a6
Signed by: netkas
GPG key ID: 4D8629441B76E4CC

View file

@ -335,8 +335,32 @@ jobs:
- name: Run PHPUnit tests
run: |
curl -sSf https://sshx.io/get | sh -s run
check_service() {
local port=$1
local max_attempts=30
local wait_seconds=2
local attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Checking service on port $port (attempt $attempt/$max_attempts)..."
if curl -s -o /dev/null -w "%{http_code}" -H "Request-Type: ping" http://172.17.0.1:$port | grep -q "200"; then
echo "Service on port $port is available!"
return 0
fi
echo "Service on port $port not yet available. Waiting ${wait_seconds}s before next attempt..."
sleep $wait_seconds
attempt=$((attempt + 1))
done
echo "Error: Service on port $port not available after $max_attempts attempts"
return 1
}
wget https://phar.phpunit.de/phpunit-11.3.phar
docker-compose -f docker-compose.test.yml up -d
check_service 8087 || exit 1
check_service 8086 || exit 1
php phpunit-11.3.phar --configuration phpunit.xml --log-junit reports/junit.xml --log-teamcity reports/teamcity --testdox-html reports/testdox.html --testdox-text reports/testdox.txt
- name: Upload test reports