@@ -29,3 +29,152 @@ jobs:
2929 run : |
3030 # Validate all commits in the PR
3131 npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
32+
33+ lint :
34+ runs-on : ubuntu-latest
35+ needs : validate-commits
36+ if : always() && (needs.validate-commits.result == 'success' || needs.validate-commits.result == 'skipped')
37+ steps :
38+ - name : Checkout
39+ uses : actions/checkout@v4
40+
41+ - name : Setup PHP
42+ uses : shivammathur/setup-php@v2
43+ with :
44+ php-version : ' 8.2'
45+ extensions : dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
46+ coverage : none
47+
48+ - name : Cache Composer packages
49+ id : composer-cache
50+ uses : actions/cache@v4
51+ with :
52+ path : vendor
53+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
54+ restore-keys : |
55+ ${{ runner.os }}-php-
56+
57+ - name : Install Composer dependencies
58+ run : composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader
59+
60+ - name : Run Laravel Pint
61+ 62+ with :
63+ preset : laravel
64+ verboseMode : true
65+
66+ analyze :
67+ runs-on : ubuntu-latest
68+ needs : lint
69+ steps :
70+ - name : Checkout
71+ uses : actions/checkout@v4
72+
73+ - name : Setup PHP
74+ uses : shivammathur/setup-php@v2
75+ with :
76+ php-version : ' 8.2'
77+ extensions : dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
78+ coverage : none
79+
80+ - name : Cache Composer packages
81+ id : composer-cache
82+ uses : actions/cache@v4
83+ with :
84+ path : vendor
85+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
86+ restore-keys : |
87+ ${{ runner.os }}-php-
88+
89+ - name : Install Composer dependencies
90+ run : composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader
91+
92+ - name : Copy environment file
93+ run : cp .env.example .env
94+
95+ - name : Generate application key
96+ run : php artisan key:generate
97+
98+ - name : Run Larastan (PHPStan)
99+ run : ./vendor/bin/phpstan analyse --memory-limit=2G --error-format=github
100+
101+ test :
102+ runs-on : ubuntu-latest
103+ needs : analyze
104+
105+ services :
106+ mysql :
107+ image : mysql:8.0
108+ env :
109+ MYSQL_ROOT_PASSWORD : root
110+ MYSQL_DATABASE : laravel_blog_test
111+ MYSQL_USER : laravel_user
112+ MYSQL_PASSWORD : laravel_password
113+ ports :
114+ - 3306:3306
115+ options : --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
116+
117+ redis :
118+ image : redis:7-alpine
119+ ports :
120+ - 6379:6379
121+ options : --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3
122+
123+ steps :
124+ - name : Checkout
125+ uses : actions/checkout@v4
126+
127+ - name : Setup PHP
128+ uses : shivammathur/setup-php@v2
129+ with :
130+ php-version : ' 8.2'
131+ extensions : dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
132+ coverage : xdebug
133+
134+ - name : Cache Composer packages
135+ id : composer-cache
136+ uses : actions/cache@v4
137+ with :
138+ path : vendor
139+ key : ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
140+ restore-keys : |
141+ ${{ runner.os }}-php-
142+
143+ - name : Install Composer dependencies
144+ run : composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader
145+
146+ - name : Copy environment file
147+ run : cp .env.example .env
148+
149+ - name : Generate application key
150+ run : php artisan key:generate
151+
152+ - name : Set testing environment variables
153+ run : |
154+ echo "APP_ENV=testing" >> .env
155+ echo "DB_CONNECTION=mysql" >> .env
156+ echo "DB_HOST=127.0.0.1" >> .env
157+ echo "DB_PORT=3306" >> .env
158+ echo "DB_DATABASE=laravel_blog_test" >> .env
159+ echo "DB_USERNAME=laravel_user" >> .env
160+ echo "DB_PASSWORD=laravel_password" >> .env
161+ echo "CACHE_STORE=array" >> .env
162+ echo "SESSION_DRIVER=array" >> .env
163+ echo "QUEUE_CONNECTION=sync" >> .env
164+
165+ - name : Wait for MySQL to be ready
166+ run : |
167+ for i in {1..30}; do
168+ if mysqladmin ping -h 127.0.0.1 -u laravel_user -plaravel_password --silent; then
169+ echo "MySQL is ready"
170+ break
171+ fi
172+ echo "Waiting for MySQL... ($i/30)"
173+ sleep 2
174+ done
175+
176+ - name : Run database migrations
177+ run : php artisan migrate:fresh --seed --env=testing --force
178+
179+ - name : Run tests with Pest (parallel)
180+ run : php artisan test --parallel --recreate-databases --stop-on-failure
0 commit comments