Skip to content

test.yml: Add logs if container fails to become healthy #288

test.yml: Add logs if container fails to become healthy

test.yml: Add logs if container fails to become healthy #288

Workflow file for this run

name: Run tests
on:
workflow_dispatch:
pull_request:
push:
jobs:
build-and-test:
runs-on: ubuntu-latest
permissions:
contents: read
env:
# Use the capxmock server to fake an api response
CAPX_URL: http://capx_mock:3030
CAPX_API_KEY: dummy
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Test image builds
run: |
docker compose -f compose.yml build
- name: Test container can start and is healthy
run: |
# Launch the project from docker-compose.yml and wait up to
# 30s for its built-in health check to return "healthy"
set -eu
if ! docker compose -f compose.yml -f compose.test.yml up --wait --wait-timeout 30; then
echo "Project failed to become healthy" >&2
echo "Logs:"
docker compose -f compose.yml -f compose.test.yml logs
exit 1
fi
docker compose -f compose.yml down
docker compose -f compose.yml run --entrypoint "" web pytest