Skip to content

install composer as a tool of setup-php #21

install composer as a tool of setup-php

install composer as a tool of setup-php #21

Workflow file for this run

name: Install and test PIE package
permissions:
contents: read
on:
push: {}
pull_request: {}
workflow_dispatch:
inputs:
full-matrix:
description: "Run the full engine, host, and language version matrix"
type: boolean
default: false
jobs:
get-matrices:
runs-on: ubuntu-latest
outputs:
engine-matrix-output: ${{ steps.get-matrices.outputs.engine-matrix-output }}
host-matrix-output: ${{ steps.get-matrices.outputs.host-matrix-output }}
version-matrix-output: ${{ steps.get-matrices.outputs.version-matrix-output }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- id: get-matrices
uses: ./.github/workflows/create-test-matrices
with:
language-name: php
# Run full test matrix if job started by cron or it was explicitly specified by a person who triggered the workflow
run-full-matrix: ${{ github.event.inputs.full-matrix == 'true' || github.event_name == 'schedule' }}
test-pie-install:
name: PHP Tests - ${{ matrix.php }}, EngineVersion - ${{ matrix.engine.version }}, Target - ${{ matrix.host.TARGET }}
needs: get-matrices
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
php: ${{ fromJson(needs.get-matrices.outputs.version-matrix-output) }}
engine: ${{ fromJson(needs.get-matrices.outputs.engine-matrix-output) }}
host: ${{ fromJson(needs.get-matrices.outputs.host-matrix-output) }}
runs-on: ${{ matrix.host.RUNNER }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Output Matrix Parameters for this job
run: |
echo "Job running with the following matrix configuration:"
echo "${{ toJson(matrix) }}"
- name: Setup PHP Extension Build Environment
uses: ./.github/workflows/setup-php-extension
with:
php-version: ${{ matrix.php }}
install-composer-deps: "true"
target: ${{ matrix.host.TARGET }}
os: ${{ matrix.host.OS }}
- name: Create manual Composer repository
run: |
mkdir -p web
# Create packages.json manually
cat > web/packages.json << EOF
{
"packages": {
"valkey-io/valkey-glide-php": {
"1.0.0": {
"name": "valkey-io/valkey-glide-php",
"version": "1.0.0",
"version_normalized": "1.0.0.0",
"source": {
"type": "git",
"url": "${{ github.event.pull_request.head.repo.clone_url || format('{0}/{1}', github.server_url, github.repository) }}",
"reference": "${{ github.head_ref || github.ref_name }}"
},
"type": "php-ext",
"php-ext": {
"extension-name": "valkey_glide"
},
"description": "Valkey GLIDE PHP Extension",
"provide": {
"ext-valkey_glide": "*"
},
"require": {
"php": ">=8.1"
}
}
}
}
}
EOF
# Start HTTP server
cd web && python3 -m http.server 8000 &
echo $! > ../server.pid
# Wait for server to be ready with proper health check
echo "Waiting for HTTP server to start..."
for i in {1..30}; do
if curl -s http://localhost:8000/packages.json >/dev/null 2>&1; then
echo "HTTP server is ready"
break
fi
if [ $i -eq 30 ]; then
echo "HTTP server failed to start after 30 seconds"
exit 1
fi
sleep 1
done
- name: Test PIE with manual repository
run: |
# Allow HTTP for localhost for both user and root
composer config --global secure-http false
sudo composer config --global secure-http false
# Initialize composer config directories and fix permissions
mkdir -p "$HOME/.config/composer"
# Skip root directory creation on macOS due to SIP
if [[ "${{ matrix.host.OS }}" != "macos" ]]; then
sudo mkdir -p /root/.config/composer
fi
# Make sure root can read the user's composer config
sudo chmod -R 755 "$HOME/.config/composer"
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
sudo chown -R root:wheel "$HOME/.config/composer" || true
else
sudo chown -R root:root "$HOME/.config/composer" || true
fi
# Verify HTTP server is accessible before proceeding
echo "=== Verifying HTTP server accessibility ==="
curl -v http://localhost:8000/packages.json || {
echo "ERROR: Cannot access local HTTP server"
echo "Server process status:"
ps aux | grep "python.*http.server" || echo "No HTTP server process found"
echo "Port 8000 status:"
lsof -i :8000 || echo "Port 8000 not in use"
exit 1
}
# Add local repository
pie repository:add composer http://localhost:8000
# Test PIE installation
echo "=== Attempting PIE installation with verbose output ==="
set +e
# Make Rust available to root by preserving environment
sudo -E env "PATH=$PATH" pie install valkey-io/valkey-glide-php:1.0.0 --force --no-interaction -j1 -vvv 2>&1 | tee pie_install.log
PIE_EXIT_CODE=$?
set -e
echo "=== PIE exit code: $PIE_EXIT_CODE ==="
echo "=== PIE log content ==="
cat pie_install.log || echo "No PIE log found"
# Check if .so file was built regardless of exit code
echo "=== Checking if extension was built ==="
PIE_WORK_DIR=$(find "$HOME/.config/pie" -name "valkey-glide-php" -type d | head -1)
if [ -n "$PIE_WORK_DIR" ]; then
echo "PIE working directory: $PIE_WORK_DIR"
find "$PIE_WORK_DIR" -name "*.so" -type f 2>/dev/null && echo "SUCCESS: .so file was built!" || echo "No .so files found - build failed"
find "$PIE_WORK_DIR" -name "valkey_glide*" -type f 2>/dev/null | head -5 || echo "No valkey_glide files found"
echo "=== Contents of modules directory ==="
ls -la "$PIE_WORK_DIR/modules/" 2>/dev/null || echo "No modules directory"
echo "=== Contents of .libs directory ==="
ls -la "$PIE_WORK_DIR/.libs/" 2>/dev/null || echo "No .libs directory"
fi
if [ $PIE_EXIT_CODE -eq 0 ]; then
echo "=== PIE installation completed successfully ==="
echo "=== Shared object file location ==="
if [ -n "$PIE_WORK_DIR" ]; then
SO_FILE=$(find "$PIE_WORK_DIR" -name "valkey_glide.so" -type f 2>/dev/null | head -1)
if [ -n "$SO_FILE" ]; then
echo "SUCCESS: Shared object built at: $SO_FILE"
ls -la "$SO_FILE"
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"
else
echo "WARNING: PIE reported success but valkey_glide.so not found"
find "$PIE_WORK_DIR" -name "*.so" -type f 2>/dev/null || echo "No .so files found at all"
fi
fi
else
echo "=== PIE installation failed or had errors, showing debugging ==="
echo "=== Looking for PIE build output files ==="
find /tmp -name "pie_*output*" -type f -exec echo "File: {}" \; -exec cat {} \; 2>/dev/null || echo "No PIE output files found"
echo "=== Checking makefile debug log ==="
cat /tmp/makefile_debug.log 2>/dev/null || echo "No makefile debug log found"
echo "=== PIE working directory contents ==="
PIE_WORK_DIR=$(find "$HOME/.config/pie" -name "valkey-glide-php" -type d | head -1)
if [ -n "$PIE_WORK_DIR" ]; then
echo "PIE working directory: $PIE_WORK_DIR"
cd "$PIE_WORK_DIR"
ls -la
echo "=== Generated Makefile targets ==="
grep "^[a-zA-Z].*:" Makefile | head -10 2>/dev/null || echo "No Makefile found"
echo "=== Checking if Makefile.frag was included ==="
grep -A10 -B5 "Platform-specific configuration\|VALKEY_GLIDE_SHARED_LIBADD" Makefile 2>/dev/null || echo "Makefile.frag content not found in Makefile"
echo "=== Full Makefile.frag content ==="
cat Makefile.frag 2>/dev/null || echo "Cannot read Makefile.frag"
echo "=== valkey-glide directory contents ==="
ls -la valkey-glide/ 2>/dev/null || echo "valkey-glide directory not found"
echo "=== .gitmodules file ==="
cat .gitmodules 2>/dev/null || echo ".gitmodules not found"
echo "=== git submodule status ==="
git submodule status 2>/dev/null || echo "git submodule status failed"
echo "=== valkey-glide/ffi directory ==="
ls -la valkey-glide/ffi/ 2>/dev/null || echo "ffi directory not found"
echo "=== target directory ==="
ls -la valkey-glide/ffi/target/ 2>/dev/null || echo "target directory not found"
echo "=== Rust build artifacts ==="
find valkey-glide/ffi/target -name "*.h" 2>/dev/null | head -10 || echo "No Rust build artifacts found"
fi
fi
- name: Verify PIE installation
run: |
echo "=== Checking PHP extension directory ==="
php-config --extension-dir
ls -la $(php-config --extension-dir) | grep valkey || echo "valkey_glide.so not found in extension directory"
# Check if PIE installed to a different location (macOS Homebrew specific)
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
echo "=== Checking alternative extension locations ==="
find /opt/homebrew/lib/php -name "valkey_glide.so" 2>/dev/null || echo "No valkey_glide.so found in /opt/homebrew/lib/php"
# If found in alternative location, create symlink
ALT_SO=$(find /opt/homebrew/lib/php -name "valkey_glide.so" 2>/dev/null | head -1)
if [ -n "$ALT_SO" ] && [ ! -f "$(php-config --extension-dir)/valkey_glide.so" ]; then
echo "Found extension at: $ALT_SO"
echo "Creating symlink to: $(php-config --extension-dir)/valkey_glide.so"
sudo ln -sf "$ALT_SO" "$(php-config --extension-dir)/valkey_glide.so"
fi
fi
# If extension was built but not installed, install it manually
PIE_SO=$(find "$HOME/.config/pie" -name "valkey_glide.so" -type f 2>/dev/null | head -1)
if [ -n "$PIE_SO" ] && [ ! -f "$(php-config --extension-dir)/valkey_glide.so" ]; then
echo "Installing extension from: $PIE_SO"
sudo cp "$PIE_SO" "$(php-config --extension-dir)/valkey_glide.so"
echo "Extension installed to: $(php-config --extension-dir)/valkey_glide.so"
fi
echo "=== Looking for built extension in PIE working directory ==="
PIE_WORK_DIR=$(find "$HOME/.config/pie" -name "valkey-glide-php" -type d | head -1)
if [ -n "$PIE_WORK_DIR" ]; then
echo "PIE working directory: $PIE_WORK_DIR"
find "$PIE_WORK_DIR" -name "*.so" -type f 2>/dev/null || echo "No .so files found in PIE directory"
find "$PIE_WORK_DIR" -name "valkey_glide*" -type f 2>/dev/null || echo "No valkey_glide files found"
# Check if extension was built but not installed
SO_FILE=$(find "$PIE_WORK_DIR" -name "valkey_glide.so" -type f 2>/dev/null | head -1)
if [ -n "$SO_FILE" ]; then
echo "Extension was built at: $SO_FILE"
echo "But PIE failed to install it to: $(php-config --extension-dir)"
echo "=== Checking PIE install log for 'make install' ==="
grep -i "make install\|install.*valkey\|copying.*valkey" pie_install.log || echo "No 'make install' found in PIE log"
echo "=== Checking if PIE created ini file ==="
find /etc/php* -name "*valkey*" 2>/dev/null || echo "No PIE-generated ini files found"
echo "=== This indicates PIE build succeeded but install step failed ==="
else
echo "Extension was not built - build step failed"
fi
fi
echo "=== Checking if extension is loaded ==="
php -m | grep -i valkey || echo "valkey extension not loaded"
echo "=== Checking PHP configuration ==="
php --ini
echo "=== Looking for PIE-generated ini files ==="
if [[ "${{ matrix.host.OS }}" == "macos" ]]; then
find /opt/homebrew/etc/php* /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files found"
find /opt/homebrew/etc/php* /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files in /usr/local"
else
find /etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files found"
find /usr/local/etc/php* -name "*valkey*" 2>/dev/null || echo "No valkey ini files in /usr/local"
fi
echo "=== Manually enabling extension ==="
php -d extension=valkey_glide -m | grep -i valkey && echo "Extension works when manually enabled!" || echo "Extension still not working"
echo "=== Testing extension functionality ==="
php -d extension=valkey_glide -r "if (extension_loaded('valkey_glide')) { echo 'SUCCESS: Extension loaded and functional!'; } else { echo 'ERROR: Extension not functional'; }"
- name: Run PHP Extension Tests
uses: ./.github/workflows/run-php-tests
with:
extension-path: valkey_glide
php-version: ${{ matrix.php }}
- name: Cleanup
if: always()
run: |
if [ -f server.pid ]; then
kill $(cat server.pid) || true
fi