diff --git a/README.md b/README.md index 8f302c2f..17a1e38d 100644 --- a/README.md +++ b/README.md @@ -955,6 +955,7 @@ Examples of using `setup-php` with various PHP frameworks and packages. | CakePHP with `PostgreSQL` and `Redis` | `ubuntu` | [cakephp-postgres.yml](./examples/cakephp-postgres.yml "GitHub Action for CakePHP with Postgres and Redis") | | CakePHP without services | `macOS`, `ubuntu` and `windows` | [cakephp.yml](./examples/cakephp.yml "GitHub Action for CakePHP without services") | | CodeIgniter | `macOS`, `ubuntu` and `windows` | [codeigniter.yml](./examples/codeigniter.yml "GitHub Action for CodeIgniter") | +| Drupal 11 (Composer-managed) | `ubuntu` | [drupal.yml](./examples/drupal.yml "GitHub Action for Drupal 11 composer-managed projects") | | Laminas MVC | `macOS`, `ubuntu` and `windows` | [laminas-mvc.yml](./examples/laminas-mvc.yml "GitHub Action for Laminas Framework MVC Projects") | | Laravel with `MySQL` and `Redis` | `ubuntu` | [laravel-mysql.yml](./examples/laravel-mysql.yml "GitHub Action for Laravel with MySQL and Redis") | | Laravel with `PostgreSQL` and `Redis` | `ubuntu` | [laravel-postgres.yml](./examples/laravel-postgres.yml "GitHub Action for Laravel with PostgreSQL and Redis") | @@ -964,12 +965,13 @@ Examples of using `setup-php` with various PHP frameworks and packages. | Lumen without services | `macOS`, `ubuntu` and `windows` | [lumen.yml](./examples/lumen.yml "GitHub Action for Lumen without services") | | Phalcon with `MySQL` | `ubuntu` | [phalcon-mysql.yml](./examples/phalcon-mysql.yml "GitHub Action for Phalcon with MySQL") | | Phalcon with `PostgreSQL` | `ubuntu` | [phalcon-postgres.yml](./examples/phalcon-postgres.yml "GitHub Action for Phalcon with PostgreSQL") | -| Roots/bedrock | `ubuntu` | [bedrock.yml](./examples/bedrock.yml "GitHub Action for Wordpress Development using @roots/bedrock") | -| Roots/sage | `ubuntu` | [sage.yml](./examples/sage.yml "GitHub Action for Wordpress Development using @roots/sage") | | Slim Framework | `macOS`, `ubuntu` and `windows` | [slim-framework.yml](./examples/slim-framework.yml "GitHub Action for Slim Framework") | | Symfony with `MySQL` | `ubuntu` | [symfony-mysql.yml](./examples/symfony-mysql.yml "GitHub Action for Symfony with MySQL") | | Symfony with `PostgreSQL` | `ubuntu` | [symfony-postgres.yml](./examples/symfony-postgres.yml "GitHub Action for Symfony with PostgreSQL") | | Symfony without services | `macOS`, `ubuntu` and `windows` | [symfony.yml](./examples/symfony.yml "GitHub Action for Symfony without services") | +| WordPress plugin | `ubuntu` | [wordpress.yml](./examples/wordpress.yml "GitHub Action for WordPress plugins") | +| WordPress with Roots/Bedrock | `ubuntu` | [bedrock.yml](./examples/bedrock.yml "GitHub Action for WordPress development using @roots/bedrock") | +| WordPress with Roots/Sage | `ubuntu` | [sage.yml](./examples/sage.yml "GitHub Action for WordPress development using @roots/sage") | | Yii3 web application with `MySQL` | `ubuntu` | [yii3-mysql.yml](./examples/yii3-mysql.yml "GitHub Action for Yii3 web application with MySQL") | | Yii3 web application with `PostgreSQL` | `ubuntu` | [yii3-postgres.yml](./examples/yii3-postgres.yml "GitHub Action for Yii3 web application with PostgreSQL") | | Yii3 web application | `ubuntu` and `windows` | [yii3.yml](./examples/yii3.yml "GitHub Action for Yii3 web application") | diff --git a/examples/drupal.yml b/examples/drupal.yml new file mode 100644 index 00000000..ca2211d6 --- /dev/null +++ b/examples/drupal.yml @@ -0,0 +1,59 @@ +# GitHub Action for Drupal 11 composer-managed projects +# Requires drupal/core-dev in require-dev for vendor/bin/phpunit +name: Testing Drupal +on: [push, pull_request] +jobs: + drupal: + name: Drupal (PHP ${{ matrix.php-versions }}) + runs-on: ubuntu-latest + env: + SIMPLETEST_BASE_URL: http://127.0.0.1:8080 + SIMPLETEST_DB: sqlite://localhost/sites/default/files/.ht.sqlite + BROWSERTEST_OUTPUT_DIRECTORY: /tmp/browser_output + strategy: + fail-fast: false + matrix: + php-versions: ['8.3', '8.4', '8.5'] + steps: + - name: Checkout + uses: actions/checkout@v6 + + # Docs: https://github.com/shivammathur/setup-php + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: apcu, ctype, curl, dom, gd, iconv, intl, mbstring, pdo_sqlite, simplexml, xml, zip + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v5 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: | + if [ "${{ matrix.php-versions }}" = "8.3" ]; then + composer require --dev drupal/core-dev:11.2.10 doctrine/instantiator:^2.0.0 --no-interaction --no-update + composer update drupal/core-dev doctrine/instantiator --with-all-dependencies --no-interaction --no-progress --prefer-dist --optimize-autoloader + else + composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader + fi + + - name: Prepare Drupal test directories + run: mkdir -p web/sites/default/files "$BROWSERTEST_OUTPUT_DIRECTORY" + + - name: Start Drupal web server + run: php -S 127.0.0.1:8080 -t web >/tmp/php-server.log 2>&1 & + + - name: Test with phpunit + # Adjust the test path to match your custom modules or themes. + run: vendor/bin/phpunit -c web/core web/modules/custom diff --git a/examples/wordpress.yml b/examples/wordpress.yml new file mode 100644 index 00000000..4cdf4fd7 --- /dev/null +++ b/examples/wordpress.yml @@ -0,0 +1,68 @@ +# GitHub Action for WordPress plugins +# Tested with files scaffolded by wp scaffold plugin-tests --ci=github +# Requires phpunit/phpunit and yoast/phpunit-polyfills in require-dev for vendor/bin/phpunit +name: Testing WordPress +on: [push, pull_request] +jobs: + wordpress: + name: WordPress (PHP ${{ matrix.php-versions }}) + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php-versions: ['8.3', '8.4', '8.5'] + + # Docs: https://docs.github.com/en/actions/using-containerized-services + services: + mysql: + image: mysql:latest + env: + MYSQL_ALLOW_EMPTY_PASSWORD: false + MYSQL_ROOT_PASSWORD: root + MYSQL_DATABASE: wordpress_test + ports: + - 3306/tcp + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + steps: + - name: Checkout + uses: actions/checkout@v6 + + # Docs: https://github.com/shivammathur/setup-php + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, xml, zip, intl, mysql + coverage: none + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v5 + with: + path: ${{ steps.composer-cache.outputs.dir }} + # Use composer.json for key, if composer.lock is not committed. + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install system dependencies + run: sudo apt-get update && sudo apt-get install -y subversion default-mysql-client + + - name: Install Composer dependencies + run: | + if [ "${{ matrix.php-versions }}" = "8.3" ]; then + composer require --dev doctrine/instantiator:^2.0.0 --no-interaction --no-update + composer update doctrine/instantiator --with-all-dependencies --no-interaction --no-progress --prefer-dist --optimize-autoloader + else + composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader + fi + + - name: Install WordPress test environment + run: bash bin/install-wp-tests.sh wordpress_test root root 127.0.0.1:${{ job.services.mysql.ports['3306'] }} latest true + + - name: Test with phpunit + run: vendor/bin/phpunit