ci: refactor GitHub Actions with Redis service and best practices

- Tests workflow: add Redis service, cache composer deps, test PHP 8.4+8.5,
  generate Passport keys, use vendor/bin/pest directly
- Larastan workflow: cache deps, consistent checkout@v4, memory limit
- Pint workflow: use project's installed Pint (not global), cache deps
- Standardize Redis port to 6379 across CI and local docker-compose
- Remove 'unstable' branch from triggers (unused)
- Remove 'main' branch from static analysis (doesn't exist)
pull/6856/head
Your Name 4 weeks ago
parent 18c288f88f
commit c7473cd1a8

@ -22,7 +22,7 @@ QUEUE_CONNECTION=sync
REDIS_SCHEME=tcp
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6399
REDIS_PORT=6379
HORIZON_PREFIX="horizon-test-"

@ -1,38 +1,35 @@
name: PHP - Larastan
permissions:
contents: read
pull-requests: write
name: Static Analysis
on:
push:
branches:
- main
- dev
- staging
branches: [staging, dev]
pull_request:
branches:
- main
- dev
- staging
branches: [staging, dev]
jobs:
phpstan:
larastan:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.5' # Or your desired PHP version
extensions: mbstring, pdo_mysql # Add necessary extensions
ini-values: post_max_size=256M, upload_max_filesize=256M
php-version: '8.5'
extensions: mbstring, pdo_sqlite, bcmath, intl
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-8.5-${{ hashFiles('composer.lock') }}
restore-keys: composer-8.5-
- name: Install Composer dependencies
run: composer install --no-interaction --no-progress
run: composer install --no-interaction --no-progress --prefer-dist
- name: Run Larastan
run: ./vendor/bin/phpstan analyse
run: vendor/bin/phpstan analyse --memory-limit=512M

@ -2,17 +2,29 @@ name: Laravel Test Suite
on:
push:
branches: [ staging, dev, unstable ]
branches: [staging, dev, unstable]
pull_request:
branches: [ staging, dev, unstable ]
branches: [staging, dev, unstable]
jobs:
tests:
runs-on: ubuntu-latest
services:
redis:
image: redis:8
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 3s
--health-retries 5
strategy:
fail-fast: true
matrix:
php: [ '8.5' ]
php: ['8.4', '8.5']
steps:
- name: Checkout code
@ -22,17 +34,35 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, intl, gd, exif, iconv, redis
coverage: none
ini-values: memory_limit=512M
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-${{ matrix.php }}-${{ hashFiles('composer.lock') }}
restore-keys: composer-${{ matrix.php }}-
- name: Install Composer dependencies
run: composer install -n --prefer-dist
run: composer install --no-interaction --no-progress --prefer-dist
- name: Copy .env.testing
- name: Prepare environment
run: |
cp .env.testing .env
php artisan key:generate
touch storage/oauth-private.key storage/oauth-public.key
php -r "
\$key = openssl_pkey_new(['private_key_bits' => 2048, 'private_key_type' => OPENSSL_KEYTYPE_RSA]);
openssl_pkey_export(\$key, \$private);
\$public = openssl_pkey_get_details(\$key)['key'];
file_put_contents('storage/oauth-private.key', \$private);
file_put_contents('storage/oauth-public.key', \$public);
"
- name: Run tests
run: php artisan test
continue-on-error: false
run: vendor/bin/pest --compact
env:
REDIS_HOST: 127.0.0.1
REDIS_PORT: 6379

@ -1,46 +1,35 @@
name: PHP - Pint
permissions:
contents: read
pull-requests: write
name: Code Style
on:
push:
branches:
- main
- dev
- staging
- unstable
branches: [staging, dev]
pull_request:
branches:
- main
- dev
- staging
- unstable
branches: [staging, dev]
jobs:
lint:
pint:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
php: [8.5]
steps:
- name: Checkout code
uses: actions/checkout@v7
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: json, dom, curl, libxml, mbstring
php-version: '8.5'
extensions: mbstring
coverage: none
- name: Install Pint
run: composer global require laravel/pint
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: composer-8.5-${{ hashFiles('composer.lock') }}
restore-keys: composer-8.5-
- name: Run Pint
run: pint --test
- name: Install Composer dependencies
run: composer install --no-interaction --no-progress --prefer-dist
# - name: Commit linted files
# uses: stefanzweifel/git-auto-commit-action@v5
- name: Run Pint
run: vendor/bin/pint --test

@ -2,7 +2,7 @@ services:
redis:
image: "redis:8"
ports:
- "6399:6379"
- "6379:6379"
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 2s

Loading…
Cancel
Save