|
| 1 | +# GitHub Actions Documentation: https://docs.github.com/en/actions |
| 2 | + |
| 3 | +name: "Continuous Integration" |
| 4 | + |
| 5 | +on: |
| 6 | + push: |
| 7 | + branches: |
| 8 | + - "main" |
| 9 | + tags: |
| 10 | + - "*" |
| 11 | + pull_request: |
| 12 | + branches: |
| 13 | + - "main" |
| 14 | + |
| 15 | +# Cancels all previous workflow runs for the same branch that have not yet completed. |
| 16 | +concurrency: |
| 17 | + # The concurrency group contains the workflow name and the branch name. |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +env: |
| 22 | + COMPOSER_ROOT_VERSION: "1.99.99" |
| 23 | + |
| 24 | +jobs: |
| 25 | + coding-standards: |
| 26 | + name: "Coding standards" |
| 27 | + runs-on: "ubuntu-latest" |
| 28 | + steps: |
| 29 | + - name: "Checkout repository" |
| 30 | + uses: "actions/checkout@v4" |
| 31 | + |
| 32 | + - name: "Install PHP" |
| 33 | + uses: "shivammathur/setup-php@v2" |
| 34 | + with: |
| 35 | + php-version: "latest" |
| 36 | + coverage: "none" |
| 37 | + |
| 38 | + - name: "Install dependencies (Composer)" |
| 39 | + uses: "ramsey/composer-install@v3" |
| 40 | + |
| 41 | + - name: "Check syntax (php-parallel-lint)" |
| 42 | + run: "composer dev:lint:syntax" |
| 43 | + |
| 44 | + - name: "Check coding standards (PHP_CodeSniffer)" |
| 45 | + run: "composer dev:lint:style" |
| 46 | + |
| 47 | + static-analysis: |
| 48 | + name: "Static analysis" |
| 49 | + runs-on: "ubuntu-latest" |
| 50 | + steps: |
| 51 | + - name: "Checkout repository" |
| 52 | + uses: "actions/checkout@v4" |
| 53 | + |
| 54 | + - name: "Install PHP" |
| 55 | + uses: "shivammathur/setup-php@v2" |
| 56 | + with: |
| 57 | + php-version: "latest" |
| 58 | + coverage: "none" |
| 59 | + |
| 60 | + - name: "Install dependencies (Composer)" |
| 61 | + uses: "ramsey/composer-install@v3" |
| 62 | + |
| 63 | + - name: "Statically analyze code (PHPStan)" |
| 64 | + run: "composer dev:analyze:phpstan" |
| 65 | + |
| 66 | + code-coverage: |
| 67 | + name: "Code coverage" |
| 68 | + needs: ["coding-standards", "static-analysis"] |
| 69 | + runs-on: "ubuntu-latest" |
| 70 | + steps: |
| 71 | + - name: "Checkout repository" |
| 72 | + uses: "actions/checkout@v4" |
| 73 | + |
| 74 | + - name: "Install PHP" |
| 75 | + uses: "shivammathur/setup-php@v2" |
| 76 | + with: |
| 77 | + php-version: "latest" |
| 78 | + coverage: "xdebug" |
| 79 | + |
| 80 | + - name: "Install dependencies (Composer)" |
| 81 | + uses: "ramsey/composer-install@v3" |
| 82 | + |
| 83 | + - name: "Run unit tests (PHPUnit)" |
| 84 | + run: "composer dev:test:coverage:ci" |
| 85 | + |
| 86 | + - name: "Publish coverage report to Codecov" |
| 87 | + uses: "codecov/codecov-action@v5" |
| 88 | + |
| 89 | + unit-tests: |
| 90 | + name: "Unit tests" |
| 91 | + needs: ["code-coverage"] |
| 92 | + runs-on: "ubuntu-latest" |
| 93 | + |
| 94 | + strategy: |
| 95 | + fail-fast: false |
| 96 | + matrix: |
| 97 | + php-version: |
| 98 | + - "8.2" |
| 99 | + - "8.3" |
| 100 | + - "8.4" |
| 101 | + |
| 102 | + steps: |
| 103 | + - name: "Checkout repository" |
| 104 | + uses: "actions/checkout@v4" |
| 105 | + |
| 106 | + - name: "Install PHP" |
| 107 | + uses: "shivammathur/setup-php@v2" |
| 108 | + with: |
| 109 | + php-version: "${{ matrix.php-version }}" |
| 110 | + coverage: "none" |
| 111 | + |
| 112 | + - name: "Install dependencies (Composer)" |
| 113 | + uses: "ramsey/composer-install@v3" |
| 114 | + |
| 115 | + - name: "Run unit tests (PHPUnit)" |
| 116 | + run: "composer dev:test:unit" |
0 commit comments