From 6c82605d22b33e4e8b66eec02159cc3c1ae50935 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 11:57:19 +0100 Subject: [PATCH 01/15] Add test coverage to ensure xdebug is not on --- .github/workflows/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fd8b1b..e645de3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,6 +23,9 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} + - name: Ensure Xdebug is not running + run: | + php -r "exit(extension_loaded('xdebug'));" - uses: actions/checkout@v2 - name: Setup Apache uses: ./ @@ -33,3 +36,6 @@ jobs: - name: Test fake site run: | curl -sSf http://127.0.0.1:9090 + - name: Ensure Xdebug is not running + run: | + php -r "exit(extension_loaded('xdebug'));" From 1a293f38e5b2ef82c88b561925656f6fc0ee3380 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:02:36 +0100 Subject: [PATCH 02/15] Add test coverage to ensure xdebug is not on pt 2 --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e645de3..6e08193 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,8 +23,10 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} + extensions: :redis, :pspell, Imagick - name: Ensure Xdebug is not running run: | + php -m php -r "exit(extension_loaded('xdebug'));" - uses: actions/checkout@v2 - name: Setup Apache @@ -38,4 +40,5 @@ jobs: curl -sSf http://127.0.0.1:9090 - name: Ensure Xdebug is not running run: | + php -m php -r "exit(extension_loaded('xdebug'));" From c6785d7f6135b452fbbe001f59aa5dce29948574 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:06:03 +0100 Subject: [PATCH 03/15] Disable Xdebug in shivammathur/setup-php@v2 --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6e08193..8488603 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -23,7 +23,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} - extensions: :redis, :pspell, Imagick + extensions: :redis, :pspell, :xdebug, Imagick - name: Ensure Xdebug is not running run: | php -m From c75448f20bad3e4e86cfc450df8e0978207d9ed8 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:25:31 +0100 Subject: [PATCH 04/15] Run on the same ubuntu version as thunder --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8488603..3a26c87 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: matrix: PHP_VERSION: [ '8.1', '8.3', '8.4' ] name: Test Apache action - runs-on: ubuntu-latest + runs-on: ubuntu-24.04 steps: - name: Create fake site run: | From 39ef29907e7aca4c8daf04d1bc005753f053dad4 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:29:43 +0100 Subject: [PATCH 05/15] Fix xdebug check --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3a26c87..c406a24 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Ensure Xdebug is not running run: | php -m - php -r "exit(extension_loaded('xdebug'));" + php -r "if (extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);" - uses: actions/checkout@v2 - name: Setup Apache uses: ./ @@ -41,4 +41,4 @@ jobs: - name: Ensure Xdebug is not running run: | php -m - php -r "exit(extension_loaded('xdebug'));" + php -r "if (extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);" From 35392328843763a409411b96d932f6075576dc8c Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:38:40 +0100 Subject: [PATCH 06/15] Use a matrix for runs-on --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c406a24..8566059 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: matrix: PHP_VERSION: [ '8.1', '8.3', '8.4' ] name: Test Apache action - runs-on: ubuntu-24.04 + runs-on: [ubuntu-latest, ubuntu-24.04] steps: - name: Create fake site run: | From 03d44e2b60d26822f833fb34fda198ab3e9dcafd Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:40:42 +0100 Subject: [PATCH 07/15] Use a matrix for runs-on pt 2 --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8566059..c1ed180 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,8 +9,9 @@ jobs: strategy: matrix: PHP_VERSION: [ '8.1', '8.3', '8.4' ] + OS: [ubuntu-latest, ubuntu-24.04] name: Test Apache action - runs-on: [ubuntu-latest, ubuntu-24.04] + runs-on: ${{ matrix.OS }} steps: - name: Create fake site run: | From fb659d15f6248326a8c8eeb94103ba11afd0c140 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:46:06 +0100 Subject: [PATCH 08/15] Fix xdebug being installed --- action.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/action.yml b/action.yml index 552cc8a..4239ca3 100644 --- a/action.yml +++ b/action.yml @@ -20,6 +20,7 @@ runs: run: | LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu sudo apt install libapache2-mod-php${{ inputs.php-version }} + sudo phpdismod xdebug || true sudo a2enmod php${{ inputs.php-version }} rewrite shell: bash - name: Configure the site under test From 867f66dcdaf78ebd6522239ba52e34eff6093e9d Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 12:58:24 +0100 Subject: [PATCH 09/15] Only disable if necessary and allow it to be installed --- action.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 4239ca3..14e3724 100644 --- a/action.yml +++ b/action.yml @@ -12,15 +12,18 @@ inputs: default: 8888\ # Install Apache and configure to serve the site under test. Apache is run # in the foreground using the same user as the test runner to avoid common -# pitfalls with file ownership. +# pitfalls with file ownership. This action also disables xdebug if it has +# resulted in it being installed. runs: using: "composite" steps: - name: Install Apache with mod_php run: | + WAS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu sudo apt install libapache2-mod-php${{ inputs.php-version }} - sudo phpdismod xdebug || true + IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` + if [ "$IS_XDEBUG_INSTALLED" == "1" && WAS_XDEBUG_INSTALLED == "" ]; then sudo phpdismod xdebug; fi; sudo a2enmod php${{ inputs.php-version }} rewrite shell: bash - name: Configure the site under test From 18cf4c9fb3f573e6ca92d0fcf16baa9a8a2b5625 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:00:25 +0100 Subject: [PATCH 10/15] Remove setup php conf --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ed180..743eb00 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} - extensions: :redis, :pspell, :xdebug, Imagick - name: Ensure Xdebug is not running run: | php -m From bce0add5f67490829726e1099a302c04fb24c92b Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:01:38 +0100 Subject: [PATCH 11/15] Whoops --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 14e3724..ff7eaff 100644 --- a/action.yml +++ b/action.yml @@ -23,7 +23,7 @@ runs: LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu sudo apt install libapache2-mod-php${{ inputs.php-version }} IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` - if [ "$IS_XDEBUG_INSTALLED" == "1" && WAS_XDEBUG_INSTALLED == "" ]; then sudo phpdismod xdebug; fi; + if [ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" == "" ]; then sudo phpdismod xdebug; fi; sudo a2enmod php${{ inputs.php-version }} rewrite shell: bash - name: Configure the site under test From 01b5e863533fd96db74528d2a875ea0a9f76b1e8 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:04:04 +0100 Subject: [PATCH 12/15] Disable xdebug --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 743eb00..8a94413 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} + extensions: :xdebug - name: Ensure Xdebug is not running run: | php -m From 7dc8c45634a561fd7f0c5c527b10b9d5739b1edd Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:08:09 +0100 Subject: [PATCH 13/15] More info and tests --- .github/workflows/test.yml | 34 ++++++++++++++++++++++++++++++++++ action.yml | 3 ++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8a94413..a9695fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,3 +43,37 @@ jobs: run: | php -m php -r "if (extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);" + test-with-xdebug: + name: Test Apache action + runs-on: ubuntu-latest + steps: + - name: Create fake site + run: | + mkdir /tmp/sut + echo '$text";' | sudo tee -a /tmp/sut/index.php + shell: bash + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.4 + extensions: xdebug + - name: Ensure Xdebug is running + run: | + php -m + php -r "if (!extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);" + - uses: actions/checkout@v2 + - name: Setup Apache + uses: ./ + with: + php-version: 8.4 + site-directory: /tmp/sut + http-port: 9090 + - name: Test fake site + run: | + curl -sSf http://127.0.0.1:9090 + - name: Ensure Xdebug is running + run: | + php -m + php -r "if (!extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);" diff --git a/action.yml b/action.yml index ff7eaff..d9ba64f 100644 --- a/action.yml +++ b/action.yml @@ -22,9 +22,10 @@ runs: WAS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu sudo apt install libapache2-mod-php${{ inputs.php-version }} + sudo a2enmod php${{ inputs.php-version }} rewrite IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` + echo "IS_XDEBUG_INSTALLED=$IS_XDEBUG_INSTALLED and WAS_XDEBUG_INSTALLED=$WAS_XDEBUG_INSTALLED" if [ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" == "" ]; then sudo phpdismod xdebug; fi; - sudo a2enmod php${{ inputs.php-version }} rewrite shell: bash - name: Configure the site under test run: | From 3bdc38d1749d806c3924185e38a1e252d60b83f6 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:11:31 +0100 Subject: [PATCH 14/15] Hate bash --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index d9ba64f..9966032 100644 --- a/action.yml +++ b/action.yml @@ -25,7 +25,7 @@ runs: sudo a2enmod php${{ inputs.php-version }} rewrite IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` echo "IS_XDEBUG_INSTALLED=$IS_XDEBUG_INSTALLED and WAS_XDEBUG_INSTALLED=$WAS_XDEBUG_INSTALLED" - if [ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" == "" ]; then sudo phpdismod xdebug; fi; + if [ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" != "1" ]; then sudo phpdismod xdebug; fi; shell: bash - name: Configure the site under test run: | From e1229ee89938a4a7b93abbe0ed34198444073287 Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Tue, 1 Jul 2025 13:15:48 +0100 Subject: [PATCH 15/15] Hate bash * 2 --- action.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 9966032..601b7bb 100644 --- a/action.yml +++ b/action.yml @@ -24,8 +24,10 @@ runs: sudo apt install libapache2-mod-php${{ inputs.php-version }} sudo a2enmod php${{ inputs.php-version }} rewrite IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` - echo "IS_XDEBUG_INSTALLED=$IS_XDEBUG_INSTALLED and WAS_XDEBUG_INSTALLED=$WAS_XDEBUG_INSTALLED" - if [ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" != "1" ]; then sudo phpdismod xdebug; fi; + if [[ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" != "1" ]]; then + echo "Disabling Xdebug" + sudo phpdismod xdebug + fi; shell: bash - name: Configure the site under test run: |