Skip to content

chore: sync PHP client with Apify OpenAPI spec v2-2026-08-05T133145Z #16

chore: sync PHP client with Apify OpenAPI spec v2-2026-08-05T133145Z

chore: sync PHP client with Apify OpenAPI spec v2-2026-08-05T133145Z #16

name: PHP integration tests
# Language-specific workflow: only runs for the PHP client. Triggers on PRs to master that touch
# PHP client, test, example, or documentation code, and can be dispatched manually from any branch.
on:
pull_request:
branches: [master]
paths:
- '**/*.php'
- 'composer.json'
- 'composer.lock'
- '.php-cs-fixer.dist.php'
- 'phpstan.neon.dist'
- 'phpunit.xml.dist'
# The "Test examples" step validates the in-documentation snippets, so doc changes must
# re-run the workflow even though Markdown is not PHP code.
- 'docs/**'
- 'README.md'
- '.github/workflows/php-integration-tests.yml'
workflow_dispatch:
# Avoid concurrent runs of the same ref racing on the shared test account.
concurrency:
group: php-integration-${{ github.ref }}
cancel-in-progress: true
jobs:
# Offline unit tests on a build WITH the PECL brotli extension, so the real brotli codec round-trip
# (testRealBrotliRoundTripsWhenExtensionPresent) actually runs instead of self-skipping. The main
# `test` job deliberately omits brotli, so between the two jobs both request-compression codecs
# (brotli and the gzip fallback) get genuine real-codec coverage in CI. This job needs no API token.
unit-brotli:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up PHP (with brotli)
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, json, curl, zlib, brotli
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
- name: Fail if brotli extension missing
run: |
if ! php -r "exit(extension_loaded('brotli') ? 0 : 1);"; then
echo "::error::brotli extension failed to load; the real brotli codec test would silently skip."
exit 1
fi
- name: Unit tests (brotli path)
run: vendor/bin/phpunit --testsuite unit
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: mbstring, json, curl, zlib
coverage: none
tools: composer:v2
- name: Install dependencies
run: composer install --no-interaction --prefer-dist --no-progress
# The formatter/lint gate mandated by the coding rules (PSR-12 via php-cs-fixer).
- name: Check formatting (php-cs-fixer)
run: composer lint
# Static-analysis gate mandated by the coding rules.
- name: Static analysis (PHPStan)
run: composer stan
# Offline unit tests (mock transport): prove the retry/error/signature logic without the API.
- name: Unit tests
run: vendor/bin/phpunit --testsuite unit
# Fail fast if the integration-test secret is missing or empty. Without this guard the
# integration tests silently "pass" (they self-skip when APIFY_TOKEN is unset), so a green run
# would not prove the API logic actually executed.
- name: Require APIFY_TOKEN secret
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: |
if [ -z "${APIFY_TOKEN}" ]; then
echo "::error::APIFY_TOKEN secret is empty or missing; integration tests would not run against the API."
exit 1
fi
- name: Integration tests
env:
# The integration-test token is stored as a repository secret.
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: vendor/bin/phpunit --testsuite integration
# Standalone CI step that verifies the documentation examples work end-to-end against the live
# API (ExamplesTest runs each example) and that every in-documentation PHP snippet is valid,
# runnable code (DocSnippetsTest lints each fenced block).
- name: Test examples
env:
APIFY_TOKEN: ${{ secrets.APIFY_TOKEN }}
run: vendor/bin/phpunit --testsuite examples