|
| 1 | +name: "Coding Standards" |
| 2 | +on: [push] |
| 3 | +jobs: |
| 4 | + coding-standards: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + |
| 7 | + strategy: |
| 8 | + matrix: |
| 9 | + php-version: |
| 10 | + - "8.0" |
| 11 | + node-version: |
| 12 | + - 16 |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout code |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + ref: ${{ github.head_ref }} |
| 19 | + |
| 20 | + - name: "Install Node" |
| 21 | + uses: actions/setup-node@v1 |
| 22 | + with: |
| 23 | + node-version: "${{ matrix.node-version }}" |
| 24 | + |
| 25 | + - name: "Install PHP with extensions" |
| 26 | + uses: "shivammathur/setup-php@v2" |
| 27 | + with: |
| 28 | + coverage: "none" |
| 29 | + php-version: "${{ matrix.php-version }}" |
| 30 | + |
| 31 | + - name: Cache node modules |
| 32 | + id: cache-npm |
| 33 | + uses: actions/cache@v3 |
| 34 | + env: |
| 35 | + cache-name: cache-node-modules |
| 36 | + with: |
| 37 | + # npm cache files are stored in `~/.npm` on Linux/macOS |
| 38 | + path: ~/.npm |
| 39 | + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} |
| 40 | + restore-keys: | |
| 41 | + ${{ runner.os }}-build-${{ env.cache-name }}- |
| 42 | + ${{ runner.os }}-build- |
| 43 | + ${{ runner.os }}- |
| 44 | +
|
| 45 | + - if: ${{ steps.cache-npm.outputs.cache-hit == 'false' }} |
| 46 | + name: List the state of node modules |
| 47 | + continue-on-error: true |
| 48 | + run: npm list |
| 49 | + |
| 50 | + - name: "Install locked dependencies with npm" |
| 51 | + run: "npm ci --ignore-scripts" |
| 52 | + |
| 53 | + - name: "Cache dependencies installed with composer" |
| 54 | + uses: "actions/cache@v2" |
| 55 | + with: |
| 56 | + path: "~/.composer/cache" |
| 57 | + key: "php-${{ matrix.php-version }}-composer-${{ hashFiles('composer.lock') }}" |
| 58 | + restore-keys: "php-${{ matrix.php-version }}-composer-" |
| 59 | + |
| 60 | + - name: "Install locked dependencies with composer" |
| 61 | + run: "composer install --no-interaction --no-progress --no-suggest" |
| 62 | + |
| 63 | + - name: "Create cache directory for friendsofphp/php-cs-fixer" |
| 64 | + run: mkdir -p .build/php-cs-fixer |
| 65 | + |
| 66 | + - name: "Cache cache directory for friendsofphp/php-cs-fixer" |
| 67 | + uses: "actions/cache@v2" |
| 68 | + with: |
| 69 | + path: "~/.build/php-cs-fixer" |
| 70 | + key: "php-${{ matrix.php-version }}-php-cs-fixer-${{ github.sha }}" |
| 71 | + restore-keys: "php-${{ matrix.php-version }}-php-cs-fixer-" |
| 72 | + |
| 73 | + - name: "Run eslint" |
| 74 | + run: "npm run eslint" |
| 75 | + |
| 76 | + - name: "Run friendsofphp/php-cs-fixer" |
| 77 | + run: "composer php-cs-fixer" |
| 78 | + |
| 79 | + - name: Commit changes |
| 80 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 81 | + with: |
| 82 | + commit_message: Fix styling |
0 commit comments