|
1 | | -name: Back-end |
| 1 | +# yaml-language-server: $schema=https://json.schemastore.org/github-workflow |
| 2 | + |
| 3 | +name: "Back-end" |
2 | 4 |
|
3 | 5 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - pull_request: null |
| 6 | + pull_request: null |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - "master" |
| 10 | +# Add [skip ci] to commit message to skip CI. |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: "read" |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: "${{ github.workflow }}-${{ github.ref }}" |
| 17 | + cancel-in-progress: true |
8 | 18 |
|
9 | 19 | jobs: |
10 | | - unit_tests: |
11 | | - |
12 | | - strategy: |
13 | | - fail-fast: true |
14 | | - matrix: |
15 | | - os: ["ubuntu-24.04"] |
16 | | - php: ["8.3", "8.4"] |
17 | | - laravel: ["^12.0"] |
18 | | - dependency-version: ["highest"] |
19 | | - |
20 | | - name: "Unit - PHP ${{ matrix.php }} - L ${{ matrix.laravel }} - ${{ matrix.dependency-version }}" |
21 | | - |
22 | | - runs-on: "${{ matrix.os }}" |
23 | | - |
24 | | - steps: |
25 | | - - name: Checkout repository |
26 | | - uses: actions/checkout@v4 |
27 | | - |
28 | | - - name: Setup PHP |
29 | | - uses: shivammathur/setup-php@v2 |
30 | | - with: |
31 | | - php-version: ${{ matrix.php }} |
32 | | - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo, exif |
33 | | - tools: composer:v2 |
34 | | - coverage: xdebug3 |
35 | | - |
36 | | - - name: Check Composer configuration |
37 | | - run: composer validate --no-interaction # @dev --strict |
38 | | - |
39 | | - - name: Install dependencies |
40 | | - if: ${{ matrix.dependency-version == 'highest' }} |
41 | | - run: composer update --no-interaction --no-progress --prefer-dist --with="laravel/framework:${{ matrix.laravel }}" |
42 | | - |
43 | | - - name: Install locked dependencies |
44 | | - if: ${{ matrix.dependency-version == 'locked' }} |
45 | | - run: composer install --prefer-dist --no-interaction --no-progress |
46 | | - |
47 | | - - name: Check for PSR-4 mapping errors |
48 | | - run: composer dump-autoload --optimize --strict-psr |
49 | | - |
50 | | - - name: Execute tests |
51 | | - run: composer exec -- phpunit |
52 | | - |
53 | | - - name: Send coverage to Coveralls |
54 | | - if: ${{ matrix.os == 'ubuntu-24.04' && matrix.php == '8.3' && matrix.laravel == '^12.0' }} |
55 | | - env: |
56 | | - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
57 | | - run: | |
58 | | - wget "https://github.com/php-coveralls/php-coveralls/releases/download/v2.7.0/php-coveralls.phar" |
59 | | - php ./php-coveralls.phar -v |
| 20 | + syntax_errors: |
| 21 | + name: "1️⃣ Syntax errors" |
| 22 | + runs-on: "ubuntu-24.04" |
| 23 | + timeout-minutes: 5 |
| 24 | + steps: |
| 25 | + - |
| 26 | + name: "Set up PHP" |
| 27 | + uses: "shivammathur/setup-php@v2" |
| 28 | + with: |
| 29 | + php-version: "8.4" |
| 30 | + extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo, exif" |
| 31 | + coverage: "none" |
| 32 | + tools: "parallel-lint" |
| 33 | + - |
| 34 | + name: "Checkout repository" |
| 35 | + uses: "actions/checkout@v4" |
| 36 | + - |
| 37 | + name: "Search for invalid complex curly syntax 🐌" |
| 38 | + run: | |
| 39 | + ! git grep -e '\${[A-Z_a-z]' -- '*.php' '*.scss' |
| 40 | + - |
| 41 | + name: "Check source code for syntax errors" |
| 42 | + run: "composer exec --no-interaction -- parallel-lint src/ tests/" |
| 43 | + |
| 44 | + unit_tests: |
| 45 | + name: "2️⃣ Unit and functional tests" |
| 46 | + needs: |
| 47 | + - "syntax_errors" |
| 48 | + strategy: |
| 49 | + fail-fast: false |
| 50 | + matrix: |
| 51 | + php-version: |
| 52 | + - "8.4" |
| 53 | + - "8.5" |
| 54 | + dependencies: |
| 55 | + - "lowest" |
| 56 | + - "locked" |
| 57 | + - "highest" |
| 58 | + include: |
| 59 | + - |
| 60 | + php-version: "8.4" |
| 61 | + dependencies: "locked" |
| 62 | + coverage: true |
| 63 | + runs-on: "ubuntu-24.04" |
| 64 | + timeout-minutes: 5 |
| 65 | + steps: |
| 66 | + - |
| 67 | + name: "Set up PHP" |
| 68 | + uses: "shivammathur/setup-php@v2" |
| 69 | + with: |
| 70 | + php-version: "${{ matrix.php-version }}" |
| 71 | + extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo, exif" |
| 72 | + - |
| 73 | + name: "Setup problem matcher for PHPUnit" |
| 74 | + run: | |
| 75 | + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" |
| 76 | + - |
| 77 | + name: "Checkout repository" |
| 78 | + uses: "actions/checkout@v4" |
| 79 | + - |
| 80 | + name: "Install dependencies" |
| 81 | + uses: "ramsey/composer-install@v3" |
| 82 | + with: |
| 83 | + dependency-versions: "${{ matrix.dependencies }}" |
| 84 | + - |
| 85 | + name: "Execute unit tests" |
| 86 | + run: "composer exec -- phpunit" |
| 87 | + - |
| 88 | + name: "Tests have failed: upload logs" |
| 89 | + if: "${{ failure() }}" |
| 90 | + uses: "actions/upload-artifact@v4" |
| 91 | + with: |
| 92 | + path: "storage/logs/" |
| 93 | + name: "laravel-logs-${{ matrix.php-version }}-${{ matrix.dependencies }}" |
| 94 | + - |
| 95 | + name: "Send coverage to Coveralls" |
| 96 | + env: |
| 97 | + COVERALLS_REPO_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 98 | + if: "${{ env.COVERALLS_REPO_TOKEN && matrix.coverage }}" |
| 99 | + uses: "coverallsapp/github-action@v2" |
| 100 | + with: |
| 101 | + github-token: "${{ env.COVERALLS_REPO_TOKEN }}" |
| 102 | + flag-name: "Unit" |
| 103 | + allow-empty: false |
| 104 | + |
| 105 | + static_analysis: |
| 106 | + name: "3️⃣ Static Analysis" |
| 107 | + needs: |
| 108 | + - "syntax_errors" |
| 109 | + runs-on: "ubuntu-24.04" |
| 110 | + timeout-minutes: 5 |
| 111 | + steps: |
| 112 | + - |
| 113 | + name: "Set up PHP" |
| 114 | + uses: "shivammathur/setup-php@v2" |
| 115 | + with: |
| 116 | + php-version: "8.4" |
| 117 | + extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo, exif" |
| 118 | + coverage: "none" |
| 119 | + - |
| 120 | + name: "Checkout repository" |
| 121 | + uses: "actions/checkout@v4" |
| 122 | + - |
| 123 | + name: "Check JSON files" |
| 124 | + run: | |
| 125 | + git ls-files --cached -z -- '*.json' \ |
| 126 | + | xargs -t --null -L 1 -- \ |
| 127 | + php -r 'json_decode(file_get_contents($argv[1]), null, 512, JSON_THROW_ON_ERROR);' |
| 128 | + - |
| 129 | + name: "Validate Composer configuration" |
| 130 | + run: "composer validate --no-interaction --strict" |
| 131 | + - |
| 132 | + name: "Install dependencies" |
| 133 | + uses: "ramsey/composer-install@v3" |
| 134 | + with: |
| 135 | + dependency-versions: "locked" |
| 136 | + - |
| 137 | + name: "Check PSR-4 mapping 🐌" |
| 138 | + run: "composer dump-autoload --dev --optimize --strict-psr" |
| 139 | + - |
| 140 | + # https://github.com/phpstan/phpstan/issues/9475 |
| 141 | + name: "Search for $this->$this typo 🐌" |
| 142 | + run: | |
| 143 | + ! git grep --line-number -e '\$this\s*->\s*\$this' -- ':!:*/back-end\.yml' |
| 144 | + - |
| 145 | + name: "Install orchestra/testbench" |
| 146 | + run: "composer require --dev --update-with-all-dependencies orchestra/testbench" |
| 147 | + - |
| 148 | + name: "Perform static analysis" |
| 149 | + run: "composer exec -- phpstan || true 'Annotate only'" |
| 150 | + |
| 151 | + coding_standards: |
| 152 | + name: "4️⃣ Coding Standards" |
| 153 | + needs: |
| 154 | + - "syntax_errors" |
| 155 | + runs-on: "ubuntu-24.04" |
| 156 | + timeout-minutes: 5 |
| 157 | + steps: |
| 158 | + - |
| 159 | + name: "Set up PHP" |
| 160 | + uses: "shivammathur/setup-php@v2" |
| 161 | + with: |
| 162 | + php-version: "8.4" |
| 163 | + extensions: "dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, gd, fileinfo, exif" |
| 164 | + coverage: "none" |
| 165 | + tools: "phpcs,cs2pr" |
| 166 | + - |
| 167 | + name: "Checkout repository" |
| 168 | + uses: "actions/checkout@v4" |
| 169 | + - |
| 170 | + name: "Install dependencies" |
| 171 | + uses: "ramsey/composer-install@v3" |
| 172 | + with: |
| 173 | + dependency-versions: "locked" |
| 174 | + #- |
| 175 | + # name: "Detect coding standards violations" |
| 176 | + # run: "composer exec -- phpcs -q --report=checkstyle --standard=PSR12 src/ | cs2pr" |
| 177 | + - |
| 178 | + name: "Detect coding standards violations" |
| 179 | + id: "pint" |
| 180 | + run: "composer exec -- pint --verbose --test" |
| 181 | + - |
| 182 | + name: "Annotate Pint results" |
| 183 | + if: "${{ failure() && steps.pint.outcome == 'failure' }}" |
| 184 | + run: "composer exec -- pint --test --format=checkstyle | cs2pr" |
0 commit comments