|
| 1 | +on: pull_request |
| 2 | +name: PR Review |
| 3 | +jobs: |
| 4 | + changelog: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + name: Changelog should be updated |
| 7 | + strategy: |
| 8 | + fail-fast: false |
| 9 | + steps: |
| 10 | + - name: Checkout |
| 11 | + uses: actions/checkout@v2 |
| 12 | + with: |
| 13 | + fetch-depth: 2 |
| 14 | + |
| 15 | + - name: Git fetch |
| 16 | + run: git fetch |
| 17 | + |
| 18 | + - name: Check that changelog has been updated. |
| 19 | + run: git diff --exit-code origin/${{ github.base_ref }} -- CHANGELOG.md && exit 1 || exit 0 |
| 20 | + |
| 21 | + test-composer-files: |
| 22 | + name: Validate composer |
| 23 | + runs-on: ubuntu-latest |
| 24 | + strategy: |
| 25 | + matrix: |
| 26 | + php-versions: [ '7.4', '8.0', '8.1' ] |
| 27 | + dependency-version: [ prefer-lowest, prefer-stable ] |
| 28 | + steps: |
| 29 | + - uses: actions/checkout@master |
| 30 | + - name: Setup PHP, with composer and extensions |
| 31 | + uses: shivammathur/setup-php@v2 |
| 32 | + with: |
| 33 | + php-version: ${{ matrix.php-versions }} |
| 34 | + extensions: json |
| 35 | + coverage: none |
| 36 | + tools: composer:v2 |
| 37 | + # https://github.com/shivammathur/setup-php#cache-composer-dependencies |
| 38 | + - name: Get composer cache directory |
| 39 | + id: composer-cache |
| 40 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 41 | + - name: Cache dependencies |
| 42 | + uses: actions/cache@v2 |
| 43 | + with: |
| 44 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 45 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 46 | + restore-keys: ${{ runner.os }}-composer- |
| 47 | + - name: Validate composer files |
| 48 | + run: | |
| 49 | + composer validate --strict composer.json |
| 50 | + # Check that dependencies resolve. |
| 51 | + composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction |
| 52 | +
|
| 53 | + php-check-coding-standards: |
| 54 | + name: PHP - Check Coding Standards |
| 55 | + runs-on: ubuntu-latest |
| 56 | + strategy: |
| 57 | + matrix: |
| 58 | + php-versions: [ '7.4', '8.0', '8.1' ] |
| 59 | + dependency-version: [ prefer-lowest, prefer-stable ] |
| 60 | + steps: |
| 61 | + - uses: actions/checkout@master |
| 62 | + - name: Setup PHP, with composer and extensions |
| 63 | + uses: shivammathur/setup-php@v2 |
| 64 | + with: |
| 65 | + php-version: ${{ matrix.php-versions }} |
| 66 | + extensions: json |
| 67 | + coverage: none |
| 68 | + tools: composer:v2 |
| 69 | + # https://github.com/shivammathur/setup-php#cache-composer-dependencies |
| 70 | + - name: Get composer cache directory |
| 71 | + id: composer-cache |
| 72 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 73 | + - name: Cache dependencies |
| 74 | + uses: actions/cache@v2 |
| 75 | + with: |
| 76 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 77 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 78 | + restore-keys: ${{ runner.os }}-composer- |
| 79 | + - name: Install Dependencies |
| 80 | + run: | |
| 81 | + composer install --no-interaction --no-progress |
| 82 | + - name: PHPCS |
| 83 | + run: | |
| 84 | + composer coding-standards-check/phpcs |
| 85 | +
|
| 86 | + php-code-analysis: |
| 87 | + name: PHP - Code analysis |
| 88 | + runs-on: ubuntu-latest |
| 89 | + strategy: |
| 90 | + matrix: |
| 91 | + php-versions: [ '7.4', '8.0', '8.1' ] |
| 92 | + dependency-version: [ prefer-lowest, prefer-stable ] |
| 93 | + steps: |
| 94 | + - uses: actions/checkout@master |
| 95 | + - name: Setup PHP, with composer and extensions |
| 96 | + uses: shivammathur/setup-php@v2 |
| 97 | + with: |
| 98 | + php-version: ${{ matrix.php-versions }} |
| 99 | + extensions: json, gd |
| 100 | + coverage: none |
| 101 | + tools: composer:v2 |
| 102 | + # https://github.com/shivammathur/setup-php#cache-composer-dependencies |
| 103 | + - name: Get composer cache directory |
| 104 | + id: composer-cache |
| 105 | + run: echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 106 | + - name: Cache dependencies |
| 107 | + uses: actions/cache@v2 |
| 108 | + with: |
| 109 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 110 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 111 | + restore-keys: ${{ runner.os }}-composer- |
| 112 | + - name: drupal-check |
| 113 | + run: | |
| 114 | + # We need a Drupal project to run drupal-check (cf. https://github.com/mglaman/drupal-check#usage) |
| 115 | + # Install Drupal |
| 116 | + composer --no-interaction create-project drupal/recommended-project:^9 --stability=dev drupal |
| 117 | + # Copy our module source code into the Drupal module folder. |
| 118 | + mkdir -p drupal/web/modules/contrib/os2forms_get_organized |
| 119 | + cp -r os2forms_get_organized.* composer.json src drupal/web/modules/contrib/os2forms_get_organized |
| 120 | + # Add our module as a composer repository. |
| 121 | + composer --no-interaction --working-dir=drupal config repositories.os2forms/os2forms_get_organized path web/modules/contrib/os2forms_get_organized |
| 122 | + # Restore Drupal composer repository. |
| 123 | + composer --no-interaction --working-dir=drupal config repositories.drupal composer https://packages.drupal.org/8 |
| 124 | +
|
| 125 | + composer --no-interaction --working-dir=drupal config --no-plugins allow-plugins.cweagans/composer-patches true |
| 126 | + # @see https://getcomposer.org/doc/03-cli.md#modifying-extra-values |
| 127 | + composer --no-interaction --working-dir=drupal config --no-plugins --json extra.enable-patching true |
| 128 | +
|
| 129 | + # Require our module. |
| 130 | + composer --no-interaction --working-dir=drupal require 'os2forms/os2forms_get_organized:*' |
| 131 | +
|
| 132 | + # Check code |
| 133 | + composer --no-interaction --working-dir=drupal require --dev drupal/core-dev |
| 134 | + cd drupal/web/modules/contrib/os2forms_get_organized |
| 135 | + # Remove our non-dev dependencies to prevent duplicated Drupal installation |
| 136 | + # PHP Fatal error: Cannot redeclare drupal_get_filename() (previously declared in /home/runner/work/os2forms_get_organized/os2forms_get_organized/drupal/web/modules/contrib/os2forms_get_organized/vendor/drupal/core/includes/bootstrap.inc:190) in /home/runner/work/os2forms_get_organized/os2forms_get_organized/drupal/web/core/includes/bootstrap.inc on line 190 |
| 137 | + # Use sed to remove the "require" property in composer.json |
| 138 | + sed -i '/^\s*"require":/,/^\s*}/d' composer.json |
| 139 | + composer --no-interaction install |
| 140 | + composer code-analysis |
0 commit comments