Refactor ncc_workflow.yml to prepare for volume mounting and update docker-compose file with absolute paths
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
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:
parent
92a981904e
commit
cdb28f841f
1 changed files with 64 additions and 28 deletions
92
.github/workflows/ncc_workflow.yml
vendored
92
.github/workflows/ncc_workflow.yml
vendored
|
@ -281,7 +281,6 @@ jobs:
|
||||||
image: php:8.3
|
image: php:8.3
|
||||||
volumes:
|
volumes:
|
||||||
- /var/run/docker.sock:/var/run/docker.sock
|
- /var/run/docker.sock:/var/run/docker.sock
|
||||||
- ./tests/docker:/tests/docker
|
|
||||||
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
|
if: needs.check-phpunit.outputs.phpunit-exists == 'true'
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
@ -336,57 +335,94 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
docker-compose -f docker-compose.test.yml build
|
docker-compose -f docker-compose.test.yml build
|
||||||
|
|
||||||
- name: Run PHPUnit tests
|
- name: Prepare for volume mounting
|
||||||
|
run: |
|
||||||
|
# Define workspace path as current directory
|
||||||
|
WORKSPACE_PATH=$(pwd)
|
||||||
|
echo "Using workspace path: $WORKSPACE_PATH"
|
||||||
|
|
||||||
|
# Ensure directories exist and have appropriate permissions
|
||||||
|
mkdir -p tests/docker/coffee/logs tests/docker/teapot/logs
|
||||||
|
chmod -R 777 tests/docker
|
||||||
|
|
||||||
|
# Create a new docker-compose file with absolute paths
|
||||||
|
cat docker-compose.test.yml | sed "s|- \./tests/docker/|- $WORKSPACE_PATH/tests/docker/|g" > docker-compose.test.absolute.yml
|
||||||
|
|
||||||
|
# Debug output to verify the changes
|
||||||
|
echo "Original volume path entries:"
|
||||||
|
grep -A 2 "volumes:" docker-compose.test.yml | head -10
|
||||||
|
|
||||||
|
echo "Updated volume path entries with absolute paths:"
|
||||||
|
grep -A 2 "volumes:" docker-compose.test.absolute.yml | head -10
|
||||||
|
|
||||||
|
# Use the updated docker-compose file
|
||||||
|
cp docker-compose.test.absolute.yml docker-compose.test.yml
|
||||||
|
|
||||||
|
# Debug: Show docker info and current directory structure
|
||||||
|
docker info
|
||||||
|
ls -la
|
||||||
|
ls -la tests/docker/
|
||||||
|
|
||||||
|
- name: Start Docker services with host networking
|
||||||
|
run: |
|
||||||
|
# Start services with host networking
|
||||||
|
docker-compose -f docker-compose.test.yml up -d
|
||||||
|
env:
|
||||||
|
COMPOSE_DOCKER_CLI_BUILD: 1
|
||||||
|
DOCKER_BUILDKIT: 1
|
||||||
|
DOCKER_HOST: "unix:///var/run/docker.sock"
|
||||||
|
|
||||||
|
- name: Verify container logs and mounts
|
||||||
|
run: |
|
||||||
|
# List running containers
|
||||||
|
docker ps
|
||||||
|
|
||||||
|
# Check if services are running properly
|
||||||
|
docker-compose -f docker-compose.test.yml logs
|
||||||
|
|
||||||
|
# Verify the volumes are mounted correctly
|
||||||
|
for container in $(docker-compose -f docker-compose.test.yml ps -q); do
|
||||||
|
echo "Inspecting container $container:"
|
||||||
|
docker inspect -f '{{ .Mounts }}' $container
|
||||||
|
done
|
||||||
|
|
||||||
|
- name: Wait for services to be ready
|
||||||
run: |
|
run: |
|
||||||
check_service() {
|
check_service() {
|
||||||
local port=$1
|
local port=$1
|
||||||
local max_attempts=30
|
local max_attempts=30
|
||||||
local wait_seconds=2
|
local wait_seconds=2
|
||||||
local attempt=1
|
local attempt=1
|
||||||
|
|
||||||
while [ $attempt -le $max_attempts ]; do
|
while [ $attempt -le $max_attempts ]; do
|
||||||
echo "Checking service on port $port (attempt $attempt/$max_attempts)..."
|
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
|
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!"
|
echo "Service on port $port is available!"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Service on port $port not yet available. Waiting ${wait_seconds}s before next attempt..."
|
echo "Service on port $port not yet available. Waiting ${wait_seconds}s before next attempt..."
|
||||||
sleep $wait_seconds
|
sleep $wait_seconds
|
||||||
attempt=$((attempt + 1))
|
attempt=$((attempt + 1))
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "Error: Service on port $port not available after $max_attempts attempts"
|
echo "Error: Service on port $port not available after $max_attempts attempts"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Prepare the environment
|
|
||||||
chmod -R 777 tests/docker
|
|
||||||
|
|
||||||
# Create a new docker-compose file with absolute paths
|
|
||||||
cat docker-compose.test.yml | sed "s|- \./tests/docker/|- $WORKSPACE_PATH/tests/docker/|g" > docker-compose.test.updated.yml
|
|
||||||
|
|
||||||
# Verify the changes
|
|
||||||
echo "Original volume path entries:"
|
|
||||||
grep -A 2 "volumes:" docker-compose.test.yml | head -10
|
|
||||||
|
|
||||||
echo "Updated volume path entries:"
|
|
||||||
grep -A 2 "volumes:" docker-compose.test.updated.yml | head -10
|
|
||||||
|
|
||||||
# Use the updated docker-compose file for subsequent steps
|
|
||||||
cp docker-compose.test.updated.yml docker-compose.test.yml
|
|
||||||
|
|
||||||
# Prepare phpunit
|
|
||||||
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 8087 || exit 1
|
||||||
check_service 8086 || exit 1
|
check_service 8086 || exit 1
|
||||||
|
|
||||||
|
- name: Run PHPUnit tests
|
||||||
|
run: |
|
||||||
|
# Prepare phpunit
|
||||||
|
wget https://phar.phpunit.de/phpunit-11.3.phar
|
||||||
|
|
||||||
# Testing point
|
# Run the tests
|
||||||
curl -sSf https://sshx.io/get | sh -s run
|
|
||||||
|
|
||||||
# Run the tests and tare down the test environment
|
|
||||||
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: Teardown test environment
|
||||||
|
run: |
|
||||||
docker-compose -f docker-compose.test.yml down
|
docker-compose -f docker-compose.test.yml down
|
||||||
|
|
||||||
- name: Upload test reports
|
- name: Upload test reports
|
||||||
|
|
Loading…
Add table
Reference in a new issue