Skip to content

feat(bucketing)!: anchored bucketing layout (contract v12) — PHP SDK #38

feat(bucketing)!: anchored bucketing layout (contract v12) — PHP SDK

feat(bucketing)!: anchored bucketing layout (contract v12) — PHP SDK #38

Workflow file for this run

name: Quality Checks
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
generated-guard:
name: Generated Types Guard
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Enforce generated-file marker (OpenAPI types)
# Catches hand-edits to files under packages/Types/lib/Generated/.
# Every .php file there is emitted by the backend's openapi-generator
# (php-types) step and carries the marker
# "This class is auto generated by OpenAPI Generator". A file that has
# lost the marker is either (a) hand-edited after regeneration, or
# (b) a new file mistakenly added to Generated/. Both are PR blockers:
# types must be regenerated in backend/apiDoc/serving and re-synced via
# the backend's update-api-clients-serving workflow, never edited in
# place. Mirrors the android-sdk precedent (.github/workflows/ci.yml).
#
# Unlike android (which greps head -1 for its marker), the PHP marker
# sits inside the file's docblock (files start with "<?php"), so the
# grep must scan the whole file. The whitelist covers ALL generated
# .php files — Model/ AND the non-Model infra (Api/, ObjectSerializer,
# Configuration, HeaderSelector, ApiException) — not just Model/.
run: |
set -euo pipefail
GEN_DIR=packages/Types/lib/Generated
MARKER="This class is auto generated by OpenAPI Generator"
if [ ! -d "$GEN_DIR" ]; then
echo "ERROR: generated directory not found: $GEN_DIR"
exit 1
fi
missing=0
while IFS= read -r -d '' file; do
if ! grep -qF "$MARKER" "$file"; then
echo "ERROR: $file is missing the OpenAPI generated-file marker."
echo " Regenerate the PHP types in backend/apiDoc/serving"
echo " (yarn generatePhpTypes) and re-sync via the backend's"
echo " update-api-clients-serving workflow. Do not hand-edit"
echo " files under $GEN_DIR."
missing=1
fi
done < <(find "$GEN_DIR" -name '*.php' -print0)
if [ "$missing" -ne 0 ]; then
exit 1
fi
echo "OK: every .php file under $GEN_DIR carries the OpenAPI generated-file marker."
lint:
name: Code Style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer:v2
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- run: composer install --no-interaction --no-progress
- run: composer cs-check
validate:
name: Monorepo Validation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.4'
tools: composer:v2
coverage: none
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-${{ hashFiles('composer.json') }}
restore-keys: composer-
- run: composer install --no-interaction --no-progress
- run: composer build:validate
test:
name: Tests (PHP ${{ matrix.php-version }}, ${{ matrix.dependency-preference }})
runs-on: ubuntu-latest
env:
CONVERT_STAGING_SDK_KEY: ${{ secrets.CONVERT_STAGING_SDK_KEY }}
CONVERT_STAGING_SDK_KEY2: ${{ secrets.CONVERT_STAGING_SDK_KEY2 }}
CONVERT_STAGING_SDK_KEY2_SECRET: ${{ secrets.CONVERT_STAGING_SDK_KEY2_SECRET }}
strategy:
fail-fast: false
matrix:
php-version: ['8.2', '8.3', '8.4']
dependency-preference: ['prefer-lowest', 'prefer-stable']
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
coverage: pcov
- name: Cache Composer dependencies
uses: actions/cache@v4
with:
path: ~/.composer/cache
key: composer-php${{ matrix.php-version }}-${{ matrix.dependency-preference }}-${{ hashFiles('composer.json') }}
restore-keys: |
composer-php${{ matrix.php-version }}-${{ matrix.dependency-preference }}-
composer-php${{ matrix.php-version }}-
- name: Install dependencies
run: composer update --${{ matrix.dependency-preference }} --prefer-stable --no-interaction --no-progress
- name: Run tests with coverage
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
run: composer test:coverage:ci
- name: Enforce 85% coverage threshold
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
run: |
php -r "
\$x = new SimpleXMLElement(file_get_contents('coverage.xml'));
\$m = \$x->project->metrics;
\$statements = (int)\$m['statements'];
if (\$statements === 0) { echo 'Error: zero statements in coverage report'; exit(1); }
\$pct = round(((int)\$m['coveredstatements'] / \$statements) * 100, 2);
echo \"Code coverage: {\$pct}%\n\";
exit(\$pct >= 85.0 ? 0 : 1);
"
- name: Upload coverage report
if: matrix.php-version == '8.4' && matrix.dependency-preference == 'prefer-stable'
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: coverage.xml
retention-days: 30
- name: Run tests without coverage
if: matrix.php-version != '8.4' || matrix.dependency-preference != 'prefer-stable'
run: composer test
- name: Run cross-SDK parity tests
run: composer test:cross-sdk