Skip to content

ci: add a basic smoke test check#174

Draft
JohnVillalovos wants to merge 1 commit intomasterfrom
jlvillal/smoke
Draft

ci: add a basic smoke test check#174
JohnVillalovos wants to merge 1 commit intomasterfrom
jlvillal/smoke

Conversation

@JohnVillalovos
Copy link
Collaborator

This runs the docker image and attempts to connect to it.

Copilot AI review requested due to automatic review settings March 9, 2026 05:41
@JohnVillalovos JohnVillalovos marked this pull request as draft March 9, 2026 05:41
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a basic smoke test to the pull request CI workflow. After successfully building the Docker image, the new steps start the container, poll the HTTP endpoint until it's ready (up to 60 seconds), verify that four required PHP extensions are loaded, and clean up the container regardless of outcome. This complements the existing lint and build checks to give earlier signal that the produced image is functional.

Changes:

  • The build step now loads the image locally (changed from load: false to load: true) and assigns a tag so it can be referenced by later steps.
  • A "Smoke test image" step runs the container, polls the HTTP endpoint with retries, and checks that gd, ldap, mysqli, and timezonedb PHP modules are present.
  • "Dump smoke logs on failure" and "Cleanup smoke container" housekeeping steps are added.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

sleep 2
done

docker exec librebooking-smoke php -m | grep -E '^(gd|ldap|mysqli|timezonedb)$'
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The grep -E '^(gd|ldap|mysqli|timezonedb)$' command only checks that at least one of the four PHP modules appears in the output. grep exits 0 as long as any single match is found, so the check would pass even if three of the four modules are missing.

To verify that all four modules are present, the count of matching lines should be confirmed to equal 4. For example, pipe to wc -l and compare against 4, or run four separate grep commands (one per module), or use grep -c and verify the result equals 4.

Suggested change
docker exec librebooking-smoke php -m | grep -E '^(gd|ldap|mysqli|timezonedb)$'
modules_count="$(docker exec librebooking-smoke php -m | grep -E '^(gd|ldap|mysqli|timezonedb)$' | wc -l)"
if [ "${modules_count}" -ne 4 ]; then
echo "Smoke test failed: expected 4 required PHP modules (gd, ldap, mysqli, timezonedb), but found ${modules_count}" >&2
docker exec librebooking-smoke php -m || true
exit 1
fi

Copilot uses AI. Check for mistakes.

if [ "${attempt}" = "30" ]; then
echo "Smoke test failed: HTTP endpoint did not become ready" >&2
docker logs librebooking-smoke || true
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "Dump smoke logs on failure" step (lines 76–78) is redundant because the smoke test step already runs docker logs librebooking-smoke inline at line 67 before calling exit 1. Container logs will be printed twice in the failure case that the HTTP endpoint does not become ready. Consider removing the inline docker logs call at line 67 (inside the smoke test step) and relying solely on the dedicated "Dump smoke logs on failure" step, which will also catch failures from the docker exec … grep command at line 74.

Suggested change
docker logs librebooking-smoke || true

Copilot uses AI. Check for mistakes.
@JohnVillalovos JohnVillalovos force-pushed the jlvillal/smoke branch 5 times, most recently from fae5977 to 49ed359 Compare March 9, 2026 06:14
This runs the docker image and attempts to connect to it.
@JohnVillalovos JohnVillalovos marked this pull request as ready for review March 9, 2026 06:21
@JohnVillalovos JohnVillalovos requested a review from Copilot March 9, 2026 06:34
@JohnVillalovos JohnVillalovos marked this pull request as draft March 9, 2026 06:34
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

name: Cleanup smoke container
if: always()
run: |
docker rm --force librebooking-smoke >/dev/null 2>&1 || true
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The librebooking-smoke-src container (created on line 88) is only removed inline on line 90 within the smoke test step. If docker cp (line 89) or any subsequent command before line 90 fails — which is possible since set -euo pipefail is active — the script exits early and the container is never removed. The Cleanup smoke container step (lines 140–144) only removes librebooking-smoke and does not clean up librebooking-smoke-src. Consider adding docker rm --force librebooking-smoke-src to the cleanup step to handle this case.

Suggested change
docker rm --force librebooking-smoke >/dev/null 2>&1 || true
docker rm --force librebooking-smoke >/dev/null 2>&1 || true
docker rm --force librebooking-smoke-src >/dev/null 2>&1 || true

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +87
for attempt in $(seq 1 20); do
if docker exec "${mysql_service_id}" mysqladmin ping --host 127.0.0.1 --user root --password=root --silent; then
break
fi

if [ "${attempt}" = "20" ]; then
echo "Smoke test failed: MySQL did not become ready" >&2
docker logs "${mysql_service_id}" || true
exit 1
fi

sleep 2
done

Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check_build job already configures the MySQL service with health check options (--health-cmd, --health-interval, --health-timeout, --health-retries). In GitHub Actions, the runner waits for a service container's health check to pass before executing the job's steps. Therefore the manual MySQL readiness polling loop (lines 74–86) is redundant and can be removed.

Suggested change
for attempt in $(seq 1 20); do
if docker exec "${mysql_service_id}" mysqladmin ping --host 127.0.0.1 --user root --password=root --silent; then
break
fi
if [ "${attempt}" = "20" ]; then
echo "Smoke test failed: MySQL did not become ready" >&2
docker logs "${mysql_service_id}" || true
exit 1
fi
sleep 2
done

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently Copilot tells you that the waiting loop is useless...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants