diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6fd8b1b..a9695fc 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 + runs-on: ${{ matrix.OS }} steps: - name: Create fake site run: | @@ -23,6 +24,11 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.PHP_VERSION }} + extensions: :xdebug + - name: Ensure Xdebug is not 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: ./ @@ -33,3 +39,41 @@ jobs: - name: Test fake site run: | curl -sSf http://127.0.0.1:9090 + - name: Ensure Xdebug is not running + 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 552cc8a..601b7bb 100644 --- a/action.yml +++ b/action.yml @@ -12,15 +12,22 @@ 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 a2enmod php${{ inputs.php-version }} rewrite + IS_XDEBUG_INSTALLED=`php -r "echo extension_loaded('xdebug');"` + 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: |