diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..669bb18ef4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,73 @@ +name: CI + +on: [push] + +env: + COMPOSER_MEMORY_LIMIT: -1 + SIMPLETEST_DB: sqlite://tmp/site.sqlite + SIMPLETEST_BASE_URL: "http://127.0.0.1:8080" + +jobs: + build: + runs-on: 'ubuntu-20.04' + strategy: + fail-fast: false + matrix: + php-versions: ['7.4', '8.1'] + drupal-release: ['stable'] + composer-channel: ['stable'] + include: + - php-versions: '8.1' + drupal-release: dev + composer-channel: stable + - php-versions: '8.1' + drupal-release: stable + composer-channel: snapshot + steps: + - name: Dump matrix context + env: + MATRIX_CONTEXT: ${{ toJSON(matrix) }} + run: echo "$MATRIX_CONTEXT" + + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: gd, pdo_sqlite + + - name: Update composer + run: composer --verbose self-update --${{ matrix.composer-channel }} + + - name: Dump composer version + run: composer --version + + - name: Validate composer.json + run: composer --verbose validate + + - name: Install dependencies + run: composer --verbose install + + - if: matrix.drupal-release == 'dev' + run: composer --verbose require --no-update drupal/core-recommended:9.4.x-dev && composer --verbose require --no-update --dev drupal/core-dev:9.4.x-dev + + - if: matrix.drupal-release == 'dev' + run: composer --verbose update + + - run: ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite + + - run: ./vendor/bin/drush runserver $SIMPLETEST_BASE_URL & + + - run: until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null + + # https://www.drupal.org/project/drupal/issues/3182653 + # https://www.drupal.org/node/3176567 + - if: ${{ matrix.php-versions == '7.4' }} || ${{ matrix.php-versions == '8.1' }} + run: composer require phpspec/prophecy-phpunit:^2 + + - name: Run a single unit test to verfiy the testing setup. + run: ./vendor/bin/phpunit -c ./web/core ./web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php + + - run: ./vendor/bin/drush diff --git a/.gitignore b/.gitignore index 50d278d8f4..12ad63d871 100644 --- a/.gitignore +++ b/.gitignore @@ -14,11 +14,12 @@ # Ignore Drupal's file directory /web/sites/*/files/ -# Ignore SimpleTest multi-site environment. +# Ignore SimpleTest multi-site environment /web/sites/simpletest -# Ignore files generated by PhpStorm +# Ignore files generated by common IDEs /.idea/ +/.vscode/ # Ignore .env files as they are personal /.env diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8f94fc41c5..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php -dist: bionic -sudo: false - -php: - - 7.3 - - 7.4 - -env: - global: - - COMPOSER_MEMORY_LIMIT=-1 - - SIMPLETEST_DB=sqlite://tmp/site.sqlite - - SIMPLETEST_BASE_URL="http://127.0.0.1:8080" - matrix: - - RELEASE=stable COMPOSER_CHANNEL=stable - - RELEASE=dev COMPOSER_CHANNEL=stable - - RELEASE=stable COMPOSER_CHANNEL=snapshot - -before_install: - # https://www.drupal.org/project/drupal/issues/3107155 - - sudo echo "deb http://archive.ubuntu.com/ubuntu focal main restricted universe multiverse" >> /etc/apt/sources.list - - sudo apt-get update - - sudo apt-get -y install sqlite3/focal - - echo 'sendmail_path = /bin/true' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - - phpenv config-rm xdebug.ini - - composer --verbose self-update --$COMPOSER_CHANNEL - - composer --version - -install: - - composer --verbose validate - - composer --verbose install - -script: - - if [[ $RELEASE = dev ]]; then composer --verbose require --no-update drupal/core-recommended:9.0.x-dev; composer --verbose require --no-update --dev drupal/core-dev:9.0.x-dev; fi; - - if [[ $RELEASE = dev ]]; then composer --verbose update; fi; - - ./vendor/bin/drush site-install --verbose --yes --db-url=sqlite://tmp/site.sqlite - - ./vendor/bin/drush runserver $SIMPLETEST_BASE_URL & - - until curl -s $SIMPLETEST_BASE_URL; do true; done > /dev/null - # Run a single unit test to verfiy the testing setup. - - ./vendor/bin/phpunit -c ./web/core ./web/core/modules/user/tests/src/Unit/UserAccessControlHandlerTest.php - - ./vendor/bin/drush diff --git a/README.md b/README.md index 3dd7d5f853..2425542697 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Composer template for Drupal projects -[![Build Status](https://travis-ci.org/drupal-composer/drupal-project.svg?branch=9.x)](https://travis-ci.org/drupal-composer/drupal-project) +[![CI](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml/badge.svg?branch=9.x)](https://github.com/drupal-composer/drupal-project/actions/workflows/ci.yml) This project template provides a starter kit for managing your site dependencies with [Composer](https://getcomposer.org/). @@ -58,7 +58,7 @@ new release of Drupal core. Follow the steps below to update your core files. -1. Run `composer update drupal/core-recommended drupal/core-dev --with-dependencies` to update Drupal Core and its dependencies. +1. Run `composer update "drupal/core-*" --with-dependencies` to update Drupal Core and its dependencies. 2. Run `git diff` to determine if any of the scaffolding files have changed. Review the files for any changes and restore any customizations to `.htaccess` or `robots.txt`. @@ -123,7 +123,7 @@ section of composer.json: ### How do I specify a PHP version ? -This project supports PHP 7.3 as minimum version (see [Environment requirements of Drupal 9](https://www.drupal.org/docs/understanding-drupal/how-drupal-9-was-made-and-what-is-included/environment-requirements-of)), however it's possible that a `composer update` will upgrade some package that will then require PHP 7.3+. +This project supports PHP 7.4 as minimum version (see Drupal 9.4 [PHP requirements](https://www.drupal.org/docs/system-requirements/php-requirements#versions)) and [Drop official PHP 7.3 support in Drupal 9.4](https://www.drupal.org/project/drupal/issues/2917655), however it's possible that a `composer update` will upgrade some package that will then require PHP 7.4+. To prevent this you can add this code to specify the PHP version you want to use in the `config` section of `composer.json`: @@ -131,7 +131,7 @@ To prevent this you can add this code to specify the PHP version you want to use "config": { "sort-packages": true, "platform": { - "php": "7.3.19" + "php": "7.4.30" } }, ``` diff --git a/composer.json b/composer.json index 3ab0e4f2ce..15561eea1b 100644 --- a/composer.json +++ b/composer.json @@ -16,18 +16,17 @@ } ], "require": { - "php": ">=7.3", + "php": ">=7.4", "composer/installers": "^1.9", "cweagans/composer-patches": "^1.7", - "drupal/core-composer-scaffold": "^9.0", - "drupal/core-recommended": "^9.0", - "drush/drush": "^10.3", + "drupal/core-composer-scaffold": "^9.4", + "drupal/core-recommended": "^9.4", + "drush/drush": "^11.0", "vlucas/phpdotenv": "^5.1", "webflo/drupal-finder": "^1.2" }, "require-dev": { - "drupal/core-dev": "^9.0", - "zaporylie/composer-drupal-optimizations": "^1.2" + "drupal/core-dev": "^9.4" }, "conflict": { "drupal/drupal": "*" @@ -36,7 +35,13 @@ "prefer-stable": true, "config": { "discard-changes": true, - "sort-packages": true + "sort-packages": true, + "allow-plugins": { + "composer/installers": true, + "cweagans/composer-patches": true, + "drupal/core-composer-scaffold": true, + "dealerdirect/phpcodesniffer-composer-installer": true + } }, "autoload": { "classmap": [ diff --git a/load.environment.php b/load.environment.php index eef1d28d07..eb5e3a0f8f 100644 --- a/load.environment.php +++ b/load.environment.php @@ -6,10 +6,12 @@ */ use Dotenv\Dotenv; -use Dotenv\Exception\InvalidPathException; /** * Load any .env file. See /.env.example. + * + * Drupal has no official method for loading environment variables and uses + * getenv() in some places. */ -$dotenv = Dotenv::createImmutable(__DIR__); +$dotenv = Dotenv::createUnsafeImmutable(__DIR__); $dotenv->safeLoad();