Skip to content

test(phpstan): Update PHPStan config options #729

test(phpstan): Update PHPStan config options

test(phpstan): Update PHPStan config options #729

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-latest
env:
extensions: mbstring, xml, pdo_sqlite, gd, opcache
strategy:
fail-fast: false
matrix:
php-versions: ['8.1', '8.2']
drupal-core: ['10.2.x']
phpstan: ['0']
include:
# Extra run to test older supported Drupal 10.1.x.
- 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.3'
drupal-core: '10.2.x'
phpstan: '1'
steps:
- name: Checkout Drupal core
uses: actions/checkout@v4
with:
repository: drupal/drupal
ref: ${{ matrix.drupal-core }}
- name: Checkout graphql module
uses: actions/checkout@v4
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@v4
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 "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v4
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
- 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: Install PHPStan and Coder dependencies
if: ${{ matrix.phpstan == '1' }}
# Pin the exact Coder version to upgrade manually when we want to.
run: |
composer --no-interaction --no-progress require \
phpstan/phpstan:^1.11.2 \
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
composer --no-interaction --no-progress --with-all-dependencies upgrade drupal/coder:8.3.23
- name: Run PHPStan
if: ${{ matrix.phpstan == '1' }}
run: cd modules/graphql && ../../vendor/bin/phpstan analyse
- name: Run PHPCS
if: ${{ matrix.phpstan == '1' }}
run: cd modules/graphql && ../../vendor/bin/phpcs -p