Skip to content

Commit 818d8f5

Browse files
CI: Fix test-pie CI on mac (#44)
Generate different semantics for the URL and reference for PRs vs. branch references Signed-off-by: James Duong <[email protected]> Co-authored-by: James Xin <[email protected]>
1 parent 2ddbc79 commit 818d8f5

File tree

2 files changed

+38
-29
lines changed

2 files changed

+38
-29
lines changed

.github/json_matrices/build-matrix.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"TARGET": "x86_64-unknown-linux-gnu",
88
"PACKAGE_MANAGERS": ["pypi", "npm", "maven", "pkg_go_dev"],
99
"run": "always",
10-
"languages": ["python", "node", "java", "go", "dotnet", "rust"]
10+
"languages": ["python", "node", "java", "go", "dotnet", "rust", "php"]
1111
},
1212
{
1313
"OS": "ubuntu",
@@ -17,7 +17,7 @@
1717
"ARCH": "arm64",
1818
"TARGET": "aarch64-unknown-linux-gnu",
1919
"PACKAGE_MANAGERS": ["pypi", "npm", "maven", "pkg_go_dev"],
20-
"languages": ["python", "node", "java", "go", "dotnet"]
20+
"languages": ["python", "node", "java", "go", "dotnet", "php"]
2121
},
2222
{
2323
"OS": "macos",
@@ -26,7 +26,7 @@
2626
"ARCH": "arm64",
2727
"TARGET": "aarch64-apple-darwin",
2828
"PACKAGE_MANAGERS": ["pypi", "npm", "maven", "pkg_go_dev"],
29-
"languages": ["python", "node", "java", "go", "dotnet"]
29+
"languages": ["python", "node", "java", "go", "dotnet", "php"]
3030
},
3131
{
3232
"OS": "macos",

.github/workflows/test-pie.yml

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ permissions:
66
on:
77
push: {}
88
pull_request: {}
9+
workflow_dispatch:
10+
inputs:
11+
full-matrix:
12+
description: "Run the full engine, host, and language version matrix"
13+
type: boolean
14+
default: false
915

1016
jobs:
1117
get-matrices:
@@ -25,7 +31,7 @@ jobs:
2531
# Run full test matrix if job started by cron or it was explicitly specified by a person who triggered the workflow
2632
run-full-matrix: ${{ github.event.inputs.full-matrix == 'true' || github.event_name == 'schedule' }}
2733

28-
test-php:
34+
test-pie-install:
2935
name: PHP Tests - ${{ matrix.php }}, EngineVersion - ${{ matrix.engine.version }}, Target - ${{ matrix.host.TARGET }}
3036
needs: get-matrices
3137
timeout-minutes: 35
@@ -47,33 +53,27 @@ jobs:
4753
echo "Job running with the following matrix configuration:"
4854
echo "${{ toJson(matrix) }}"
4955
50-
test-pie-install:
51-
name: PHP Tests - ${{ matrix.php }}, EngineVersion - ${{ matrix.engine.version }}, Target - ${{ matrix.host.TARGET }}
52-
needs: get-matrices
53-
timeout-minutes: 35
54-
strategy:
55-
fail-fast: false
56-
matrix:
57-
php: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }}
58-
engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }}
59-
host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output) }}
60-
runs-on: ${{ matrix.host.RUNNER }}
61-
62-
steps:
63-
- uses: actions/checkout@v4
64-
with:
65-
submodules: recursive
66-
6756
- name: Setup PHP Extension Build Environment
6857
uses: ./.github/workflows/setup-php-extension
6958
with:
70-
php-version: ${{ env.BASE_PHP_VERSION }}
59+
php-version: ${{ matrix.php }}
7160
install-composer-deps: "true"
7261

7362
- name: Create manual Composer repository
7463
run: |
7564
mkdir -p web
7665
66+
# Determine the correct repository URL and reference for PRs vs direct pushes
67+
if [ "${{ github.event_name }}" = "pull_request" ]; then
68+
REPO_URL="${{ github.event.pull_request.head.repo.clone_url }}"
69+
REPO_REF="${{ github.event.pull_request.head.sha }}"
70+
echo "Using PR head repository: $REPO_URL at $REPO_REF"
71+
else
72+
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
73+
REPO_REF="${{ github.sha }}"
74+
echo "Using main repository: $REPO_URL at $REPO_REF"
75+
fi
76+
7777
# Create packages.json manually
7878
cat > web/packages.json << EOF
7979
{
@@ -85,8 +85,8 @@ jobs:
8585
"version_normalized": "1.0.0.0",
8686
"source": {
8787
"type": "git",
88-
"url": "${{ github.event.pull_request.head.repo.clone_url || format('{0}/{1}', github.server_url, github.repository) }}",
89-
"reference": "${{ github.head_ref || github.ref_name }}"
88+
"url": "$REPO_URL",
89+
"reference": "$REPO_REF"
9090
},
9191
"type": "php-ext",
9292
"php-ext": {
@@ -122,7 +122,11 @@ jobs:
122122
123123
# Make sure root can read the user's composer config
124124
sudo chmod -R 755 "$HOME/.config/composer"
125-
sudo chown -R root:root "$HOME/.config/composer" || true
125+
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
126+
sudo chown -R root:wheel "$HOME/.config/composer" || true
127+
else
128+
sudo chown -R root:root "$HOME/.config/composer" || true
129+
fi
126130
127131
# Add local repository
128132
pie repository:add composer http://localhost:8000
@@ -160,7 +164,7 @@ jobs:
160164
if [ -n "$SO_FILE" ]; then
161165
echo "SUCCESS: Shared object built at: $SO_FILE"
162166
ls -la "$SO_FILE"
163-
echo "File size: $(stat -c%s "$SO_FILE" 2>/dev/null || echo "unknown") bytes"
167+
echo "File size: $(if [[ "${{ matrix.host.OS }}" == "macos" ]]; then stat -f%z "$SO_FILE" 2>/dev/null; else stat -c%s "$SO_FILE" 2>/dev/null; fi || echo "unknown") bytes"
164168
else
165169
echo "WARNING: PIE reported success but valkey_glide.so not found"
166170
find "$PIE_WORK_DIR" -name "*.so" -type f 2>/dev/null || echo "No .so files found at all"
@@ -237,8 +241,13 @@ jobs:
237241
php --ini
238242
239243
echo "=== Looking for PIE-generated ini files ==="
240-
find /etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files found"
241-
find /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files in /usr/local"
244+
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
245+
find /opt/homebrew/etc/php* /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files found"
246+
find /opt/homebrew/etc/php* /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files in /usr/local"
247+
else
248+
find /etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files found"
249+
find /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files in /usr/local"
250+
fi
242251
243252
echo "=== Manually enabling extension ==="
244253
php -d extension=valkey_glide -m | grep -i valkey && echo "Extension works when manually enabled!" || echo "Extension still not working"
@@ -250,7 +259,7 @@ jobs:
250259
uses: ./.github/workflows/run-php-tests
251260
with:
252261
extension-path: valkey_glide
253-
php-version: ${{ env.BASE_PHP_VERSION }}
262+
php-version: ${{ matrix.php }}
254263

255264
- name: Cleanup
256265
if: always()

0 commit comments

Comments
 (0)