Skip to content

Conversation

mglaman
Copy link
Owner

@mglaman mglaman commented Dec 13, 2020

This moves from TravisCI to GitHub Actions. It also ensures we're testing on D9.

PHP8 was skipped due to drupal/core-dev-pinned referencing phar-io/manifest:1.0.3 which does not support PHP 8. However, using drupal/core-dev would allow phar-io/manifest:^2.0. Moving that to another PR.

@mglaman mglaman linked an issue Dec 13, 2020 that may be closed by this pull request
@mglaman mglaman mentioned this pull request Dec 13, 2020
@mglaman
Copy link
Owner Author

mglaman commented Dec 13, 2020

Spin out into two workflows. There should be one workflow for PHPCS, PHPStan, PHPUnit. One workflow for the Drupal integrations.

For example, first workflow:

    steps:
      - name: "Checkout"
        uses: "actions/checkout@v2"
      - name: "Install PHP"
        uses: "shivammathur/setup-php@v2"
        with:
          coverage: "none"
          php-version: "${{ matrix.php-version }}"
          tools: composer:v2
          extensions: dom, curl, libxml, mbstring, zip, pdo, mysql, pdo_mysql, bcmath, gd, exif, iconv
      - name: "Install dependencies"
        run: "composer update --no-progress --prefer-dist"
      - name: "Downgrade dev dependencies"
        run: "composer require phpunit/phpunit:^7.5 drupal/core-recommended:${{ matrix.drupal }} --with-all-dependencies"
        if: ${{ matrix.drupal == '~8.9' }}
      - name: "PHPCS"
        run: "php vendor/bin/phpcs src"
      - name: "PHPStan"
        run: "php vendor/bin/phpstan analyze src"
      - name: "PHPUnit"
        run: "php vendor/bin/phpunit --debug"

Second workflow:

     - name: Setup Drupal
        run: |
          COMPOSER_MEMORY_LIMIT=-1 composer create-project drupal/recommended-project:${{ matrix.drupal }} ~/drupal --no-interaction
          cd ~/drupal
          composer config minimum-stability dev
          composer config prefer-stable true
          composer config preferred-install dist
          composer config repositories.0 path $GITHUB_WORKSPACE
          composer config repositories.1 composer https://packages.drupal.org/8
          COMPOSER_MEMORY_LIMIT=-1 composer require drupal/core-dev-pinned:${{ matrix.drupal }} --no-suggest
      - name: "require phpstan-drupal"
        run: |
          cd ~/drupal
          COMPOSER_MEMORY_LIMIT=-1 composer require mglaman/phpstan-drupal *@dev
          cp $GITHUB_WORKSPACE/tests/fixtures/config/drupal-phpstan.neon phpstan.neon
      - name: "Test core/install.php"
        run: |
          cd ~/drupal
          ./vendor/bin/phpstan analyze web/core/install.php --debug
      - name: "Test BrowserTestBase is autoloaded"
        run: |
          cd ~/drupal
          ./vendor/bin/phpstan analyze web/core/modules/dynamic_page_cache | grep -q "Class Drupal\Tests\BrowserTestBase not found and could not be autoloaded." && false || true
      - name: "Verify test fixtures are ignored."
        run: |
          cd ~/drupal
          ./vendor/bin/phpstan analyze web/core/modules/migrate_drupal --no-progress | grep -q "tests/fixtures" && false || true
      - name: 'Check "Cannot redeclare token_theme() due to blazy_test.module"'
        run: |
          cd ~/drupal
          COMPOSER_MEMORY_LIMIT=-1 composer require drupal/token drupal/blazy
          ./vendor/bin/phpstan analyze web/modules/contrib/blazy --no-progress || if (($? == 255)); then false; else true; fi

@mglaman
Copy link
Owner Author

mglaman commented Dec 13, 2020

Last failure seems to be on downgrading drupal/core and composer/installers breaking with composer v2

@mglaman
Copy link
Owner Author

mglaman commented Dec 20, 2020

New idea:

  • remove drupal/core packages from require-dev
  • create a custom @requires annotation to specify the major version of drupal the test is for
  • the pipeline runs composer require --dev of specific Drupal major version

@mglaman
Copy link
Owner Author

mglaman commented Dec 20, 2020

For @require drupal 8 and @require drupal 9, see \Drupal\Tests\TestRequirementsTrait.

Parse from $annotations = $this->getAnnotations();

@mglaman mglaman changed the title Improve test matrix for D8 + D9 and PHP8 Improve test matrix for D8 + D9 Mar 10, 2021
@mglaman mglaman merged commit c041720 into master Mar 10, 2021
@mglaman mglaman deleted the gh-actions branch March 10, 2021 22:40
markdorison pushed a commit to markdorison/phpstan-drupal that referenced this pull request Jun 17, 2021
mglaman#156: Added an exclude option to prevent analysis in selected directories.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add testing support for Drupal 9
1 participant