Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 89 additions & 12 deletions .github/workflows/build_pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Check the Docker image builds for a PR

on:
workflow_dispatch:
pull_request:

jobs:
Expand All @@ -19,22 +20,31 @@ jobs:

check_build:
runs-on: ubuntu-latest
env:
APP_GH_REF: develop
APP_GH_ADD_SHA: "true"
services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: librebooking
MYSQL_USER: librebooking
MYSQL_PASSWORD: librebooking
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -proot"
--health-interval=10s
--health-timeout=5s
--health-retries=5
steps:
-
name: Checkout github repository
uses: actions/checkout@v6
-
name: Setup Docker buildx
uses: docker/setup-buildx-action@v4
-
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@v7
Expand All @@ -44,7 +54,74 @@ jobs:
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 }}
load: false
APP_GH_REF=${{ env.APP_GH_REF }}
APP_GH_ADD_SHA=${{ env.APP_GH_ADD_SHA }}
tags: librebooking-pr:${{ github.sha }}
load: true
push: false
-
name: Smoke test image
run: |
set -euo pipefail
lb_image_tag="librebooking-pr:${GITHUB_SHA}"
mysql_service_id="${{ job.services.mysql.id }}"

docker create --name librebooking-smoke-src "${lb_image_tag}" >/dev/null
docker cp librebooking-smoke-src:/var/www/html/database_schema /tmp/librebooking-database_schema
docker rm librebooking-smoke-src

cat \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given what you are testing, I am not sure you needto create the database

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without a database Librebooking will give an error message when trying to access it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This is odd.
When I run librebooking without any sql container, I don't have any issue.

robin@trixie-dev:~$ docker container ls
CONTAINER ID   IMAGE                COMMAND                  CREATED              STATUS              PORTS                                         NAMES
7179644bd62f   librebooking:4.2.0   "/usr/local/bin/entr…"   About a minute ago   Up About a minute   0.0.0.0:8080->8080/tcp, [::]:8080->8080/tcp   librebooking-app-1
robin@trixie-dev:~$ curl --silent --show-error --fail --max-time 2 http://localhost:8080
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://localhost:8080/Web/">here</a>.</p>
<hr>
<address>Apache/2.4.66 (Debian) Server at localhost Port 8080</address>
</body></html>

Please note that the URL is http://localhost:8080 when I run from my laptop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

But when you go to http://localhost:8080/Web/ it will give a 500 😢 if no SQL.

All that is testing is .htaccess is working.

/tmp/librebooking-database_schema/create-db.sql \
/tmp/librebooking-database_schema/create-schema.sql \
| docker exec --interactive "${mysql_service_id}" mysql --user root --password=root

docker run --rm \
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same remark as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Without a database Librebooking will give an error message when trying to access it.

--add-host host.docker.internal:host-gateway \
"${lb_image_tag}" \
php /var/www/html/phing-tasks/UpgradeDbTask.php \
librebooking \
librebooking \
host.docker.internal \
librebooking \
/var/www/html/database_schema

docker run --detach \
--name librebooking-smoke \
--add-host host.docker.internal:host-gateway \
--publish 18080:8080 \
--env LB_DATABASE_HOSTSPEC=host.docker.internal \
--env LB_DATABASE_NAME=librebooking \
--env LB_DATABASE_USER=librebooking \
--env LB_DATABASE_PASSWORD=librebooking \
"${lb_image_tag}"

for attempt in $(seq 1 30); do
if curl --silent --show-error --fail --max-time 2 http://127.0.0.1:18080/Web/; then
Copy link
Collaborator

@colisee colisee Mar 10, 2026

Choose a reason for hiding this comment

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

I would curl the /web/install URL path, instead.

In a future release, I would investigate the utilization of web page test automation tools, such as Playwright.

Please note that upstream could benefit from such tools.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Why is /Web/install better?

Playwright looks interesting. I would like a LOT more actual testing of the app in the upstream project.

echo "Connected to docker image successfully"
break
fi

if [ "${attempt}" = "30" ]; then
echo "Smoke test failed: HTTP endpoint did not become ready" >&2
docker logs librebooking-smoke || true
docker logs "${{ job.services.mysql.id }}" || true
exit 1
fi

sleep 2
done

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

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