Skip to content

Commit 3247c5c

Browse files
Merge pull request #7 from CodeWithDennis/add-workflows
Workflows
2 parents c9e3f0e + c5dfa17 commit 3247c5c

File tree

9 files changed

+351
-2
lines changed

9 files changed

+351
-2
lines changed

.github/workflows/pest.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: Tests
2+
3+
on: [ push ]
4+
5+
jobs:
6+
tests:
7+
name: Application Operational Test
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Start MYSQL
11+
run: |
12+
sudo systemctl enable mysql.service
13+
sudo systemctl start mysql.service
14+
mysql --host 127.0.0.1 -uroot -proot -e 'CREATE DATABASE IF NOT EXISTS laravel;'
15+
mysql --host 127.0.0.1 -uroot -proot -e "SELECT @@global.secure_file_priv, @@global.local_infile"
16+
17+
- name: Checkout
18+
uses: actions/checkout@v3
19+
20+
- name: Setup PHP
21+
uses: shivammathur/setup-php@v2
22+
with:
23+
php-version: '8.4'
24+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
25+
coverage: none
26+
27+
- name: Setup NodeJS
28+
uses: actions/setup-node@v3
29+
with:
30+
node-version: 14
31+
32+
- name: Install NodeJS dependencies
33+
run: |
34+
npm install
35+
36+
- name: Install Composer dependencies
37+
run: composer install --no-interaction --prefer-dist --optimize-autoloader
38+
39+
- name: Prepare Application
40+
run: |
41+
php artisan config:clear
42+
cp .env.example .env
43+
php artisan key:generate
44+
php artisan storage:link
45+
npm run build
46+
47+
- name: Migrations
48+
run: php artisan migrate --force -v
49+
50+
- name: PEST
51+
run: php artisan test --parallel

.github/workflows/phpstan.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Static Analysis
2+
3+
on: [ push ]
4+
5+
jobs:
6+
tests:
7+
name: Run Larastan
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Setup PHP
13+
uses: shivammathur/setup-php@v2
14+
with:
15+
php-version: '8.4'
16+
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
17+
coverage: none
18+
19+
- name: Run composer install
20+
run: composer install -n --prefer-dist
21+
22+
- name: Prepare Laravel Application
23+
run: |
24+
cp .env.example .env
25+
php artisan key:generate
26+
27+
- name: Run Larastan
28+
run: ./vendor/bin/phpstan analyse

.github/workflows/pint.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Fix Code Style
2+
3+
on: [ push ]
4+
5+
jobs:
6+
lint:
7+
runs-on: ubuntu-latest
8+
permissions:
9+
contents: write
10+
strategy:
11+
fail-fast: true
12+
matrix:
13+
php: [8.4]
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Setup PHP
20+
uses: shivammathur/setup-php@v2
21+
with:
22+
php-version: ${{ matrix.php }}
23+
extensions: json, dom, curl, libxml, mbstring
24+
coverage: none
25+
26+
- name: Install Pint
27+
run: composer global require laravel/pint
28+
29+
- name: Run Pint
30+
run: pint
31+
32+
- name: Commit linted files
33+
uses: stefanzweifel/git-auto-commit-action@v5
34+
with:
35+
commit_message: "Apply code style fixes"

.github/workflows/rector.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Rector CI
2+
3+
on: [ push ]
4+
5+
jobs:
6+
rector:
7+
runs-on: ubuntu-latest
8+
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v3
12+
13+
- name: Set up PHP
14+
uses: shivammathur/setup-php@v2
15+
with:
16+
php-version: 8.4
17+
extensions: mbstring, xml, tokenizer, curl, json
18+
tools: composer
19+
coverage: none
20+
21+
- name: Cache Composer dependencies
22+
uses: actions/cache@v3
23+
with:
24+
path: vendor
25+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
26+
restore-keys: ${{ runner.os }}-composer-
27+
28+
- name: Install dependencies
29+
run: composer install --no-progress --no-suggest --prefer-dist
30+
31+
- name: Cache Rector cache
32+
uses: actions/cache@v3
33+
with:
34+
path: storage/rector
35+
key: ${{ runner.os }}-rector-${{ hashFiles('**/rector.php') }}
36+
restore-keys: ${{ runner.os }}-rector-
37+
38+
- name: Run Rector
39+
run: |
40+
vendor/bin/rector process --ansi
41+
42+
- name: Validate Rector changes
43+
run: |
44+
git diff --exit-code

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
![DocExplorer Thumbnail](thumbnail.png)
44

5+
[![Rector](https://github.com/CodeWithDennis/docexplorer/actions/workflows/rector.yml/badge.svg)](https://github.com/CodeWithDennis/docexplorer/actions/workflows/rector.yml)
6+
[![PHPStan](https://github.com/CodeWithDennis/docexplorer/actions/workflows/phpstan.yml/badge.svg)](https://github.com/CodeWithDennis/docexplorer/actions/workflows/phpstan.yml)
7+
[![Pest](https://github.com/CodeWithDennis/docexplorer/actions/workflows/pest.yml/badge.svg)](https://github.com/CodeWithDennis/docexplorer/actions/workflows/pest.yml)
8+
[![Laravel Pint](https://github.com/CodeWithDennis/docexplorer/actions/workflows/pint.yml/badge.svg)](https://github.com/CodeWithDennis/docexplorer/actions/workflows/pint.yml)
59

610
## Introduction
711

@@ -80,6 +84,27 @@ The project uses Pest PHP for testing. Run tests with:
8084
php artisan test
8185
```
8286

87+
## Code Quality Tools
88+
89+
The project uses several code quality tools to maintain high standards:
90+
91+
- [Rector](https://github.com/rectorphp/rector) - Automated code refactoring
92+
- [Laravel Pint](https://laravel.com/docs/pint) - PHP code style fixer
93+
- [PHPStan](https://phpstan.org/) - Static analysis tool
94+
- [PestPHP](https://pestphp.com/) - Testing framework
95+
96+
You can run all code quality tools in sequence using the composer review command:
97+
98+
```bash
99+
composer review
100+
```
101+
102+
This command will:
103+
1. Run Rector for automated code refactoring
104+
2. Apply Laravel Pint code style fixes
105+
3. Run PHPStan for static analysis
106+
4. Execute all tests with PestPHP
107+
83108
## Contributing
84109

85110
To contribute to the project:

app/Models/DocumentationLink.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Models;
66

77
use App\Enums\Framework;
8+
use Database\Factories\DocumentationLinkFactory;
89
use Illuminate\Database\Eloquent\Factories\HasFactory;
910
use Illuminate\Database\Eloquent\Model;
1011

composer.json

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
"name": "laravel/laravel",
44
"type": "project",
55
"description": "The skeleton application for the Laravel framework.",
6-
"keywords": ["laravel", "framework"],
6+
"keywords": [
7+
"laravel",
8+
"framework"
9+
],
710
"license": "MIT",
811
"require": {
912
"php": "^8.2",
@@ -15,6 +18,7 @@
1518
"require-dev": {
1619
"driftingly/rector-laravel": "^2.0",
1720
"fakerphp/faker": "^1.23",
21+
"larastan/larastan": "^3.3",
1822
"laravel/pail": "^1.2.2",
1923
"laravel/pint": "^1.13",
2024
"laravel/sail": "^1.41",
@@ -23,6 +27,7 @@
2327
"pestphp/pest": "^3.8",
2428
"pestphp/pest-plugin-laravel": "^3.1",
2529
"pestphp/pest-plugin-livewire": "^3.0",
30+
"phpstan/phpstan": "^2.1",
2631
"phpunit/phpunit": "^11.5.3",
2732
"rector/rector": "^2.0"
2833
},
@@ -57,6 +62,16 @@
5762
"dev": [
5863
"Composer\\Config::disableProcessTimeout",
5964
"npx concurrently -c \"#93c5fd,#c4b5fd,#fb7185,#fdba74\" \"php artisan serve\" \"php artisan queue:listen --tries=1\" \"php artisan pail --timeout=0\" \"npm run dev\" --names=server,queue,logs,vite"
65+
],
66+
"pest": "./vendor/bin/pest --parallel",
67+
"pint": "./vendor/bin/pint",
68+
"rector": "./vendor/bin/rector process",
69+
"phpstan": "./vendor/bin/phpstan analyse",
70+
"review": [
71+
"@rector",
72+
"@pint",
73+
"@phpstan",
74+
"@pest"
6075
]
6176
},
6277
"extra": {

0 commit comments

Comments
 (0)