Skip to content

Commit c42045f

Browse files
indy2krocradu
andauthored
Github actions improvements, replace outdated libraries (#29)
* Updated workflow for Laravel 11 * Updated workflow for Laravel 11 * Updated workflow for Laravel 11 * Updated phpunit.xml schema * Updated fixture * Updated merge tests to work for all versions of git * Added separate jobs for Laravel 10 and Laravel 11 * Added separate jobs for Laravel 10 and Laravel 11 * Added separate jobs for Laravel 9 * Upgraded node.js to v20 * Replaced deprecated usage for set-output * Upgraded to actions/setup-node@v4 * Upgraded to actions/checkout@v4 * Upgraded to actions/cache@v4 * Removed deprecated package pest-plugin-mock * Added package lock to ignore, removed from project * Revert changes for package lock * Formatting update * Added support for more parameters including docker support * Fixed pint issues --------- Co-authored-by: cradu <cradu@cradu>
1 parent aee71da commit c42045f

27 files changed

+2343
-1101
lines changed

.github/workflows/main.yml

Lines changed: 197 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,101 @@ on:
1414
- develop
1515

1616
jobs:
17-
laravel-tests:
17+
laravel9-tests:
18+
runs-on: ubuntu-latest
19+
20+
strategy:
21+
matrix:
22+
operating-system: [ ubuntu-latest ]
23+
php: [ '8.1', '8.2' ]
24+
dependency-stability: [ 'prefer-stable' ]
25+
26+
laravel: [ '9.*' ]
27+
include:
28+
- laravel: 9.*
29+
testbench: 8.*
30+
31+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: '20.x'
41+
42+
- name: Cache node_modules directory
43+
uses: actions/cache@v4
44+
id: node_modules-cache
45+
with:
46+
path: node_modules
47+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
48+
49+
- name: Install NPM packages
50+
if: steps.node_modules-cache.outputs.cache-hit != 'true'
51+
run: npm ci --include=dev
52+
53+
- name: Install PHP versions
54+
uses: shivammathur/setup-php@v2
55+
with:
56+
php-version: ${{ matrix.php }}
57+
58+
- name: Get Composer Cache Directory
59+
id: composer-cache
60+
run: |
61+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
62+
63+
- name: Cache Composer dependencies
64+
uses: actions/cache@v4
65+
id: actions-cache
66+
with:
67+
path: ${{ steps.composer-cache.outputs.dir }}
68+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
69+
restore-keys: |
70+
${{ runner.os }}-composer-
71+
72+
- name: Cache PHP dependencies (vendor)
73+
uses: actions/cache@v4
74+
id: vendor-cache
75+
with:
76+
path: vendor
77+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
78+
79+
- name: Install Laravel Dependencies
80+
if: steps.vendor-cache.outputs.cache-hit != 'true'
81+
run: |
82+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
83+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
84+
85+
- name: Update Dependencies with latest stable
86+
if: matrix.dependency-stability == 'prefer-stable'
87+
run: composer update --prefer-stable
88+
89+
- name: Update Dependencies with lowest stable
90+
if: matrix.dependency-stability == 'prefer-lowest'
91+
run: composer update --prefer-stable --prefer-lowest
92+
93+
- name: Set up Git User
94+
run: |
95+
git config --global user.email "github-actions@example.com"
96+
git config --global user.name "GitHub Actions"
97+
98+
# Code quality
99+
- name: Execute tests (Unit and Feature tests) via PestPHP
100+
shell: 'script -q -e -c "bash {0}"'
101+
# Set environment
102+
env:
103+
SESSION_DRIVER: array
104+
TTY: true
105+
106+
run: vendor/bin/pest
107+
108+
- name: Execute Code Sniffer via Laravel Pint
109+
run: vendor/bin/pint --test src config
110+
111+
laravel10-tests:
18112
runs-on: ubuntu-latest
19113

20114
strategy:
@@ -32,15 +126,15 @@ jobs:
32126

33127
steps:
34128
- name: Checkout code
35-
uses: actions/checkout@v3
129+
uses: actions/checkout@v4
36130

37131
- name: Setup Node.js
38-
uses: actions/setup-node@v3
132+
uses: actions/setup-node@v4
39133
with:
40-
node-version: '18.x'
134+
node-version: '20.x'
41135

42136
- name: Cache node_modules directory
43-
uses: actions/cache@v3
137+
uses: actions/cache@v4
44138
id: node_modules-cache
45139
with:
46140
path: node_modules
@@ -58,10 +152,10 @@ jobs:
58152
- name: Get Composer Cache Directory
59153
id: composer-cache
60154
run: |
61-
echo "::set-output name=dir::$(composer config cache-files-dir)"
155+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
62156
63157
- name: Cache Composer dependencies
64-
uses: actions/cache@v3
158+
uses: actions/cache@v4
65159
id: actions-cache
66160
with:
67161
path: ${{ steps.composer-cache.outputs.dir }}
@@ -70,7 +164,7 @@ jobs:
70164
${{ runner.os }}-composer-
71165
72166
- name: Cache PHP dependencies (vendor)
73-
uses: actions/cache@v3
167+
uses: actions/cache@v4
74168
id: vendor-cache
75169
with:
76170
path: vendor
@@ -107,3 +201,98 @@ jobs:
107201

108202
- name: Execute Code Sniffer via Laravel Pint
109203
run: vendor/bin/pint --test src config
204+
205+
laravel11-tests:
206+
runs-on: ubuntu-latest
207+
208+
strategy:
209+
matrix:
210+
operating-system: [ ubuntu-latest ]
211+
php: [ '8.2', '8.3' ]
212+
dependency-stability: [ 'prefer-stable' ]
213+
214+
laravel: [ '11.*' ]
215+
include:
216+
- laravel: 11.*
217+
testbench: 9.*
218+
219+
name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-stability }} - ${{ matrix.operating-system}}
220+
221+
steps:
222+
- name: Checkout code
223+
uses: actions/checkout@v4
224+
225+
- name: Setup Node.js
226+
uses: actions/setup-node@v4
227+
with:
228+
node-version: '20.x'
229+
230+
- name: Cache node_modules directory
231+
uses: actions/cache@v4
232+
id: node_modules-cache
233+
with:
234+
path: node_modules
235+
key: ${{ runner.OS }}-build-${{ hashFiles('**/package.json') }}-${{ hashFiles('**/package-lock.json') }}
236+
237+
- name: Install NPM packages
238+
if: steps.node_modules-cache.outputs.cache-hit != 'true'
239+
run: npm ci --include=dev
240+
241+
- name: Install PHP versions
242+
uses: shivammathur/setup-php@v2
243+
with:
244+
php-version: ${{ matrix.php }}
245+
246+
- name: Get Composer Cache Directory
247+
id: composer-cache
248+
run: |
249+
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
250+
251+
- name: Cache Composer dependencies
252+
uses: actions/cache@v4
253+
id: actions-cache
254+
with:
255+
path: ${{ steps.composer-cache.outputs.dir }}
256+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
257+
restore-keys: |
258+
${{ runner.os }}-composer-
259+
260+
- name: Cache PHP dependencies (vendor)
261+
uses: actions/cache@v4
262+
id: vendor-cache
263+
with:
264+
path: vendor
265+
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
266+
267+
- name: Install Laravel Dependencies
268+
if: steps.vendor-cache.outputs.cache-hit != 'true'
269+
run: |
270+
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
271+
composer update --${{ matrix.dependency-stability }} --prefer-dist --no-interaction --no-suggest
272+
273+
- name: Update Dependencies with latest stable
274+
if: matrix.dependency-stability == 'prefer-stable'
275+
run: composer update --prefer-stable
276+
277+
- name: Update Dependencies with lowest stable
278+
if: matrix.dependency-stability == 'prefer-lowest'
279+
run: composer update --prefer-stable --prefer-lowest
280+
281+
- name: Set up Git User
282+
run: |
283+
git config --global user.email "github-actions@example.com"
284+
git config --global user.name "GitHub Actions"
285+
286+
# Code quality
287+
- name: Execute tests (Unit and Feature tests) via PestPHP
288+
shell: 'script -q -e -c "bash {0}"'
289+
# Set environment
290+
env:
291+
SESSION_DRIVER: array
292+
TTY: true
293+
294+
run: vendor/bin/pest
295+
296+
- name: Execute Code Sniffer via Laravel Pint
297+
run: vendor/bin/pint --test src config
298+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@
22
vendor/
33
node_modules/
44
composer.lock
5+
yarn.lock
6+
.phpunit.cache
57
.phpunit.result.cache

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
"enlightn/enlightn": "^2.3",
3434
"laravel/pint": "^1.2",
3535
"mockery/mockery": "^1.5.1",
36-
"nunomaduro/larastan": "^2.0",
37-
"orchestra/testbench": "^v8.0.0",
36+
"larastan/larastan": "^2.9",
37+
"orchestra/testbench": "^v8.0.0|^v9.0.0",
3838
"pestphp/pest": "^2.0",
39-
"pestphp/pest-plugin-mock": "^2.0",
4039
"squizlabs/php_codesniffer": "^3.7"
4140
},
4241
"autoload": {

config/git-hooks.php

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,8 @@
164164
| The following variables are used to store the paths to bin executables for
165165
| various code analyzer dependencies used in your Laravel application.
166166
| This configuration node allows you to set up the paths for these executables.
167-
| Here you can also specify the path to the configuration files they use to customize their behavior
167+
| Here you can also specify the path to the configuration files they use to customize their behavior.
168+
| Each analyzer can be configured to run inside Docker on a specific container.
168169
|
169170
*/
170171
'code_analyzers' => [
@@ -173,34 +174,46 @@
173174
'config' => env('LARAVEL_PINT_CONFIG'),
174175
'preset' => env('LARAVEL_PINT_PRESET', 'laravel'),
175176
'file_extensions' => env('LARAVEL_PINT_FILE_EXTENSIONS', '/\.php$/'),
177+
'run_in_docker' => env('LARAVEL_PINT_RUN_IN_DOCKER', false),
178+
'docker_container' => env('LARAVEL_PINT_DOCKER_CONTAINER', ''),
176179
],
177180
'php_code_sniffer' => [
178181
'phpcs_path' => env('PHPCS_PATH', 'vendor/bin/phpcs'),
179182
'phpcbf_path' => env('PHPCBF_PATH', 'vendor/bin/phpcbf'),
180183
'config' => env('PHPCS_STANDARD_CONFIG', 'phpcs.xml'),
181184
'file_extensions' => env('PHPCS_FILE_EXTENSIONS', '/\.php$/'),
185+
'run_in_docker' => env('LARAVEL_PHPCS_RUN_IN_DOCKER', false),
186+
'docker_container' => env('LARAVEL_PHPCS_DOCKER_CONTAINER', ''),
182187
],
183188
'larastan' => [
184189
'path' => env('LARASTAN_PATH', 'vendor/bin/phpstan'),
185190
'config' => env('LARASTAN_CONFIG', 'phpstan.neon'),
186191
'additional_params' => env('LARASTAN_ADDITIONAL_PARAMS', '--xdebug'),
192+
'run_in_docker' => env('LARAVEL_LARASTAN_RUN_IN_DOCKER', false),
193+
'docker_container' => env('LARAVEL_LARASTAN_DOCKER_CONTAINER', ''),
187194
],
188195
'blade_formatter' => [
189196
'path' => env('BLADE_FORMATTER_PATH', 'node_modules/.bin/blade-formatter'),
190197
'config' => env('BLADE_FORMATTER_CONFIG', '.bladeformatterrc.json'),
191198
'file_extensions' => env('BLADE_FORMATTER_FILE_EXTENSIONS', '/\.blade\.php$/'),
199+
'run_in_docker' => env('BLADE_FORMATTER_RUN_IN_DOCKER', false),
200+
'docker_container' => env('BLADE_FORMATTER_DOCKER_CONTAINER', ''),
192201
],
193202
'prettier' => [
194203
'path' => env('PRETTIER_PATH', 'node_modules/.bin/prettier'),
195204
'config' => env('PRETTIER_CONFIG', '.prettierrc.json'),
196205
'additional_params' => env('PRETTIER_ADDITIONAL_PARAMS', ''),
197206
'file_extensions' => env('PRETTIER_FILE_EXTENSIONS', '/\.(jsx?|tsx?|vue)$/'),
207+
'run_in_docker' => env('PRETTIER_RUN_IN_DOCKER', false),
208+
'docker_container' => env('PRETTIER_DOCKER_CONTAINER', ''),
198209
],
199210
'eslint' => [
200211
'path' => env('ESLINT_PATH', 'node_modules/.bin/eslint'),
201212
'config' => env('ESLINT_CONFIG', '.eslintrc.js'),
202213
'additional_params' => env('ESLINT_ADDITIONAL_PARAMS', ''),
203214
'file_extensions' => env('ESLINT_FILE_EXTENSIONS', '/\.(jsx?|tsx?|vue)$/'),
215+
'run_in_docker' => env('ESLINT_RUN_IN_DOCKER', false),
216+
'docker_container' => env('ESLINT_DOCKER_CONTAINER', ''),
204217
],
205218
],
206219

@@ -221,4 +234,60 @@
221234
|
222235
*/
223236
'artisan_path' => base_path('artisan'),
237+
238+
/*
239+
|--------------------------------------------------------------------------
240+
| Output errors
241+
|--------------------------------------------------------------------------
242+
|
243+
| This configuration option allows you output any errors encountered
244+
| during execution directly for easy debug.
245+
|
246+
*/
247+
'output_errors' => false,
248+
249+
/*
250+
|--------------------------------------------------------------------------
251+
| Automatically fix errors
252+
|--------------------------------------------------------------------------
253+
|
254+
| This configuration option allows you to configure the git hooks to
255+
| automatically run the fixer without any CLI prompt.
256+
|
257+
*/
258+
'automatically_fix_errors' => false,
259+
260+
/*
261+
|--------------------------------------------------------------------------
262+
| Automatically re-run analyzer after autofix
263+
|--------------------------------------------------------------------------
264+
|
265+
| This configuration option allows you to configure the git hooks to
266+
| automatically re-run the analyzer command after autofix.
267+
| The git hooks will not fail in case the re-run is succesful.
268+
|
269+
*/
270+
'rerun_analyzer_after_autofix' => false,
271+
272+
/*
273+
|--------------------------------------------------------------------------
274+
| Stop at first analyzer failure
275+
|--------------------------------------------------------------------------
276+
|
277+
| This configuration option allows you to configure the git hooks to
278+
| stop (or not) at the first analyzer failure encountered.
279+
|
280+
*/
281+
'stop_at_first_analyzer_failure' => true,
282+
283+
/*
284+
|--------------------------------------------------------------------------
285+
| Debug commands
286+
|--------------------------------------------------------------------------
287+
|
288+
| This configuration option allows you to configure the git hooks to
289+
| display the commands that are executed (usually for debug purpose).
290+
|
291+
*/
292+
'debug_commands' => false,
224293
];

0 commit comments

Comments
 (0)