Skip to content

test(github): Test in PHP development mode #610

test(github): Test in PHP development mode

test(github): Test in PHP development mode #610

Workflow file for this run

name: Tests
on:
push:
branches: [ 8.x-4.x ]
pull_request:
branches: [ 8.x-4.x ]
jobs:
drupal:
name: Drupal ${{ matrix.drupal-core }} (PHP ${{ matrix.php-versions }})
runs-on: ubuntu-20.04
env:
extensions: mbstring, xml, pdo_sqlite, gd, opcache
strategy:
fail-fast: false
matrix:
php-versions: ['7.3', '7.4', '8.0', '8.1']
drupal-core: ['9.5.x']
phpstan: ['0']
include:
# Extra runs to also test on latest Drupal 10.
- php-versions: '8.1'
drupal-core: '10.1.x'
phpstan: '0'
# We only need to run PHPStan once on the latest PHP version.
- php-versions: '8.2'
drupal-core: '10.1.x'
phpstan: '1'
steps:
- name: Checkout Drupal core
uses: actions/checkout@v3
with:
repository: drupal/drupal
ref: ${{ matrix.drupal-core }}
- name: Checkout graphql module
uses: actions/checkout@v3
with:
path: modules/graphql
- name: Setup PHP extension cache
id: extcache
uses: shivammathur/cache-extensions@v1
with:
php-version: ${{ matrix.php-versions }}
extensions: ${{ env.extensions }}
# Ideally this would be based on env.extensions, how can we make a
# hash out of that?
key: cache-v1
- name: Cache PHP extensions
uses: actions/cache@v3
with:
path: ${{ steps.extcache.outputs.dir }}
key: ${{ steps.extcache.outputs.key }}
restore-keys: ${{ steps.extcache.outputs.key }}
- name: Setup PHP, with composer and extensions
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-versions }}
# Disable Xdebug for better performance.
coverage: none
ini-file: development
extensions: ${{ env.extensions }}
- name: Get composer cache directory
id: composercache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composercache.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 Drupal core dependencies
run: |
composer install --no-progress --prefer-dist --optimize-autoloader
composer --no-interaction run-script drupal-phpunit-upgrade
composer config --no-plugins allow-plugins.phpstan/extension-installer true
- name: Install GraphQL dependencies
run: composer --no-interaction --no-progress require \
webonyx/graphql-php:^14.8 \
drupal/typed_data:^1.0 \
drupal/redirect:^1.0 \
phpstan/phpstan:^1.10.32 \
mglaman/phpstan-drupal:^1.1.2 \
phpstan/phpstan-deprecation-rules:^1.0.0 \
jangregor/phpstan-prophecy:^1.0.0 \
phpstan/phpstan-phpunit:^1.0.0 \
phpstan/extension-installer:^1.0
# We install Coder separately because updating did not work in the local
# Drupal vendor dir.
- name: Install Coder
run: |
mkdir coder
cd coder
echo '{"config": {"allow-plugins": {"dealerdirect/phpcodesniffer-composer-installer": true}}}' > composer.json
composer require drupal/coder:8.3.15 --no-interaction --no-progress
- name: Run PHPUnit
run: |
cp modules/graphql/phpunit.xml.dist core/phpunit.xml
./vendor/bin/phpunit --configuration core/phpunit.xml modules/graphql
env:
SIMPLETEST_DB: "sqlite://localhost/:memory:"
- name: Run PHPStan
# phpstan-drupal bug, so we remove 1 stub file
# https://github.com/mglaman/phpstan-drupal/issues/509
run: if [[ ${{ matrix.phpstan }} == "1" ]]; then rm vendor/mglaman/phpstan-drupal/stubs/Drupal/Core/Field/FieldItemList.stub && cd modules/graphql && ../../vendor/bin/phpstan analyse; fi
- name: Run PHPCS
run: |
cd modules/graphql && ../../coder/vendor/bin/phpcs -p