The test workflow was hitting GitHub's unauthenticated API rate limit (60 req/hour) when downloading 95 packages via composer install --prefer-dist, causing 429 Too Many Requests errors. Two fixes applied: 1. Cache Composer's download cache (~/.composer/cache) keyed on composer.lock hash, so repeated CI runs don't re-download packages at all. 2. Configure GitHub OAuth token via SYNC_GITHUB_TOKEN secret to raise the rate limit to 5,000 req/hour for cache misses.
55 lines
1.5 KiB
YAML
55 lines
1.5 KiB
YAML
name: Tests
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- 'main'
|
|
- 'develop'
|
|
pull_request:
|
|
branches:
|
|
- 'main'
|
|
- 'develop'
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup PHP
|
|
uses: shivammathur/setup-php@v2
|
|
with:
|
|
php-version: '8.5'
|
|
extensions: apcu, mbstring
|
|
coverage: xdebug
|
|
ini-values: apc.enable_cli=1
|
|
|
|
# Authenticate to GitHub to raise API rate limit from 60 → 5,000 req/hour.
|
|
# Uses the same token that publish.yaml uses to sync to GitHub.
|
|
- name: Configure GitHub OAuth token
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.SYNC_GITHUB_TOKEN }}
|
|
run: composer config --global github-oauth.github.com "$GITHUB_TOKEN"
|
|
|
|
# Cache Composer's download cache so repeated CI runs don't re-download
|
|
# packages at all. Keyed on composer.lock hash — cache busts automatically
|
|
# when dependencies change.
|
|
- name: Cache Composer dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: ~/.composer/cache
|
|
key: composer-${{ runner.os }}-${{ hashFiles('composer.lock') }}
|
|
restore-keys: |
|
|
composer-${{ runner.os }}-
|
|
|
|
- name: Install dependencies
|
|
run: composer install --prefer-dist --no-progress
|
|
|
|
- name: Run php-cs-fixer
|
|
run: vendor/bin/php-cs-fixer fix --dry-run --diff
|
|
|
|
- name: Run tests
|
|
run: XDEBUG_MODE=coverage vendor/bin/phpunit --coverage-text
|