Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,152 @@ jobs:
run: |
# Validate all commits in the PR
npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

lint:
runs-on: ubuntu-latest
needs: validate-commits
if: always() && (needs.validate-commits.result == 'success' || needs.validate-commits.result == 'skipped')
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Run Laravel Pint
uses: aglipanci/[email protected]
with:
preset: laravel
verboseMode: true

analyze:
runs-on: ubuntu-latest
needs: lint
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: none

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Copy environment file
run: cp .env.example .env

- name: Generate application key
run: php artisan key:generate

- name: Run Larastan (PHPStan)
run: ./vendor/bin/phpstan analyse --memory-limit=2G --error-format=github

test:
runs-on: ubuntu-latest
needs: analyze

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: laravel_blog_test
MYSQL_USER: laravel_user
MYSQL_PASSWORD: laravel_password
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

redis:
image: redis:7-alpine
ports:
- 6379:6379
options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=3

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
coverage: xdebug

- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-

- name: Install Composer dependencies
run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader

- name: Copy environment file
run: cp .env.example .env

- name: Generate application key
run: php artisan key:generate

- name: Set testing environment variables
run: |
echo "APP_ENV=testing" >> .env
echo "DB_CONNECTION=mysql" >> .env
echo "DB_HOST=127.0.0.1" >> .env
echo "DB_PORT=3306" >> .env
echo "DB_DATABASE=laravel_blog_test" >> .env
echo "DB_USERNAME=laravel_user" >> .env
echo "DB_PASSWORD=laravel_password" >> .env
echo "CACHE_STORE=array" >> .env
echo "SESSION_DRIVER=array" >> .env
echo "QUEUE_CONNECTION=sync" >> .env

- name: Wait for MySQL to be ready
run: |
for i in {1..30}; do
if mysqladmin ping -h 127.0.0.1 -u laravel_user -plaravel_password --silent; then
echo "MySQL is ready"
break
fi
echo "Waiting for MySQL... ($i/30)"
sleep 2
done

- name: Run database migrations
run: php artisan migrate:fresh --seed --env=testing --force

- name: Run tests with Pest (parallel)
run: php artisan test --parallel --recreate-databases --stop-on-failure
Loading