Skip to content

ci: add a basic smoke test check #46

ci: add a basic smoke test check

ci: add a basic smoke test check #46

name: Check the Docker image builds for a PR
on:
pull_request:
jobs:
lint_dockerfile:
name: Lint Dockerfile
runs-on: ubuntu-latest
steps:
-
name: Checkout github repository
uses: actions/checkout@v6
-
name: Lint Dockerfile with hadolint
uses: hadolint/hadolint-action@v3.3.0
with:
dockerfile: Dockerfile
check_build:
runs-on: ubuntu-latest
steps:
-
name: Checkout github repository
uses: actions/checkout@v6
-
name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
-
name: Set pull request build arguments
id: pr_meta
run: |
appGitRef=develop
appAddSha=true
echo "appGitRef=$appGitRef" >> "$GITHUB_OUTPUT"
echo "appAddSha=$appAddSha" >> "$GITHUB_OUTPUT"
-
name: Build Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
build-args: |
VERSION_PHP=8.4
VERSION_COMPOSER=lts
APP_GH_REF=${{ steps.pr_meta.outputs.appGitRef }}
APP_GH_ADD_SHA=${{ steps.pr_meta.outputs.appAddSha }}
tags: librebooking-pr:${{ github.sha }}
load: true
push: false
-
name: Smoke test image
run: |
set -euo pipefail
image_tag="librebooking-pr:${GITHUB_SHA}"
docker run --detach --name librebooking-smoke --publish 18080:8080 "${image_tag}"
for attempt in $(seq 1 30); do
if curl --silent --show-error --fail --max-time 2 http://127.0.0.1:18080/ >/dev/null; then
break
fi
if [ "${attempt}" = "30" ]; then
echo "Smoke test failed: HTTP endpoint did not become ready" >&2
docker logs librebooking-smoke || true
exit 1
fi
sleep 2
done
docker exec librebooking-smoke php -m | grep -E '^(gd|ldap|mysqli|timezonedb)$'
-
name: Dump smoke logs on failure
if: failure()
run: docker logs librebooking-smoke || true
-
name: Cleanup smoke container
if: always()
run: docker rm --force librebooking-smoke >/dev/null 2>&1 || true