|
| 1 | +name: CI |
| 2 | +# touching: trigger children sync when workflows change |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main] |
| 7 | + pull_request: |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: read |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: ci-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + tests: |
| 18 | + name: PHP 8.3 • L12 • deps=highest • OS=ubuntu-latest |
| 19 | + runs-on: ubuntu-latest |
| 20 | + env: |
| 21 | + # Throttle parallel HTTP downloads to reduce GitHub codeload 429 rate limit occurrences for all child packages inheriting this workflow. |
| 22 | + COMPOSER_MAX_PARALLEL_HTTP: 6 |
| 23 | + |
| 24 | + steps: |
| 25 | + - name: Checkout |
| 26 | + uses: actions/checkout@v6 |
| 27 | + |
| 28 | + - name: Setup PHP (8.3) |
| 29 | + uses: shivammathur/setup-php@v2 |
| 30 | + with: |
| 31 | + php-version: "8.3" |
| 32 | + extensions: mbstring, dom, pdo, sqlite3, pdo_sqlite, fileinfo |
| 33 | + coverage: none |
| 34 | + tools: composer:v2 |
| 35 | + |
| 36 | + - name: Validate composer.json |
| 37 | + run: composer validate --strict |
| 38 | + |
| 39 | + - name: Configure GitHub OAuth for Composer (improves API rate limits) |
| 40 | + run: composer config -g github-oauth.github.com "${{ secrets.GITHUB_TOKEN }}" |
| 41 | + # GITHUB_TOKEN is automatically provided by Actions; using it boosts authenticated quota for metadata requests. |
| 42 | + |
| 43 | + - name: Get Composer cache directory |
| 44 | + shell: bash |
| 45 | + id: composer-cache |
| 46 | + run: | |
| 47 | + echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT |
| 48 | +
|
| 49 | + - name: Cache Composer files |
| 50 | + uses: actions/cache@v5 |
| 51 | + with: |
| 52 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 53 | + key: ${{ runner.os }}-composer-php83-highest-${{ hashFiles('**/composer.lock') }} |
| 54 | + restore-keys: | |
| 55 | + ${{ runner.os }}-composer-php83-highest- |
| 56 | + ${{ runner.os }}-composer-php83- |
| 57 | +
|
| 58 | + - name: Install dependencies |
| 59 | + shell: bash |
| 60 | + run: | |
| 61 | + set -euo pipefail |
| 62 | + echo "Starting composer update with limited parallel HTTP=${COMPOSER_MAX_PARALLEL_HTTP}"; |
| 63 | + for attempt in 1 2 3; do |
| 64 | + if composer update --no-interaction --prefer-dist --no-progress; then |
| 65 | + break |
| 66 | + fi |
| 67 | + echo "Composer update failed (attempt ${attempt}). Retrying after backoff..." >&2 |
| 68 | + sleep $((attempt*15)) |
| 69 | + done |
| 70 | + echo "Composer dependencies installed."; |
| 71 | +
|
| 72 | + - name: Clear testbench cache |
| 73 | + run: | |
| 74 | + rm -rf vendor/orchestra/testbench-core/laravel/bootstrap/cache/* |
| 75 | + rm -rf vendor/orchestra/testbench-core/laravel/database/database.sqlite |
| 76 | +
|
| 77 | + - name: Run test suite |
| 78 | + run: composer test |
| 79 | + |
| 80 | + - name: Check test inventory docs up-to-date |
| 81 | + shell: bash |
| 82 | + run: | |
| 83 | + set -euo pipefail |
| 84 | + # Generate the latest test inventory |
| 85 | + composer docs:tests |
| 86 | + # Fail if docs/tests.md changed compared to the committed version |
| 87 | + if ! git diff --quiet -- docs/tests.md; then |
| 88 | + echo "::error title=Out-of-date test inventory::docs/tests.md is not up-to-date." >&2 |
| 89 | + echo "Run the following locally and commit the result:" >&2 |
| 90 | + echo " composer docs:tests && git add docs/tests.md && git commit -m 'chore(docs): update test inventory'" >&2 |
| 91 | + echo "\nChanges:" >&2 |
| 92 | + git --no-pager diff -- docs/tests.md || true |
| 93 | + exit 1 |
| 94 | + fi |
0 commit comments