trypost/.github/workflows/tests.yml
Paulo Castellano bec831fec6 ci: fix tests workflow and clear pre-existing lint errors
- Add `php artisan passport:keys --force` step to tests workflow
  so the OAuth2 server keys exist before tests run. Without them
  every API test failed with `LogicException: Invalid key supplied`
  from `vendor/league/oauth2-server/src/CryptKey.php`.

- Clear 4 pre-existing unused-variable lint errors that were
  blocking this PR's CI (auth/GoogleAuthButton, billing/Subscribe,
  posts/editor/CommentsTab, posts/editor/TikTokSettings).

- `eslint --fix` also reordered imports alphabetically in 11 other
  files — pure cosmetic.
2026-05-04 12:03:44 -03:00

99 lines
2.5 KiB
YAML

name: Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
jobs:
tests:
runs-on: ubuntu-latest
env:
DB_CONNECTION: pgsql
DB_DATABASE: trypost_test
DB_USERNAME: postgres
DB_PASSWORD: password
BROADCAST_CONNECTION: "null"
CACHE_STORE: array
QUEUE_CONNECTION: sync
SESSION_DRIVER: array
services:
postgres:
image: postgres:16
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
POSTGRES_DB: trypost_test
ports:
- 5432/tcp
options: >-
--health-cmd="pg_isready"
--health-interval=10s
--health-timeout=5s
--health-retries=3
redis:
image: redis:7
ports:
- 6379/tcp
options: >-
--health-cmd="redis-cli ping"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, pdo_pgsql, bcmath, intl, gd, redis
coverage: none
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-
- name: Prepare environment
run: cp .env.ci .env
- name: Install Composer dependencies
run: composer install --no-interaction --prefer-dist --optimize-autoloader
- name: Install npm dependencies
run: npm ci
- name: Generate application key
run: php artisan key:generate
- name: Build assets
run: npm run build
- name: Run migrations
run: php artisan migrate --force
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
- name: Generate Passport keys
run: php artisan passport:keys --force
- name: Run tests
run: php artisan test --compact
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}