Skip to content

Commit 81c92f8

Browse files
Merge pull request #45 from jamesx-improving/ci/jamesx-test-pie-mac-2nd-fix
CI: test-pie CI on mac 2nd fix
2 parents 8eaedc9 + 48ffe59 commit 81c92f8

File tree

9 files changed

+115
-196
lines changed

9 files changed

+115
-196
lines changed

.github/workflows/build-php-wrapper/action.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ runs:
2525
with:
2626
php-version: ${{ inputs.php-version }}
2727
extensions: tokenizer, json, ctype, iconv, mbstring
28-
tools: none
28+
tools: composer
2929
env:
3030
runner: self-hosted
3131

@@ -56,7 +56,7 @@ runs:
5656
if: ${{ inputs.os == 'macos' }}
5757
shell: bash
5858
run: |
59-
brew install autoconf automake libtool pkg-config protobuf@3 openssl clang-format
59+
brew install autoconf automake libtool pkg-config protobuf openssl clang-format
6060
6161
- name: Install protobuf compiler (Ubuntu)
6262
if: ${{ inputs.os == 'ubuntu' }}
@@ -73,7 +73,6 @@ runs:
7373
if: ${{ inputs.os == 'macos' }}
7474
shell: bash
7575
run: |
76-
echo 'export PATH="/opt/homebrew/opt/protobuf@3/bin:$PATH"' >> $GITHUB_ENV
7776
# Install protobuf-c
7877
brew install protobuf-c
7978

.github/workflows/install-zig/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ runs:
66
- name: Install zig
77
shell: bash
88
run: |
9-
if [[ `cat /etc/os-release | grep "Amazon Linux"` ]]; then
9+
if [[ "$OSTYPE" == "darwin"* ]]; then
10+
echo "macOS detected, pip3 already available"
11+
elif [[ `cat /etc/os-release | grep "Amazon Linux"` ]]; then
1012
yum install -y python3-pip
1113
else
1214
sudo apt install -y python3-pip

.github/workflows/php.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ jobs:
219219
- name: Install shared dependencies
220220
uses: ./.github/workflows/install-shared-dependencies
221221
with:
222-
target: x86_64-apple-darwin
222+
# "macos-latest" is actually an ARM runner, hence using the ARM target for mac here
223+
target: aarch64-apple-darwin
223224
github-token: ${{ secrets.GITHUB_TOKEN }}
224225
engine-version: ${{ matrix.engine.version }}
225226

.github/workflows/run-php-tests/action.yml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -77,43 +77,40 @@ runs:
7777
env:
7878
EXTENSION_PATH: ${{ inputs.extension-path }}
7979
run: |
80-
# Debug: Check if extension is loaded and classes exist
81-
echo "=== Extension Debug Info ==="
82-
echo "Extension path: $EXTENSION_PATH"
80+
# Find the actual .so file location
81+
SO_FILE=""
8382
84-
# Check if this is a file path or extension name
83+
# Check common locations
8584
if [[ -f "$EXTENSION_PATH" ]]; then
86-
echo "Loading extension from file: $EXTENSION_PATH"
87-
EXTENSION_ARG="extension=$EXTENSION_PATH"
85+
SO_FILE="$EXTENSION_PATH"
86+
elif [[ -f "$(php-config --extension-dir)/${EXTENSION_PATH}.so" ]]; then
87+
SO_FILE="$(php-config --extension-dir)/${EXTENSION_PATH}.so"
8888
else
89-
echo "Loading extension by name: $EXTENSION_PATH"
90-
EXTENSION_ARG="extension=$EXTENSION_PATH"
89+
# Search for the extension in common PHP directories
90+
for dir in /opt/homebrew/lib/php/pecl /opt/homebrew/Cellar/php*/*/pecl /usr/lib/php; do
91+
FOUND=$(find "$dir" -name "${EXTENSION_PATH}.so" 2>/dev/null | head -1)
92+
if [[ -n "$FOUND" ]]; then
93+
SO_FILE="$FOUND"
94+
break
95+
fi
96+
done
97+
fi
98+
99+
if [[ -z "$SO_FILE" ]]; then
100+
echo "ERROR: Extension .so file not found"
101+
exit 1
91102
fi
92103
93-
php -n -d "$EXTENSION_ARG" -r "
104+
echo "=== Extension Debug Info ==="
105+
echo "Found extension at: $SO_FILE"
106+
107+
php -n -d "extension=$SO_FILE" -r "
94108
echo 'Extension loaded: ' . (extension_loaded('valkey_glide') ? 'YES' : 'NO') . PHP_EOL;
95-
echo 'Extension version: ' . phpversion('valkey_glide') . PHP_EOL;
96-
echo 'Extension functions: ' . PHP_EOL;
97-
foreach (get_extension_funcs('valkey_glide') as \$func) {
98-
echo ' - ' . \$func . PHP_EOL;
99-
}
100-
echo 'All declared classes: ' . PHP_EOL;
101-
foreach (get_declared_classes() as \$class) {
102-
if (strpos(\$class, 'Valkey') !== false || strpos(\$class, 'Client') !== false || strpos(\$class, 'Mock') !== false) {
103-
echo ' - ' . \$class . PHP_EOL;
104-
}
105-
}
106109
echo 'ClientConstructorMock exists: ' . (class_exists('ClientConstructorMock') ? 'YES' : 'NO') . PHP_EOL;
107-
if (class_exists('ClientConstructorMock')) {
108-
echo 'ClientConstructorMock methods: ' . PHP_EOL;
109-
foreach (get_class_methods('ClientConstructorMock') as \$method) {
110-
echo ' - ' . \$method . PHP_EOL;
111-
}
112-
}
113110
"
114111
115-
# Run tests using extension loading
116-
php -n -d "$EXTENSION_ARG" tests/TestValkeyGlide.php
112+
# Run tests
113+
php -n -d "extension=$SO_FILE" tests/TestValkeyGlide.php
117114
118115
- name: Run integration tests
119116
shell: bash

.github/workflows/setup-php-extension/action.yml

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,35 @@ inputs:
1010
description: Whether to install composer dependencies
1111
required: false
1212
default: "true"
13+
target:
14+
description: "Specified target for rust toolchain, ex. x86_64-apple-darwin"
15+
type: string
16+
required: false
17+
defalt: "x86_64-unknown-linux-gnu"
18+
options:
19+
- x86_64-unknown-linux-gnu
20+
- aarch64-unknown-linux-gnu
21+
- x86_64-apple-darwin
22+
- aarch64-apple-darwin
23+
- aarch64-unknown-linux-musl
24+
- x86_64-unknown-linux-musl
25+
os:
26+
description: "The current operating system"
27+
required: true
28+
type: string
29+
options:
30+
- amazon-linux
31+
- macos
32+
- ubuntu
1333

1434
runs:
1535
using: composite
1636
steps:
1737
- name: Install shared dependencies
1838
uses: ./.github/workflows/install-shared-dependencies
1939
with:
20-
target: x86_64-unknown-linux-gnu
40+
os: ${{ inputs.os }}
41+
target: ${{ inputs.target }}
2142
github-token: ${{ github.token }}
2243
engine-version: "7.2.5"
2344

@@ -28,7 +49,8 @@ runs:
2849
extensions: none
2950
tools: pie, jq
3051

31-
- name: Install system dependencies
52+
- name: Install system dependencies for Ubuntu
53+
if: inputs.os == 'ubuntu'
3254
shell: bash
3355
env:
3456
PHP_VERSION: ${{ inputs.php-version }}
@@ -49,6 +71,12 @@ runs:
4971
libprotobuf-c-dev \
5072
libprotobuf-c1
5173
74+
- name: Install system dependencies for macOS
75+
if: inputs.os == 'macos'
76+
shell: bash
77+
run: |
78+
brew install autoconf automake libtool pkg-config protobuf-c clang-format
79+
5280
- name: Install Rust and protoc
5381
uses: ./.github/workflows/install-rust-and-protoc
5482
with:

.github/workflows/test-pie.yml

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ jobs:
5858
with:
5959
php-version: ${{ matrix.php }}
6060
install-composer-deps: "true"
61+
target: ${{ matrix.host.TARGET }}
62+
os: ${{ matrix.host.OS }}
6163

6264
- name: Create manual Composer repository
6365
run: |
@@ -97,7 +99,20 @@ jobs:
9799
# Start HTTP server
98100
cd web && python3 -m http.server 8000 &
99101
echo $! > ../server.pid
100-
sleep 3
102+
103+
# Wait for server to be ready with proper health check
104+
echo "Waiting for HTTP server to start..."
105+
for i in {1..30}; do
106+
if curl -s http://localhost:8000/packages.json >/dev/null 2>&1; then
107+
echo "HTTP server is ready"
108+
break
109+
fi
110+
if [ $i -eq 30 ]; then
111+
echo "HTTP server failed to start after 30 seconds"
112+
exit 1
113+
fi
114+
sleep 1
115+
done
101116
102117
- name: Test PIE with manual repository
103118
run: |
@@ -107,7 +122,10 @@ jobs:
107122
108123
# Initialize composer config directories and fix permissions
109124
mkdir -p "$HOME/.config/composer"
110-
sudo mkdir -p /root/.config/composer
125+
# Skip root directory creation on macOS due to SIP
126+
if [[ "${{ matrix.host.OS }}" != "macos" ]]; then
127+
sudo mkdir -p /root/.config/composer
128+
fi
111129
112130
# Make sure root can read the user's composer config
113131
sudo chmod -R 755 "$HOME/.config/composer"
@@ -117,6 +135,17 @@ jobs:
117135
sudo chown -R root:root "$HOME/.config/composer" || true
118136
fi
119137
138+
# Verify HTTP server is accessible before proceeding
139+
echo "=== Verifying HTTP server accessibility ==="
140+
curl -v http://localhost:8000/packages.json || {
141+
echo "ERROR: Cannot access local HTTP server"
142+
echo "Server process status:"
143+
ps aux | grep "python.*http.server" || echo "No HTTP server process found"
144+
echo "Port 8000 status:"
145+
lsof -i :8000 || echo "Port 8000 not in use"
146+
exit 1
147+
}
148+
120149
# Add local repository
121150
pie repository:add composer http://localhost:8000
122151
@@ -201,6 +230,28 @@ jobs:
201230
php-config --extension-dir
202231
ls -la $(php-config --extension-dir) | grep valkey || echo "valkey_glide.so not found in extension directory"
203232
233+
# Check if PIE installed to a different location (macOS Homebrew specific)
234+
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
235+
echo "=== Checking alternative extension locations ==="
236+
find /opt/homebrew/lib/php -name "valkey_glide.so" 2>/dev/null || echo "No valkey_glide.so found in /opt/homebrew/lib/php"
237+
238+
# If found in alternative location, create symlink
239+
ALT_SO=$(find /opt/homebrew/lib/php -name "valkey_glide.so" 2>/dev/null | head -1)
240+
if [ -n "$ALT_SO" ] && [ ! -f "$(php-config --extension-dir)/valkey_glide.so" ]; then
241+
echo "Found extension at: $ALT_SO"
242+
echo "Creating symlink to: $(php-config --extension-dir)/valkey_glide.so"
243+
sudo ln -sf "$ALT_SO" "$(php-config --extension-dir)/valkey_glide.so"
244+
fi
245+
fi
246+
247+
# If extension was built but not installed, install it manually
248+
PIE_SO=$(find "$HOME/.config/pie" -name "valkey_glide.so" -type f 2>/dev/null | head -1)
249+
if [ -n "$PIE_SO" ] && [ ! -f "$(php-config --extension-dir)/valkey_glide.so" ]; then
250+
echo "Installing extension from: $PIE_SO"
251+
sudo cp "$PIE_SO" "$(php-config --extension-dir)/valkey_glide.so"
252+
echo "Extension installed to: $(php-config --extension-dir)/valkey_glide.so"
253+
fi
254+
204255
echo "=== Looking for built extension in PIE working directory ==="
205256
PIE_WORK_DIR=$(find "$HOME/.config/pie" -name "valkey-glide-php" -type d | head -1)
206257
if [ -n "$PIE_WORK_DIR" ]; then

.vscode/launch.json

Lines changed: 0 additions & 32 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 86 deletions
This file was deleted.

0 commit comments

Comments
 (0)