Enhance Docker setup in workflow with CLI installation and service readiness checks
Some checks are pending
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
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 / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
Some checks are pending
CI / check-phpdoc (push) Waiting to run
CI / generate-phpdoc (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
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 / release-documentation (push) Blocked by required conditions
CI / release-artifacts (push) Blocked by required conditions
This commit is contained in:
parent
be49c55196
commit
1384aee3b3
1 changed files with 22 additions and 81 deletions
103
.github/workflows/ncc_workflow.yml
vendored
103
.github/workflows/ncc_workflow.yml
vendored
|
@ -279,6 +279,9 @@ jobs:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: php:8.3
|
image: php:8.3
|
||||||
|
volumes:
|
||||||
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
|
options: --network host
|
||||||
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
|
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -294,11 +297,22 @@ jobs:
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
apt update -yqq
|
apt update -yqq
|
||||||
apt install git libpq-dev libzip-dev zip make wget gnupg curl docker.io docker-compose -yqq
|
apt install git libpq-dev libzip-dev zip make wget gnupg -yqq
|
||||||
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
|
curl -sSLf -o /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions
|
||||||
chmod +x /usr/local/bin/install-php-extensions
|
chmod +x /usr/local/bin/install-php-extensions
|
||||||
install-php-extensions zip
|
install-php-extensions zip
|
||||||
|
|
||||||
|
- name: Install Docker CLI and Docker Compose
|
||||||
|
run: |
|
||||||
|
apt-get update -yqq
|
||||||
|
apt-get install -y ca-certificates curl gnupg
|
||||||
|
install -m 0755 -d /etc/apt/keyrings
|
||||||
|
curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
|
||||||
|
chmod a+r /etc/apt/keyrings/docker.gpg
|
||||||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||||||
|
apt-get update -yqq
|
||||||
|
apt-get install -y docker-ce-cli docker-compose-plugin
|
||||||
|
|
||||||
- name: Install phive
|
- name: Install phive
|
||||||
run: |
|
run: |
|
||||||
wget -O phive.phar https://phar.io/releases/phive.phar
|
wget -O phive.phar https://phar.io/releases/phive.phar
|
||||||
|
@ -329,100 +343,27 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
ncc package install --package="release/net.nosial.socialbox.ncc" --build-source --reinstall -y --log-level debug
|
ncc package install --package="release/net.nosial.socialbox.ncc" --build-source --reinstall -y --log-level debug
|
||||||
|
|
||||||
- name: Deploy test environment
|
- name: Start Docker services
|
||||||
|
run: docker compose -f docker-compose.test.yml up -d
|
||||||
|
|
||||||
|
- name: Wait for services to be ready
|
||||||
run: |
|
run: |
|
||||||
# Create logs directory
|
until curl -f -H "Request-Type: ping" http://localhost:8085/ && curl -f -H "Request-Type: ping" http://localhost:8086/; do
|
||||||
mkdir -p docker-logs
|
echo "Waiting for services to become available..."
|
||||||
|
sleep 1
|
||||||
# Start Docker Compose in detached mode
|
|
||||||
echo "Starting Docker Compose services..."
|
|
||||||
docker-compose -f docker-compose.test.yml up -d
|
|
||||||
|
|
||||||
# Save container IDs for later log extraction
|
|
||||||
CONTAINER_IDS=$(docker-compose -f docker-compose.test.yml ps -q)
|
|
||||||
echo "Started containers: $CONTAINER_IDS"
|
|
||||||
|
|
||||||
- name: Wait for services to be available
|
|
||||||
run: |
|
|
||||||
# Function to check if a service is available
|
|
||||||
check_service() {
|
|
||||||
local url=$1
|
|
||||||
local max_attempts=200
|
|
||||||
local wait_seconds=5
|
|
||||||
local attempt=1
|
|
||||||
|
|
||||||
echo "Checking availability of $url"
|
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
|
||||||
response=$(curl -s -o /dev/null -w "%{http_code}" -f -H "Request-Type: ping" $url || echo "failed")
|
|
||||||
|
|
||||||
if [ "$response" = "200" ]; then
|
|
||||||
echo "Service at $url is available!"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Attempt $attempt/$max_attempts: Service at $url is not available yet (status: $response). Waiting $wait_seconds seconds..."
|
|
||||||
sleep $wait_seconds
|
|
||||||
attempt=$((attempt + 1))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Service at $url is not available after $max_attempts attempts."
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check both services
|
|
||||||
check_service "http://127.0.0.1:8085/" && check_service "http://127.0.0.1:8086/"
|
|
||||||
|
|
||||||
- name: Start log streaming in background
|
|
||||||
run: |
|
|
||||||
# Start a background process to stream logs to a file
|
|
||||||
docker-compose -f docker-compose.test.yml logs -f > docker-logs/live-logs.txt 2>&1 &
|
|
||||||
echo $! > .docker-logs-pid
|
|
||||||
|
|
||||||
# Also save current logs to a separate file
|
|
||||||
docker-compose -f docker-compose.test.yml logs > docker-logs/startup-logs.txt 2>&1
|
|
||||||
|
|
||||||
- name: Run PHPUnit tests
|
- name: Run PHPUnit tests
|
||||||
run: |
|
run: |
|
||||||
wget https://phar.phpunit.de/phpunit-11.3.phar
|
wget https://phar.phpunit.de/phpunit-11.3.phar
|
||||||
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
|
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: Capture final logs
|
|
||||||
if: always()
|
|
||||||
run: |
|
|
||||||
# Stop the background log process if it's running
|
|
||||||
if [ -f .docker-logs-pid ]; then
|
|
||||||
kill $(cat .docker-logs-pid) || true
|
|
||||||
rm .docker-logs-pid
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Capture one final set of logs
|
|
||||||
docker-compose -f docker-compose.test.yml logs > docker-logs/final-logs.txt 2>&1
|
|
||||||
|
|
||||||
# Get individual container logs as well (with timestamps)
|
|
||||||
for container in $(docker-compose -f docker-compose.test.yml ps -q); do
|
|
||||||
container_name=$(docker inspect --format='{{.Name}}' $container | sed 's/^\///')
|
|
||||||
docker logs --timestamps $container > "docker-logs/$container_name.log" 2>&1
|
|
||||||
done
|
|
||||||
|
|
||||||
- name: Stop test environment
|
|
||||||
run: |
|
|
||||||
docker-compose -f docker-compose.test.yml down
|
|
||||||
if: always() # Always run this step, even if previous steps fail
|
|
||||||
|
|
||||||
- name: Upload test reports
|
- name: Upload test reports
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: reports
|
name: reports
|
||||||
path: reports
|
path: reports
|
||||||
|
|
||||||
- name: Upload Docker logs
|
|
||||||
uses: actions/upload-artifact@v4
|
|
||||||
with:
|
|
||||||
name: docker-logs
|
|
||||||
path: docker-logs
|
|
||||||
if: always() # Always upload logs, even if tests fail
|
|
||||||
|
|
||||||
|
|
||||||
release-documentation:
|
release-documentation:
|
||||||
needs: generate-phpdoc
|
needs: generate-phpdoc
|
||||||
|
|
Loading…
Add table
Reference in a new issue