|
| 1 | +name: Tests |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ 8.x-4.x ] |
| 5 | + pull_request: |
| 6 | + branches: [ 8.x-4.x ] |
| 7 | +jobs: |
| 8 | + drupal: |
| 9 | + name: Drupal ${{ matrix.drupal-core }} (PHP ${{ matrix.php-versions }}) |
| 10 | + runs-on: ubuntu-20.04 |
| 11 | + env: |
| 12 | + extensions: mbstring, xml, pdo_sqlite, gd, opcache |
| 13 | + strategy: |
| 14 | + fail-fast: false |
| 15 | + matrix: |
| 16 | + php-versions: ['7.3', '7.4', '8.0', '8.1'] |
| 17 | + drupal-core: ['9.5.x'] |
| 18 | + phpstan: ['0'] |
| 19 | + include: |
| 20 | + # Extra runs to also test on latest Drupal 10. |
| 21 | + - php-versions: '8.1' |
| 22 | + drupal-core: '10.0.x' |
| 23 | + phpstan: '0' |
| 24 | + # We only need to run PHPStan once on the latest PHP version. |
| 25 | + - php-versions: '8.2' |
| 26 | + drupal-core: '10.0.x' |
| 27 | + phpstan: '1' |
| 28 | + steps: |
| 29 | + - name: Checkout Drupal core |
| 30 | + uses: actions/checkout@v3 |
| 31 | + with: |
| 32 | + repository: drupal/drupal |
| 33 | + ref: ${{ matrix.drupal-core }} |
| 34 | + |
| 35 | + - name: Checkout graphql module |
| 36 | + uses: actions/checkout@v3 |
| 37 | + with: |
| 38 | + path: modules/graphql |
| 39 | + |
| 40 | + - name: Setup PHP extension cache |
| 41 | + id: extcache |
| 42 | + uses: shivammathur/cache-extensions@v1 |
| 43 | + with: |
| 44 | + php-version: ${{ matrix.php-versions }} |
| 45 | + extensions: ${{ env.extensions }} |
| 46 | + # Ideally this would be based on env.extensions, how can we make a |
| 47 | + # hash out of that? |
| 48 | + key: cache-v1 |
| 49 | + |
| 50 | + - name: Cache PHP extensions |
| 51 | + uses: actions/cache@v3 |
| 52 | + with: |
| 53 | + path: ${{ steps.extcache.outputs.dir }} |
| 54 | + key: ${{ steps.extcache.outputs.key }} |
| 55 | + restore-keys: ${{ steps.extcache.outputs.key }} |
| 56 | + |
| 57 | + - name: Setup PHP, with composer and extensions |
| 58 | + uses: shivammathur/setup-php@v2 |
| 59 | + with: |
| 60 | + php-version: ${{ matrix.php-versions }} |
| 61 | + # Disable Xdebug for better performance. |
| 62 | + coverage: none |
| 63 | + extensions: ${{ env.extensions }} |
| 64 | + |
| 65 | + - name: Get composer cache directory |
| 66 | + id: composercache |
| 67 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 68 | + |
| 69 | + - name: Cache composer dependencies |
| 70 | + uses: actions/cache@v3 |
| 71 | + with: |
| 72 | + path: ${{ steps.composercache.outputs.dir }} |
| 73 | + # Use composer.json for key, if composer.lock is not committed. |
| 74 | + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 75 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 76 | + restore-keys: ${{ runner.os }}-composer- |
| 77 | + |
| 78 | + - name: Install Drupal core dependencies |
| 79 | + run: | |
| 80 | + composer install --no-progress --prefer-dist --optimize-autoloader |
| 81 | + composer --no-interaction run-script drupal-phpunit-upgrade |
| 82 | + composer config --no-plugins allow-plugins.phpstan/extension-installer true |
| 83 | +
|
| 84 | + - name: Install GraphQL dependencies |
| 85 | + run: composer --no-interaction --no-progress require \ |
| 86 | + webonyx/graphql-php:^14.8 \ |
| 87 | + drupal/typed_data:^1.0 \ |
| 88 | + drupal/redirect:^1.0 \ |
| 89 | + phpstan/phpstan:^1.10.32 \ |
| 90 | + mglaman/phpstan-drupal:^1.1.2 \ |
| 91 | + phpstan/phpstan-deprecation-rules:^1.0.0 \ |
| 92 | + jangregor/phpstan-prophecy:^1.0.0 \ |
| 93 | + phpstan/phpstan-phpunit:^1.0.0 \ |
| 94 | + phpstan/extension-installer:^1.0 |
| 95 | + |
| 96 | + # We install Coder separately because updating did not work in the local |
| 97 | + # Drupal vendor dir. |
| 98 | + - name: Install Coder |
| 99 | + run: | |
| 100 | + mkdir coder |
| 101 | + cd coder |
| 102 | + echo '{"config": {"allow-plugins": {"dealerdirect/phpcodesniffer-composer-installer": true}}}' > composer.json |
| 103 | + composer require drupal/coder:8.3.15 --no-interaction --no-progress |
| 104 | +
|
| 105 | + - name: Run PHPUnit |
| 106 | + run: | |
| 107 | + cp modules/graphql/phpunit.xml.dist core/phpunit.xml |
| 108 | + ./vendor/bin/phpunit --configuration core/phpunit.xml modules/graphql |
| 109 | + env: |
| 110 | + SIMPLETEST_DB: "sqlite://localhost/:memory:" |
| 111 | + |
| 112 | + - name: Run PHPStan |
| 113 | + # phpstan-drupal bug, so we remove 1 stub file |
| 114 | + # https://github.com/mglaman/phpstan-drupal/issues/509 |
| 115 | + 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 |
| 116 | + |
| 117 | + - name: Run PHPCS |
| 118 | + run: | |
| 119 | + cd modules/graphql && ../../coder/vendor/bin/phpcs -p |
0 commit comments