From a7c0d4919dbd048bbe0e828627ce436b208078b3 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 25 Oct 2025 22:39:54 +0000 Subject: [PATCH 1/7] feat: Add GitHub Actions CI workflow Adds a GitHub Actions workflow to run tests on every push. The workflow uses the existing scripts in .github-offline to ensure consistency between the CI and offline testing environments. It tests against PHP versions 5.4, 5.5, and 7.0, and uses a MySQL 5.5 service. --- .github/workflows/ci.yml | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..71b2e18 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,41 @@ +name: CI + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['5.4', '5.5', '7.0'] + services: + mysql: + image: mysql:5.5 + env: + MYSQL_ROOT_PASSWORD: root + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + + - name: Install MySQL client + run: sudo apt-get install -y mysql-client + + - name: Setup database + run: | + mysql -h 127.0.0.1 -u root -proot -e "DROP DATABASE IF EXISTS addressbook;" + mysql -h 127.0.0.1 -u root -proot -e "CREATE DATABASE addressbook;" + mysql -h 127.0.0.1 -u root -proot addressbook < addressbook.sql + + - name: Configure database + run: cp .github-offline/db.config.php config/cfg.db.php + + - name: Run tests + run: php test/index.php From 09aac58eba1d1f5657f75711d0348627683e8bbd Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat, 25 Oct 2025 22:52:25 +0000 Subject: [PATCH 2/7] feat: Add GitHub Actions CI workflow Adds a GitHub Actions workflow to run tests on every push. The workflow uses the existing scripts in .github-offline to ensure consistency between the CI and offline testing environments. It tests against PHP versions 5.4, 5.5, and 7.0, and a matrix of MySQL and MariaDB databases. The workflow will continue even if one of the jobs in the matrix fails. --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 71b2e18..c3e3fd7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,12 +5,14 @@ on: [push] jobs: test: runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: php-versions: ['5.4', '5.5', '7.0'] + db-image: [mysql:5.5, mariadb:10.0, mariadb:10.1] services: mysql: - image: mysql:5.5 + image: ${{ matrix.db-image }} env: MYSQL_ROOT_PASSWORD: root ports: From 980f4b622753f78b45d06d58937c933ddbf20053 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 07:00:32 +0000 Subject: [PATCH 3/7] fix(ci): Add apt-get update to fix dependency issues Adds a step to run `sudo apt-get update` before installing the mysql-client package. This is necessary to synchronize the package lists and prevent unmet dependency errors that were causing the build to fail. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c3e3fd7..ffa6ee0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: with: php-version: ${{ matrix.php-versions }} + - name: Update apt-get + run: sudo apt-get update + - name: Install MySQL client run: sudo apt-get install -y mysql-client From 9665adb1332bfee1262a77763ed4b83354a3018a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 07:26:08 +0000 Subject: [PATCH 4/7] fix(ci): Add a step to fix broken dependencies Adds a step to run `sudo apt-get install -f -y` after setting up PHP. This command is necessary to resolve dependency conflicts that can arise from the package repositories added for older PHP versions. This should fix the recurring `E: Unmet dependencies` error. --- .github/workflows/ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffa6ee0..eae1e6b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,6 +27,9 @@ jobs: with: php-version: ${{ matrix.php-versions }} + - name: Fix broken dependencies + run: sudo apt-get install -f -y + - name: Update apt-get run: sudo apt-get update From cb4cb73dfa1d7817e23ab3dea3abcaa443005d19 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 08:19:28 +0000 Subject: [PATCH 5/7] fix(ci): Execute tests via web server This commit fixes the test execution by running the tests in a proper web context. Previously, the tests were run via the PHP CLI, which caused errors because the `$_SERVER` variables were not being set. This has been resolved by: 1. Starting a PHP built-in web server in the background. 2. Using `curl` to make an HTTP request to the `test/index.php` script. 3. Parsing the output of `curl` to determine if the tests passed or failed. 4. Adding a step to stop the web server after the tests are complete. This approach correctly simulates a web environment, allowing the tests to run as intended. --- .github/workflows/ci.yml | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index eae1e6b..c2d3ba9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,5 +45,24 @@ jobs: - name: Configure database run: cp .github-offline/db.config.php config/cfg.db.php + - name: Start PHP web server + run: php -S localhost:8000 -t . & + - name: Run tests - run: php test/index.php + run: | + sleep 3 # Give server time to start + # Fetch the test page, show output, and fail if "FAILURES!!!" is present. + curl -s --fail http://localhost:8000/test/index.php | tee /tmp/test_output.txt + if ! grep -q "Passes:" /tmp/test_output.txt; then + echo "::error::Test output did not contain 'Passes:'. The test runner likely failed." + exit 1 + fi + if grep -q "FAILURES!!!" /tmp/test_output.txt; then + echo "::error::Test suite reported failures." + exit 1 + fi + echo "All tests passed!" + + - name: Stop PHP web server + if: always() + run: pkill -f "php -S localhost:8000" || true From 0fcc38a7313dabb2c2c697ad8a6642bb90a7e2f9 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:08:09 +0000 Subject: [PATCH 6/7] fix(ci): Run web server on port 80 This commit fixes the "Connection refused" errors by running the PHP built-in web server on port 80, which is the port the test suite expects. This required the following changes: 1. Using `sudo` to start the web server on the privileged port 80. 2. Updating the `curl` command to target `http://localhost/test/index.php`. 3. Using `sudo pkill` to stop the server process. This change aligns the test environment with the test suite's expectations and should allow the tests to pass. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c2d3ba9..e4fafcc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,13 +46,13 @@ jobs: run: cp .github-offline/db.config.php config/cfg.db.php - name: Start PHP web server - run: php -S localhost:8000 -t . & + run: sudo php -S localhost:80 -t . & - name: Run tests run: | sleep 3 # Give server time to start # Fetch the test page, show output, and fail if "FAILURES!!!" is present. - curl -s --fail http://localhost:8000/test/index.php | tee /tmp/test_output.txt + curl -s --fail http://localhost/test/index.php | tee /tmp/test_output.txt if ! grep -q "Passes:" /tmp/test_output.txt; then echo "::error::Test output did not contain 'Passes:'. The test runner likely failed." exit 1 @@ -65,4 +65,4 @@ jobs: - name: Stop PHP web server if: always() - run: pkill -f "php -S localhost:8000" || true + run: sudo pkill -f "php -S localhost:80" || true From f7a491738f9b7338c889373701a83bea24294ea5 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sun, 26 Oct 2025 17:56:16 +0000 Subject: [PATCH 7/7] feat: Add GitHub Actions CI workflow This commit introduces a comprehensive GitHub Actions workflow that automates the testing of the application. The workflow is triggered on every push and runs a matrix of tests against PHP versions 5.4, 5.5, and 7.0, as well as against MySQL 5.5, MariaDB 10.0, and MariaDB 10.1. This implementation correctly replicates the logic from the offline regression testing script by: 1. Starting a PHP built-in web server in the background. 2. Executing the test script via the PHP CLI. 3. Passing the `SERVER_NAME` and `REQUEST_URI` as environment variables, which the SimpleTest framework uses to make HTTP requests to the running server. 4. Parsing the output to determine the success or failure of the tests. This approach resolves all previous build failures, including package dependency issues and test execution errors. --- .github/workflows/ci.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e4fafcc..b1bb148 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,23 +46,27 @@ jobs: run: cp .github-offline/db.config.php config/cfg.db.php - name: Start PHP web server - run: sudo php -S localhost:80 -t . & + run: php -S localhost:8000 -t . & - name: Run tests + env: + SERVER_NAME: "localhost:8000" + REQUEST_URI: "/index.php" run: | - sleep 3 # Give server time to start - # Fetch the test page, show output, and fail if "FAILURES!!!" is present. - curl -s --fail http://localhost/test/index.php | tee /tmp/test_output.txt + sleep 2 + php test/index.php | tee /tmp/test_output.txt + # Fail the job if the test runner didn't report success if ! grep -q "Passes:" /tmp/test_output.txt; then - echo "::error::Test output did not contain 'Passes:'. The test runner likely failed." - exit 1 + echo "::error::Test runner did not complete successfully." + exit 1 fi + # Fail the job if the test suite reported failures if grep -q "FAILURES!!!" /tmp/test_output.txt; then - echo "::error::Test suite reported failures." - exit 1 + echo "::error::Test suite reported failures." + exit 1 fi echo "All tests passed!" - name: Stop PHP web server if: always() - run: sudo pkill -f "php -S localhost:80" || true + run: pkill -f "php -S localhost:8000" || true