Skip to content

Update PHP version matrix in GitHub workflow #32

Update PHP version matrix in GitHub workflow

Update PHP version matrix in GitHub workflow #32

Workflow file for this run

name: Build and Test PHP Extension
on:
push:
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
php-version: ['8.0', '8.1', '8.2', '8.3']
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up PHP ${{ matrix.php-version }}
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
extensions: mbstring, intl
- name: Enable core dumps
run: |
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p
ulimit -c unlimited
- name: Set PHP error logging
run: |
PHP_INI_DIR=$(php -i | grep "Loaded Configuration File" | sed -e "s|.*>\s*||")
PHP_INI_DIR=$(dirname "$PHP_INI_DIR")
echo "PHP INI directory: $PHP_INI_DIR"
if [ ! -d "$PHP_INI_DIR" ]; then
echo "Creating PHP INI directory"
sudo mkdir -p "$PHP_INI_DIR"
fi
echo "error_log = /tmp/php_errors.log" | sudo tee -a "$PHP_INI_DIR/php.ini"
echo "log_errors = On" | sudo tee -a "$PHP_INI_DIR/php.ini"
echo "PHP INI content:"
cat "$PHP_INI_DIR/php.ini"
- name: Display PHP Info
run: php -i
- name: Install build tools
run: sudo apt-get update && sudo apt-get install -y autoconf automake libtool bison re2c gdb
- name: Prepare build
run: |
phpize
./configure
make
- name: Run tests
run: make test
- name: Run demo
run: |
php -d extension=./modules/rayaop.so -i | grep rayaop
timeout 60s php -d extension=./modules/rayaop.so -d memory_limit=128M -d report_memleaks=1 -d zend.assertions=1 -d assert.exception=1 rayaop.php 2> php_stderr.log || true
- name: Check for segmentation fault
run: |
if grep -q "Segmentation fault" php_stderr.log; then
echo "Segmentation fault detected in php_stderr.log"
cat php_stderr.log
elif dmesg | grep -q "segfault"; then
echo "Segmentation fault detected in kernel logs"
dmesg | tail -n 20
elif [ -r /tmp/php_errors.log ]; then
echo "No segmentation fault detected, but php_errors.log is present"
cat /tmp/php_errors.log
else
echo "No segmentation fault detected and no php_errors.log present"
fi
if: always()
- name: Check for core dump
run: |
if ls /tmp/core-* 1> /dev/null 2>&1; then
echo "Core dump found"
ls -l /tmp/core-*
else
echo "No core dump found"
fi
if: always()
- name: Display core dump
run: |
for corefile in /tmp/core-*; do
if [ -f "$corefile" ]; then
echo "Processing core dump: $corefile"
gdb -q $(which php) "$corefile" -ex "thread apply all bt full" -ex "quit"
fi
done
if: always()
- name: Upload core dump
uses: actions/upload-artifact@v2
with:
name: core-dumps
path: /tmp/core-*
if: always()
- name: Upload logs as artifacts
uses: actions/upload-artifact@v2
with:
name: debug-logs
path: |
/tmp/php_errors.log
php_stderr.log
if-no-files-found: warn
if: always()