|
| 1 | +name: build-sidecar-client |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - '[0-9]+.[0-9]+.x' |
| 7 | + paths: |
| 8 | + - 'src/Sidecar/Client/**' |
| 9 | + - 'tests/Sidecar/Client/**' |
| 10 | + - 'rector-sidecar-client.php' |
| 11 | + - 'tools/rector/**' |
| 12 | + - 'tools/build-sidecar-client.sh' |
| 13 | + - '.github/workflows/build-sidecar-client.yml' |
| 14 | + - 'composer.json' |
| 15 | + - 'composer.lock' |
| 16 | + pull_request: |
| 17 | + branches: |
| 18 | + - '*' |
| 19 | + paths: |
| 20 | + - 'src/Sidecar/Client/**' |
| 21 | + - 'tests/Sidecar/Client/**' |
| 22 | + - 'rector-sidecar-client.php' |
| 23 | + - 'tools/rector/**' |
| 24 | + - 'tools/build-sidecar-client.sh' |
| 25 | + - '.github/workflows/build-sidecar-client.yml' |
| 26 | + - 'composer.json' |
| 27 | + - 'composer.lock' |
| 28 | + workflow_dispatch: |
| 29 | + |
| 30 | +jobs: |
| 31 | + build: |
| 32 | + name: Rector downgrade |
| 33 | + runs-on: ubuntu-latest |
| 34 | + steps: |
| 35 | + - uses: actions/checkout@v6 |
| 36 | + |
| 37 | + - name: Setup PHP |
| 38 | + uses: shivammathur/setup-php@v2 |
| 39 | + with: |
| 40 | + php-version: 8.5 |
| 41 | + coverage: none |
| 42 | + |
| 43 | + - name: Get Composer cache directory |
| 44 | + id: composer-cache |
| 45 | + run: echo "dir=$(composer config cache-files-dir)" >> "$GITHUB_OUTPUT" |
| 46 | + |
| 47 | + - name: Cache Composer dependencies |
| 48 | + uses: actions/cache@v5 |
| 49 | + with: |
| 50 | + path: ${{ steps.composer-cache.outputs.dir }} |
| 51 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 52 | + restore-keys: ${{ runner.os }}-composer- |
| 53 | + |
| 54 | + - name: Install monorepo dependencies (Rector + custom rules) |
| 55 | + run: composer install --prefer-dist --no-progress --no-suggest |
| 56 | + |
| 57 | + - name: Build downgraded artifact |
| 58 | + run: tools/build-sidecar-client.sh |
| 59 | + |
| 60 | + # Composer 1 was shut down on Packagist (2025-09-01) and Composer 2 |
| 61 | + # requires PHP >= 7.2.5, so we cannot run `composer install` on the |
| 62 | + # PHP 7.0 verifier. Pre-populate the artifact's vendor/ here on |
| 63 | + # PHP 8.5 with the phpunit constraint pinned to ~6.5.0 — the only |
| 64 | + # phpunit major that runs on PHP 7.0. --ignore-platform-req=php |
| 65 | + # lets the resolver target our PHP 7.0 floor while running on the |
| 66 | + # build host's 8.5. (--prefer-lowest alone is not robust here; |
| 67 | + # composer 2 on a recent host can still pick a higher PHPUnit |
| 68 | + # major within the artifact's "^6.5 || ^7 || ^8 || ^9" range, as |
| 69 | + # observed empirically on CI.) |
| 70 | + - name: Pre-install verification dependencies into artifact |
| 71 | + working-directory: build/sidecar-client |
| 72 | + run: | |
| 73 | + composer update --prefer-lowest --no-interaction --no-progress \ |
| 74 | + --ignore-platform-req=php \ |
| 75 | + --with 'phpunit/phpunit:~6.5.0' |
| 76 | +
|
| 77 | + - name: Upload artifact |
| 78 | + uses: actions/upload-artifact@v7 |
| 79 | + with: |
| 80 | + name: sidecar-client-build |
| 81 | + path: build/sidecar-client |
| 82 | + retention-days: 7 |
| 83 | + if-no-files-found: error |
| 84 | + |
| 85 | + verify-php70: |
| 86 | + name: Verify on PHP 7.0 |
| 87 | + needs: build |
| 88 | + runs-on: ubuntu-latest |
| 89 | + steps: |
| 90 | + - name: Download downgraded artifact |
| 91 | + uses: actions/download-artifact@v7 |
| 92 | + with: |
| 93 | + name: sidecar-client-build |
| 94 | + path: build/sidecar-client |
| 95 | + |
| 96 | + - name: Setup PHP 7.0 |
| 97 | + uses: shivammathur/setup-php@v2 |
| 98 | + with: |
| 99 | + php-version: '7.0' |
| 100 | + # pcntl is needed by SidecarClientTest, which spawns child |
| 101 | + # processes via pcntl_fork() to drive both ends of a Unix |
| 102 | + # socket round-trip. PHP 7.0's CLI image doesn't enable it |
| 103 | + # by default. |
| 104 | + extensions: pcntl |
| 105 | + coverage: none |
| 106 | + |
| 107 | + - name: Lint downgraded files |
| 108 | + working-directory: build/sidecar-client |
| 109 | + run: find . -name '*.php' -not -path './vendor/*' -print0 | xargs -0 -n 1 php -l |
| 110 | + |
| 111 | + - name: Run downgraded test suite (phpunit 6.5 on PHP 7.0) |
| 112 | + working-directory: build/sidecar-client |
| 113 | + # Invoke phpunit through `php` rather than executing it directly: |
| 114 | + # actions/upload-artifact and actions/download-artifact strip the |
| 115 | + # executable bit, so `vendor/bin/phpunit` returns exit 126 |
| 116 | + # (permission denied) when called as a binary. |
| 117 | + run: php vendor/bin/phpunit tests/ |
0 commit comments