Skip to content

Commit 6861bc6

Browse files
authored
Merge pull request #663 from reliforp/claude/fix-sidecar-ffi-requirements-9ops4
Add PHP 7.0 downgrade tooling for sidecar client distribution
2 parents 67fc6a4 + 01d142d commit 6861bc6

16 files changed

Lines changed: 751 additions & 10 deletions
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
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/
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
name: publish-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/publish-sidecar-client.yml'
14+
- 'composer.json'
15+
- 'composer.lock'
16+
tags:
17+
- 'v*'
18+
workflow_dispatch:
19+
20+
# We use an SSH deploy key for the mirror; no GITHUB_TOKEN write needed here.
21+
permissions:
22+
contents: read
23+
24+
jobs:
25+
publish:
26+
name: Publish to reli-prof-sidecar-client mirror
27+
runs-on: ubuntu-latest
28+
steps:
29+
- uses: actions/checkout@v6
30+
31+
- name: Setup PHP
32+
uses: shivammathur/setup-php@v2
33+
with:
34+
php-version: 8.5
35+
coverage: none
36+
37+
- name: Install monorepo dependencies (Rector + custom rules)
38+
run: composer install --prefer-dist --no-progress --no-suggest
39+
40+
- name: Build downgraded artifact
41+
run: tools/build-sidecar-client.sh
42+
43+
- name: Configure SSH for mirror push
44+
env:
45+
DEPLOY_KEY: ${{ secrets.SIDECAR_CLIENT_MIRROR_DEPLOY_KEY }}
46+
run: |
47+
mkdir -p ~/.ssh
48+
chmod 700 ~/.ssh
49+
printf '%s\n' "$DEPLOY_KEY" > ~/.ssh/id_ed25519
50+
chmod 600 ~/.ssh/id_ed25519
51+
ssh-keyscan github.com >> ~/.ssh/known_hosts 2>/dev/null
52+
git config --global user.name "reli-prof publish bot"
53+
git config --global user.email "noreply@reli-prof.dev"
54+
55+
- name: Clone mirror repository
56+
run: git clone git@github.com:reliforp/reli-prof-sidecar-client.git mirror
57+
58+
- name: Sync artifact into mirror (preserve .git, .github, README.md)
59+
run: |
60+
cd mirror
61+
# Wipe everything except mirror-side hand-maintained tooling:
62+
# .git/ — repository state
63+
# .github/ — mirror-only workflows (e.g. PR-to-upstream redirect)
64+
# README.md — explains that this repo is a generated mirror
65+
find . -mindepth 1 -maxdepth 1 \
66+
-not -name '.git' \
67+
-not -name '.github' \
68+
-not -name 'README.md' \
69+
-exec rm -rf {} +
70+
# Copy build artifact contents (the trailing /. copies the
71+
# contents of the directory, not the directory itself).
72+
cp -a ../build/sidecar-client/. .
73+
74+
- name: Commit and push to mirror main
75+
env:
76+
UPSTREAM_SHA: ${{ github.sha }}
77+
UPSTREAM_REF: ${{ github.ref_name }}
78+
run: |
79+
cd mirror
80+
git add -A
81+
if git diff --cached --quiet; then
82+
echo "No changes to publish; mirror is already up to date."
83+
exit 0
84+
fi
85+
git commit -m "Sync from upstream ${UPSTREAM_REF}@${UPSTREAM_SHA:0:12}
86+
87+
Source: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}
88+
Workflow: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
89+
git push origin main
90+
91+
- name: Tag mirror on upstream tag push
92+
if: github.ref_type == 'tag'
93+
env:
94+
TAG_NAME: ${{ github.ref_name }}
95+
run: |
96+
cd mirror
97+
git tag "$TAG_NAME"
98+
git push origin "$TAG_NAME"

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
vendor
22
.phpunit.cache
33
.claude/
4+
/build/

composer.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
"monolog/monolog": "3.10.0",
3232
"webmozart/assert": "2.3.0"
3333
},
34+
"replace": {
35+
"reliforp/reli-prof-sidecar-client": "self.version"
36+
},
3437
"require-dev": {
3538
"ext-posix": "*",
3639
"phpunit/phpunit": "13.1.7",
@@ -39,7 +42,8 @@
3942
"jetbrains/phpstorm-stubs": "2025.3",
4043
"php-coveralls/php-coveralls": "2.9.1",
4144
"psalm/phar": "^6.0",
42-
"brianium/paratest": "^7.22"
45+
"brianium/paratest": "^7.22",
46+
"rector/rector": "^2.4"
4347
},
4448
"autoload": {
4549
"files": ["src/Lib/Defer/defer.php"],
@@ -50,7 +54,8 @@
5054
"autoload-dev": {
5155
"psr-4": {
5256
"Reli\\": "tests",
53-
"Reli\\Command\\": "tests/Command/CommandEnumeratorTestData"
57+
"Reli\\Command\\": "tests/Command/CommandEnumeratorTestData",
58+
"Reli\\Tools\\Rector\\": "tools/rector"
5459
}
5560
},
5661
"bin": [

composer.lock

Lines changed: 115 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)