Skip to content

Commit d6c7c04

Browse files
authored
Ensure Xdebug is not enabled by this action (#7)
1 parent 43c4292 commit d6c7c04

2 files changed

Lines changed: 53 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ jobs:
99
strategy:
1010
matrix:
1111
PHP_VERSION: [ '8.1', '8.3', '8.4' ]
12+
OS: [ubuntu-latest, ubuntu-24.04]
1213
name: Test Apache action
13-
runs-on: ubuntu-latest
14+
runs-on: ${{ matrix.OS }}
1415
steps:
1516
- name: Create fake site
1617
run: |
@@ -23,6 +24,11 @@ jobs:
2324
uses: shivammathur/setup-php@v2
2425
with:
2526
php-version: ${{ matrix.PHP_VERSION }}
27+
extensions: :xdebug
28+
- name: Ensure Xdebug is not running
29+
run: |
30+
php -m
31+
php -r "if (extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);"
2632
- uses: actions/checkout@v2
2733
- name: Setup Apache
2834
uses: ./
@@ -33,3 +39,41 @@ jobs:
3339
- name: Test fake site
3440
run: |
3541
curl -sSf http://127.0.0.1:9090
42+
- name: Ensure Xdebug is not running
43+
run: |
44+
php -m
45+
php -r "if (extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);"
46+
test-with-xdebug:
47+
name: Test Apache action
48+
runs-on: ubuntu-latest
49+
steps:
50+
- name: Create fake site
51+
run: |
52+
mkdir /tmp/sut
53+
echo '<?php' | sudo tee /tmp/sut/index.php
54+
echo ' $text = "It works!";' | sudo tee -a /tmp/sut/index.php
55+
echo ' print "<strong>$text</strong>";' | sudo tee -a /tmp/sut/index.php
56+
shell: bash
57+
- name: Setup PHP
58+
uses: shivammathur/setup-php@v2
59+
with:
60+
php-version: 8.4
61+
extensions: xdebug
62+
- name: Ensure Xdebug is running
63+
run: |
64+
php -m
65+
php -r "if (!extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);"
66+
- uses: actions/checkout@v2
67+
- name: Setup Apache
68+
uses: ./
69+
with:
70+
php-version: 8.4
71+
site-directory: /tmp/sut
72+
http-port: 9090
73+
- name: Test fake site
74+
run: |
75+
curl -sSf http://127.0.0.1:9090
76+
- name: Ensure Xdebug is running
77+
run: |
78+
php -m
79+
php -r "if (!extension_loaded('xdebug')) trigger_error('xdebug on', E_USER_ERROR);"

action.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,22 @@ inputs:
1212
default: 8888\
1313
# Install Apache and configure to serve the site under test. Apache is run
1414
# in the foreground using the same user as the test runner to avoid common
15-
# pitfalls with file ownership.
15+
# pitfalls with file ownership. This action also disables xdebug if it has
16+
# resulted in it being installed.
1617
runs:
1718
using: "composite"
1819
steps:
1920
- name: Install Apache with mod_php
2021
run: |
22+
WAS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"`
2123
LC_ALL=C.UTF-8 sudo apt-add-repository http://ppa.launchpad.net/ondrej/php/ubuntu
2224
sudo apt install libapache2-mod-php${{ inputs.php-version }}
2325
sudo a2enmod php${{ inputs.php-version }} rewrite
26+
IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"`
27+
if [[ "$IS_XDEBUG_INSTALLED" == "1" && "$WAS_XDEBUG_INSTALLED" != "1" ]]; then
28+
echo "Disabling Xdebug"
29+
sudo phpdismod xdebug
30+
fi;
2431
shell: bash
2532
- name: Configure the site under test
2633
run: |

0 commit comments

Comments
 (0)