Skip to content

Commit 64cfb2c

Browse files
authored
GitHub actions (#8)
* Create php.yml * Install squizlabs/php_codesniffer via Composer * Add Composer script for linting * Add Composer script to fix PSR-12 issues * Fix PSR-12 issues * Create testing env file * Remove unused ENV
1 parent 24bc97a commit 64cfb2c

File tree

17 files changed

+202
-57
lines changed

17 files changed

+202
-57
lines changed

.env.example

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,3 @@ MAIL_PASSWORD=null
3838
MAIL_ENCRYPTION=null
3939
MAIL_FROM_ADDRESS="admin@laravel-inertia-template.test"
4040
MAIL_FROM_NAME="${APP_NAME}"
41-
42-
AWS_ACCESS_KEY_ID=
43-
AWS_SECRET_ACCESS_KEY=
44-
AWS_DEFAULT_REGION=us-east-1
45-
AWS_BUCKET=
46-
AWS_USE_PATH_STYLE_ENDPOINT=false
47-
48-
PUSHER_APP_ID=
49-
PUSHER_APP_KEY=
50-
PUSHER_APP_SECRET=
51-
PUSHER_HOST=
52-
PUSHER_PORT=443
53-
PUSHER_SCHEME=https
54-
PUSHER_APP_CLUSTER=mt1
55-
56-
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
57-
VITE_PUSHER_HOST="${PUSHER_HOST}"
58-
VITE_PUSHER_PORT="${PUSHER_PORT}"
59-
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
60-
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

.env.testing

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
APP_NAME="TEST – Laravel Inertia Template"
2+
APP_ENV=testing
3+
APP_KEY=base64:jpd/wy450S/8N0y6OfuRoZ8yS3AWEzrbkSgo08djF4w=
4+
APP_DEBUG=true
5+
APP_URL=http://laravel-inertia-template.test
6+
7+
BCRYPT_ROUNDS=4
8+
9+
SEED_ADMIN_EMAIL=admin@laravel-inertia-template.test
10+
11+
LOG_CHANNEL=stack
12+
LOG_DEPRECATIONS_CHANNEL=null
13+
LOG_LEVEL=debug
14+
15+
DB_CONNECTION=sqlite
16+
DB_HOST=127.0.0.1
17+
DB_PORT=3306
18+
DB_DATABASE=":memory:"
19+
DB_USERNAME=root
20+
DB_PASSWORD=
21+
22+
BROADCAST_DRIVER=log
23+
CACHE_DRIVER=array
24+
FILESYSTEM_DISK=local
25+
QUEUE_CONNECTION=sync
26+
SESSION_DRIVER=array
27+
SESSION_LIFETIME=120
28+
29+
MAIL_DRIVER=log
30+
MAIL_MAILER=array
31+
MAIL_FROM_ADDRESS="admin@laravel-inertia-template.test"
32+
MAIL_FROM_NAME="${APP_NAME}"

.github/workflows/php.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: PHP
2+
3+
on: [pull_request]
4+
5+
jobs:
6+
dependencies:
7+
name: Install Dependencies
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v3
12+
13+
- name: Get Composer dependencies
14+
id: cache-vendor
15+
uses: actions/cache@v3
16+
with:
17+
path: vendor
18+
key: ${{ runner.os }}-vendor-dev-${{ hashFiles('**/composer.lock') }}
19+
20+
- name: Install Composer dependencies
21+
if: steps.cache-vendor.outputs.cache-hit != 'true'
22+
run: composer install --no-interaction
23+
24+
validate:
25+
name: Lint
26+
needs: dependencies
27+
runs-on: ubuntu-latest
28+
29+
steps:
30+
- uses: actions/checkout@v3
31+
32+
- name: Get Composer dependencies
33+
id: cache-vendor
34+
uses: actions/cache@v3
35+
with:
36+
path: vendor
37+
key: ${{ runner.os }}-vendor-dev-${{ hashFiles('**/composer.lock') }}
38+
39+
- name: Install Composer dependencies
40+
if: steps.cache-vendor.outputs.cache-hit != 'true'
41+
run: composer install --no-interaction
42+
43+
- name: Lint against PSR-12
44+
run: composer lint
45+
46+
test:
47+
name: Test
48+
needs: dependencies
49+
runs-on: ubuntu-latest
50+
env:
51+
APP_ENV: testing
52+
DB_CONNECTION: sqlite
53+
DB_DATABASE: ":memory:"
54+
55+
steps:
56+
- uses: actions/checkout@v3
57+
58+
- name: Get Composer dependencies
59+
id: cache-vendor
60+
uses: actions/cache@v3
61+
with:
62+
path: vendor
63+
key: ${{ runner.os }}-vendor-dev-${{ hashFiles('**/composer.lock') }}
64+
65+
- name: Install Composer dependencies
66+
if: steps.cache-vendor.outputs.cache-hit != 'true'
67+
run: composer install --no-interaction
68+
69+
- name: Setup application
70+
run: |
71+
cp .env.testing .env
72+
php artisan key:generate
73+
php artisan migrate:fresh --seed --seeder=TestsSeeder
74+
75+
- name: Run tests
76+
run: composer test:coverage

app/Console/Kernel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ protected function schedule(Schedule $schedule)
2525
*/
2626
protected function commands()
2727
{
28-
$this->load(__DIR__.'/Commands');
28+
$this->load(__DIR__ . '/Commands');
2929

3030
require base_path('routes/console.php');
3131
}

app/Http/Controllers/Controller.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@
99

1010
class Controller extends BaseController
1111
{
12-
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
12+
use AuthorizesRequests;
13+
use DispatchesJobs;
14+
use ValidatesRequests;
1315
}

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
"pestphp/pest-plugin-parallel": "^1.2",
2626
"phpunit/phpunit": "^9.5.26",
2727
"spatie/laravel-ignition": "^1.6.1",
28-
"spatie/ray": "^1.36"
28+
"spatie/ray": "^1.36",
29+
"squizlabs/php_codesniffer": "^3.7"
2930
},
3031
"autoload": {
3132
"psr-4": {
@@ -53,6 +54,12 @@
5354
"npm run prod"
5455
],
5556
"build:test": "composer install --no-interaction",
57+
"lint": [
58+
"./vendor/bin/phpcs ./ --extensions=php --standard=PSR12 --ignore=vendor/,tests/,storage/,cache/,database/migrations/,*.blade.php,public/index.php"
59+
],
60+
"fix": [
61+
"./vendor/bin/phpcbf ./ --extensions=php --standard=PSR12 --ignore=vendor/,tests/,storage/,cache/,database/migrations/,*.blade.php,public/index.php"
62+
],
5663
"test": "php artisan test --parallel --stop-on-failure",
5764
"test:coverage": "XDEBUG_MODE=coverage php artisan test --parallel --coverage --min=85",
5865
"post-autoload-dump": [

composer.lock

Lines changed: 57 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/broadcasting.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
'secret' => env('PUSHER_APP_SECRET'),
3737
'app_id' => env('PUSHER_APP_ID'),
3838
'options' => [
39-
'host' => env('PUSHER_HOST') ?: 'api-'.env('PUSHER_APP_CLUSTER', 'mt1').'.pusher.com',
39+
'host' => env('PUSHER_HOST') ?: 'api-' . env('PUSHER_APP_CLUSTER', 'mt1') . '.pusher.com',
4040
'port' => env('PUSHER_PORT', 443),
4141
'scheme' => env('PUSHER_SCHEME', 'https'),
4242
'encrypted' => true,

config/cache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,6 @@
105105
|
106106
*/
107107

108-
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache_'),
108+
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache_'),
109109

110110
];

config/database.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125

126126
'options' => [
127127
'cluster' => env('REDIS_CLUSTER', 'redis'),
128-
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
128+
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
129129
],
130130

131131
'default' => [

0 commit comments

Comments
 (0)