trypost/.github/workflows/tests.yml
Paulo Castellano 80888641e5
ci: local TIA test runs; simplify e2e (drop sharding + e2e-gate) (#262)
* ci: name e2e shards descriptively and add time-balanced sharding

- e2e job now shows as "e2e (shard 1/2)" / "e2e (shard 2/2)" in checks
  instead of the unlabeled matrix "(1)" / "(2)" suffix
- add scheduled/manual "Update Shards" workflow that generates and
  commits tests/.pest/shards.json so Pest balances the two e2e shards
  by real execution time instead of file count

* ci: enable Pest TIA for local test runs

Scoped to local via locally() so CI keeps running the full suite on
every commit. Add composer test:tia script using herd coverage, since
Herd bundles Xdebug but doesn't load it by default.

* ci: drop Herd-specific prefix from test:tia composer script

trypost is open-source and self-hosted; not every contributor runs
Herd. The script now just needs a coverage driver (Xdebug/PCOV)
active however the environment provides it — Herd users can run it
via "herd coverage composer test:tia".

* ci: revert e2e sharding, drop Update Shards workflow

Sharding across 2 runners added complexity (unbalanced shards without
timing data, plus an Update Shards workflow that can't push straight
to main under branch protection) that isn't worth it here. e2e now
runs tests/Browser as a single job again; e2e-gate stays as a
pass-through so the required branch protection check name is
unchanged.

* ci: drop redundant e2e-gate job

e2e-gate only mirrored e2e's own result once sharding was removed.
Updated main's branch protection required_status_checks to require
"e2e" directly instead of "e2e-gate".
2026-08-09 12:24:10 -03:00

122 lines
3 KiB
YAML

name: Tests
on:
push:
branches: [main, develop]
pull_request:
branches: [main, develop]
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
jobs:
backend:
runs-on: ubuntu-latest
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@v7
- name: Setup test environment
uses: ./.github/actions/setup-laravel
with:
db-port: ${{ job.services.postgres.ports['5432'] }}
redis-port: ${{ job.services.redis.ports['6379'] }}
- name: Run backend tests
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
run: php artisan test --compact --parallel
e2e:
runs-on: ubuntu-latest
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@v7
- name: Setup test environment
uses: ./.github/actions/setup-laravel
with:
node: 'true'
db-port: ${{ job.services.postgres.ports['5432'] }}
redis-port: ${{ job.services.redis.ports['6379'] }}
- name: Build assets
run: npm run build
- name: Install Playwright browsers
run: npx playwright install --with-deps chromium
- name: Run browser tests
env:
DB_PORT: ${{ job.services.postgres.ports['5432'] }}
REDIS_PORT: ${{ job.services.redis.ports['6379'] }}
run: php artisan test tests/Browser --compact
- name: Upload Playwright artifacts
if: failure()
uses: actions/upload-artifact@v7
with:
name: playwright-artifacts
path: tests/Browser/Screenshots
if-no-files-found: ignore
retention-days: 7