|
| 1 | +name: Code Quality Checks |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + lint: #----------------------------------------------------------------------- |
| 8 | + name: Lint PHP files |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - name: Check out source code |
| 12 | + uses: actions/checkout@v2 |
| 13 | + |
| 14 | + - name: Check existence of composer.json file |
| 15 | + id: check_composer_file |
| 16 | + uses: andstor/file-existence-action@v1 |
| 17 | + with: |
| 18 | + files: "composer.json" |
| 19 | + |
| 20 | + - name: Set up PHP envirnoment |
| 21 | + uses: shivammathur/setup-php@v2 |
| 22 | + with: |
| 23 | + php-version: '7.4' |
| 24 | + tools: cs2pr |
| 25 | + |
| 26 | + - name: Get Composer cache Directory |
| 27 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 28 | + id: composer-cache |
| 29 | + run: | |
| 30 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 31 | +
|
| 32 | + - name: Use Composer cache |
| 33 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 34 | + uses: actions/cache@v1 |
| 35 | + with: |
| 36 | + path: ${{ steps['composer-cache'].outputs.dir }} |
| 37 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 38 | + restore-keys: | |
| 39 | + ${{ runner.os }}-composer- |
| 40 | +
|
| 41 | + - name: Install dependencies |
| 42 | + if: steps.check_composer_file.outputs.files_exists == 'true' |
| 43 | + run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest |
| 44 | + |
| 45 | + - name: Check existence of vendor/bin/parallel-lint file |
| 46 | + id: check_linter_file |
| 47 | + uses: andstor/file-existence-action@v1 |
| 48 | + with: |
| 49 | + files: "vendor/bin/parallel-lint" |
| 50 | + |
| 51 | + - name: Run Linter |
| 52 | + if: steps.check_linter_file.outputs.files_exists == 'true' |
| 53 | + run: vendor/bin/parallel-lint -j 10 . --exclude vendor --checkstyle | cs2pr |
| 54 | + |
| 55 | + phpcs: #---------------------------------------------------------------------- |
| 56 | + name: PHPCS |
| 57 | + runs-on: ubuntu-latest |
| 58 | + |
| 59 | + steps: |
| 60 | + - name: Check out source code |
| 61 | + uses: actions/checkout@v2 |
| 62 | + |
| 63 | + - name: Check existence of composer.json & phpcs.xml.dist files |
| 64 | + id: check_files |
| 65 | + uses: andstor/file-existence-action@v1 |
| 66 | + with: |
| 67 | + files: "composer.json, phpcs.xml.dist" |
| 68 | + |
| 69 | + - name: Set up PHP envirnoment |
| 70 | + uses: shivammathur/setup-php@v2 |
| 71 | + with: |
| 72 | + php-version: '7.4' |
| 73 | + tools: cs2pr |
| 74 | + |
| 75 | + - name: Get Composer cache Directory |
| 76 | + if: steps.check_files.outputs.files_exists == 'true' |
| 77 | + id: composer-cache |
| 78 | + run: | |
| 79 | + echo "::set-output name=dir::$(composer config cache-files-dir)" |
| 80 | +
|
| 81 | + - name: Use Composer cache |
| 82 | + if: steps.check_files.outputs.files_exists == 'true' |
| 83 | + uses: actions/cache@v1 |
| 84 | + with: |
| 85 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 86 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} |
| 87 | + restore-keys: | |
| 88 | + ${{ runner.os }}-composer- |
| 89 | +
|
| 90 | + - name: Install dependencies |
| 91 | + if: steps.check_files.outputs.files_exists == 'true' |
| 92 | + run: COMPOSER_ROOT_VERSION=dev-master composer install --prefer-dist --no-progress --no-suggest |
| 93 | + |
| 94 | + - name: Check existence of vendor/bin/phpcs file |
| 95 | + id: check_phpcs_binary_file |
| 96 | + uses: andstor/file-existence-action@v1 |
| 97 | + with: |
| 98 | + files: "vendor/bin/phpcs" |
| 99 | + |
| 100 | + - name: Run PHPCS |
| 101 | + if: steps.check_phpcs_binary_file.outputs.files_exists == 'true' |
| 102 | + run: vendor/bin/phpcs -q --report=checkstyle | cs2pr |
0 commit comments