From e916409ea94364fc7d86d2e03a6f58f0835e5232 Mon Sep 17 00:00:00 2001 From: kevin-studer Date: Thu, 2 May 2024 12:44:51 +0200 Subject: [PATCH 1/2] Automatic configuration of xdebug --- .github/workflows/test.yaml | 18 +++++++++++++++++- src/php/install.sh | 10 ++++++++++ test/php/install_php_version.sh | 13 +++++++++++++ test/php/install_php_xdebug.sh | 18 ++++++++++++++++++ test/php/scenarios.json | 18 ++++++++++++++++++ 5 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 test/php/install_php_version.sh create mode 100644 test/php/install_php_xdebug.sh create mode 100644 test/php/scenarios.json diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5661571..1b6843b 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -33,6 +33,22 @@ jobs: - name: "Generating tests for '${{ matrix.features }}' against '${{ matrix.baseImage }}'" run: devcontainer features test -f ${{ matrix.features }} -i ${{ matrix.baseImage }} . + test-scenarios: + runs-on: ubuntu-latest + continue-on-error: true + strategy: + matrix: + features: + - php + steps: + - uses: actions/checkout@v3 + + - name: "Install latest devcontainer CLI" + run: npm install -g @devcontainers/cli + + - name: "Testing '${{ matrix.features }}' scenarios" + run: devcontainer features test -f ${{ matrix.features }} --skip-autogenerated . + test-global: runs-on: ubuntu-latest continue-on-error: true @@ -43,4 +59,4 @@ jobs: run: npm install -g @devcontainers/cli - name: "Testing global scenarios" - run: devcontainer features test --global-scenarios-only . \ No newline at end of file + run: devcontainer features test --global-scenarios-only . diff --git a/src/php/install.sh b/src/php/install.sh index 9ab8bba..c4b7416 100644 --- a/src/php/install.sh +++ b/src/php/install.sh @@ -67,3 +67,13 @@ if [[ $INSTALLCOMPOSER == "true" ]]; then php composer-setup.php --install-dir=/usr/local/bin --filename=composer rm composer-setup.php fi + +if [[ "${MODULES[@]}" =~ "xdebug" ]]; then + XDEBUG_INI="/etc/php/${VERSION}/mods-available/xdebug.ini" + + echo "" >> "${XDEBUG_INI}" + echo "xdebug.mode = debug" >> "${XDEBUG_INI}" + echo "xdebug.start_with_request = yes" >> "${XDEBUG_INI}" + echo "xdebug.client_port = 9003" >> "${XDEBUG_INI}" +fi + diff --git a/test/php/install_php_version.sh b/test/php/install_php_version.sh new file mode 100644 index 0000000..33d25f8 --- /dev/null +++ b/test/php/install_php_version.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -e + +# Optional: Import test library +source dev-container-features-test-lib + +check "php-version-8-is-installed" bash -c "php --version | grep '8.0'" +check "php-fpm-version-8-is-installed" bash -c "php-fpm8.0 --version | grep '8.0'" +check "composer-version" composer --version + +# Report result +reportResults diff --git a/test/php/install_php_xdebug.sh b/test/php/install_php_xdebug.sh new file mode 100644 index 0000000..787f390 --- /dev/null +++ b/test/php/install_php_xdebug.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash + +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "php -v" php -v +check "php-fpm -v" php-fpm8.2 -v + +check "php-xdebug-extension" php -m | grep "xdebug" +check "php-xdebug-config" php -i | grep "xdebug.mode" | grep " => debug" + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults diff --git a/test/php/scenarios.json b/test/php/scenarios.json new file mode 100644 index 0000000..97572d4 --- /dev/null +++ b/test/php/scenarios.json @@ -0,0 +1,18 @@ +{ + "install_php_version": { + "image": "ubuntu:latest", + "features": { + "php": { + "version": "8.0" + } + } + }, + "install_php_xdebug": { + "image": "ubuntu:latest", + "features": { + "php": { + "extensionsExtra": "xdebug" + } + } + } +} From e22bf7a5b44ecd3977c48faaf3e924290413d8fb Mon Sep 17 00:00:00 2001 From: Shyim Date: Thu, 2 May 2024 13:00:17 +0200 Subject: [PATCH 2/2] fix: add ubuntu 24.04 support --- src/php/install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/php/install.sh b/src/php/install.sh index c4b7416..fce8ebe 100644 --- a/src/php/install.sh +++ b/src/php/install.sh @@ -35,9 +35,12 @@ if [[ "$OS" == '"Ubuntu"' ]]; then if [[ "$VERSION_CODENAME" == "focal" ]]; then echo "Detected: Ubuntu Focal (20.04)" echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu focal main" > /etc/apt/sources.list.d/ondrej-php.list - else + elif [[ "$VERSION_CODENAME" == "jammy" ]]; then echo "Detected: Ubuntu Jammy (22.04)" echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy main" > /etc/apt/sources.list.d/ondrej-php.list + else + echo "Detected: Ubuntu Noble (24.04)" + echo "deb https://ppa.launchpadcontent.net/ondrej/php/ubuntu noble main" > /etc/apt/sources.list.d/ondrej-php.list fi apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 4F4EA0AAE5267A6C