|
| 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-latest |
| 11 | + services: |
| 12 | + mysql: |
| 13 | + image: mysql:5.7 |
| 14 | + env: |
| 15 | + MYSQL_ALLOW_EMPTY_PASSWORD: false |
| 16 | + MYSQL_ROOT_PASSWORD: graphql |
| 17 | + MYSQL_DATABASE: graphql |
| 18 | + ports: |
| 19 | + - 3306/tcp |
| 20 | + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 |
| 21 | + strategy: |
| 22 | + fail-fast: false |
| 23 | + matrix: |
| 24 | + php-versions: ['7.3', '7.4'] |
| 25 | + drupal-core: ['9.0.x'] |
| 26 | + # Extra run to also test on latest Drupal 8 and PHP 7.2. |
| 27 | + include: |
| 28 | + - php-versions: '7.2' |
| 29 | + drupal-core: '8.9.x' |
| 30 | + steps: |
| 31 | + - name: Checkout Drupal core |
| 32 | + uses: actions/checkout@v2 |
| 33 | + with: |
| 34 | + repository: drupal/drupal |
| 35 | + ref: ${{ matrix.drupal-core }} |
| 36 | + - name: Checkout graphql module |
| 37 | + uses: actions/checkout@v2 |
| 38 | + with: |
| 39 | + path: modules/graphql |
| 40 | + - name: Setup PHP, with composer and extensions |
| 41 | + uses: shivammathur/setup-php@v2 |
| 42 | + with: |
| 43 | + php-version: ${{ matrix.php-versions }} |
| 44 | + extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, mysql |
| 45 | + - name: Start mysql service |
| 46 | + run: sudo /etc/init.d/mysql start |
| 47 | + - name: Get composer cache directory |
| 48 | + id: composercache |
| 49 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 50 | + - name: Cache composer dependencies |
| 51 | + uses: actions/cache@v2 |
| 52 | + with: |
| 53 | + path: ${{ steps.composercache.outputs.dir }} |
| 54 | + # Use composer.json for key, if composer.lock is not committed. |
| 55 | + # key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 56 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 57 | + restore-keys: ${{ runner.os }}-composer- |
| 58 | + - name: Install Drupal core dependencies |
| 59 | + run: | |
| 60 | + composer install --no-progress --prefer-dist --optimize-autoloader |
| 61 | + composer --no-interaction run-script drupal-phpunit-upgrade |
| 62 | + - name: Install GraphQL dependencies |
| 63 | + run: composer --no-interaction --no-progress require \ |
| 64 | + webonyx/graphql-php:^14.3 \ |
| 65 | + drupal/typed_data:^1.0 \ |
| 66 | + drupal/redirect:^1.6 \ |
| 67 | + phpstan/phpstan:^0.12.50 \ |
| 68 | + mglaman/phpstan-drupal:^0.12.3 \ |
| 69 | + phpstan/phpstan-deprecation-rules:^0.12.2 \ |
| 70 | + jangregor/phpstan-prophecy:^0.8 \ |
| 71 | + phpstan/phpstan-phpunit:^0.12 |
| 72 | + # We install Coder separately because updating did not work in the local |
| 73 | + # Drupal vendor dir. |
| 74 | + - name: Install Coder |
| 75 | + run: | |
| 76 | + mkdir coder |
| 77 | + cd coder |
| 78 | + composer require drupal/coder:8.3.11 --no-interaction --no-progress |
| 79 | + - name: Run PHPUnit |
| 80 | + run: | |
| 81 | + cp modules/graphql/phpunit.xml.dist core/phpunit.xml |
| 82 | + ./vendor/bin/phpunit --configuration core/phpunit.xml modules/graphql |
| 83 | + env: |
| 84 | + SIMPLETEST_DB: mysql://root:[email protected]:${{ job.services.mysql.ports['3306'] }}/graphql |
| 85 | + - name: Run PHPStan |
| 86 | + run: | |
| 87 | + cd modules/graphql && ../../vendor/bin/phpstan analyse |
| 88 | + - name: Run PHPCS |
| 89 | + run: | |
| 90 | + ./coder/vendor/bin/phpcs --config-set installed_paths ../../drupal/coder/coder_sniffer |
| 91 | + cd modules/graphql && ../../coder/vendor/bin/phpcs -p |
0 commit comments