Chore: Consolidate CI workflows and harden test infra #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| pull_request: | |
| push: | |
| branches: [master, "*.x"] | |
| jobs: | |
| format: | |
| name: Format | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run Pint | |
| run: | | |
| docker run --rm -v "$PWD":/app -w /app composer:2.7 sh -c \ | |
| "composer install --profile --ignore-platform-reqs --no-interaction && composer lint" | |
| analyze: | |
| name: Analyze | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: swoole | |
| coverage: none | |
| - name: Validate composer.json and composer.lock | |
| run: composer validate --strict | |
| - name: Get composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: composer-${{ hashFiles('composer.lock') }} | |
| restore-keys: composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress --no-interaction | |
| - name: PHPStan | |
| run: composer check | |
| unit: | |
| name: Tests / Unit | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: shivammathur/setup-php@v2 | |
| with: | |
| php-version: '8.2' | |
| extensions: swoole | |
| coverage: none | |
| - name: Get composer cache directory | |
| id: composer-cache | |
| run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" | |
| - uses: actions/cache@v4 | |
| with: | |
| path: ${{ steps.composer-cache.outputs.dir }} | |
| key: composer-${{ hashFiles('composer.lock') }} | |
| restore-keys: composer- | |
| - name: Install dependencies | |
| run: composer install --prefer-dist --no-progress --no-interaction | |
| - name: Run unit tests | |
| run: vendor/bin/phpunit --configuration phpunit.xml --testsuite unit | |
| e2e-fpm: | |
| name: Tests / E2E / FPM | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build and wait for fpm to be healthy | |
| run: docker compose up -d --build --wait fpm | |
| - name: Run E2E tests | |
| run: docker compose exec -T fpm vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e-fpm | |
| - name: Dump container logs on failure | |
| if: failure() | |
| run: docker compose logs fpm | |
| e2e-swoole: | |
| name: Tests / E2E / Swoole | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Build and wait for swoole to be healthy | |
| run: docker compose up -d --build --wait swoole | |
| - name: Run E2E tests | |
| run: docker compose exec -T swoole vendor/bin/phpunit --configuration phpunit.xml --testsuite e2e-swoole | |
| - name: Dump container logs on failure | |
| if: failure() | |
| run: docker compose logs swoole | |
| benchmark: | |
| name: Benchmark | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Run phpbench | |
| run: | | |
| docker run --rm -v "$PWD":/app -w /app composer:2.7 sh -c \ | |
| "composer install --profile --ignore-platform-reqs --no-interaction && git config --global --add safe.directory /app && composer bench -- --progress=plain" |