Skip to content

Rewrite to be based on php-build #641

Rewrite to be based on php-build

Rewrite to be based on php-build #641

Workflow file for this run

name: Main workflow
on:
pull_request:
types:
- opened
- synchronize
- reopened
paths-ignore:
- "**.md"
push:
branches:
- master
- main
paths-ignore:
- "**.md"
schedule:
- cron: 0 0 * * 5
jobs:
plugin_test:
strategy:
fail-fast: false
matrix:
os:
- os: ubuntu-latest
version: 8.0.0
# will uncomment later; currently focus on php 8.0.0
# - os: ubuntu-latest
# version: 7.4.14
# - os: ubuntu-latest
# version: latest
# will uncomment later; currently focus on linux
# - os: macos-latest
# version: 8.0.0
# - os: macos-latest
# version: 7.4.14
# - os: macos-latest
# version: latest
runs-on: ${{ matrix.os.os }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize submodule and set permissions
run: |
git submodule update --init --recursive
chmod +x bin/* lib/*
- name: Install system packages on Ubuntu
if: ${{ runner.os == 'Linux' }}
run: |
if command -v sudo >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y autoconf bison build-essential curl gettext git libgd-dev libcurl4-openssl-dev libedit-dev libicu-dev libjpeg-dev libmysqlclient-dev libonig-dev libpng-dev libpq-dev libreadline-dev libsqlite3-dev libssl-dev libxml2-dev libzip-dev libtidy-dev openssl pkg-config re2c zlib1g-dev ca-certificates wget libtool automake gcc-9 g++-9 libxslt
else
apt-get update
apt-get install -y autoconf bison build-essential curl gettext git libgd-dev libcurl4-openssl-dev libedit-dev libicu-dev libjpeg-dev libmysqlclient-dev libonig-dev libpng-dev libpq-dev libreadline-dev libsqlite3-dev libssl-dev libxml2-dev libzip-dev libtidy-dev openssl pkg-config re2c zlib1g-dev ca-certificates wget libtool automake gcc-9 g++-9 libxslt
fi
- name: Install system packages on macOS
if: ${{ runner.os == 'macOS' }}
run: brew install autoconf automake bison freetype gd gettext icu4c krb5 libedit libiconv libjpeg libpng libxml2 libzip openssl@1.1 openssl@3 pkg-config re2c zlib
- name: Setup asdf
uses: asdf-vm/actions/setup@v4
- name: Fix autotools for PHP 8.0.0
if: ${{ matrix.os.version == '8.0.0' || matrix.os.version == '7.4.14' }}
run: |
# Install compatible autotools for old PHP versions
if command -v sudo >/dev/null 2>&1; then
sudo apt-get install -y autotools-dev m4 libtool-bin
else
apt-get install -y autotools-dev m4 libtool-bin
fi
echo "Autotools installed for PHP ${{ matrix.os.version }}"
- name: Test plugin
timeout-minutes: 45
run: |
# Add plugin from current checkout
asdf plugin add php $GITHUB_WORKSPACE
# Set version-specific configuration
if [ "${{ matrix.os.version }}" = "8.0.0" ]; then
echo "=== Configuring for PHP 8.0.0 ==="
# Verify gcc-9 is available, fallback to gcc if not
if command -v gcc-9 >/dev/null 2>&1; then
COMPILER="gcc-9"
CXXCOMPILER="g++-9"
else
COMPILER="gcc"
CXXCOMPILER="g++"
fi
# Export all variables for php-build
export ASDF_PHP_OPENSSL_AUTO=yes
export PHP_BUILD_XDEBUG_ENABLE=off
export CC="$COMPILER"
export CXX="$CXXCOMPILER"
# Set for autoconf/configure scripts
export ac_cv_prog_CC="$COMPILER"
export ac_cv_prog_CXX="$CXXCOMPILER"
# Set CONFIG_SHELL for consistent shell behavior
export CONFIG_SHELL="/bin/bash"
elif [ "${{ matrix.os.version }}" = "7.4.14" ]; then
echo "=== Configuring for PHP 7.4.14 ==="
# Verify gcc-9 is available, fallback to gcc if not
if command -v gcc-9 >/dev/null 2>&1; then
COMPILER="gcc-9"
CXXCOMPILER="g++-9"
else
COMPILER="gcc"
CXXCOMPILER="g++"
fi
export ASDF_PHP_OPENSSL_AUTO=yes
export PHP_BUILD_XDEBUG_ENABLE=off
export CC="$COMPILER"
export CXX="$CXXCOMPILER"
# Set for autoconf/configure scripts
export ac_cv_prog_CC="$COMPILER"
export ac_cv_prog_CXX="$CXXCOMPILER"
# Set CONFIG_SHELL for consistent shell behavior
export CONFIG_SHELL="/bin/bash"
else
echo "=== Configuring for PHP latest ==="
export ASDF_PHP_OPENSSL_AUTO=no
export PHP_BUILD_XDEBUG_ENABLE=off
export CC="gcc"
export CXX="g++"
fi
# Debug compiler setup for problematic versions
if [ "${{ matrix.os.version }}" = "8.0.0" ] || [ "${{ matrix.os.version }}" = "7.4.14" ]; then
echo "=== Compiler Debug Info ==="
echo "CC=$CC"
echo "CXX=$CXX"
echo "ac_cv_prog_CC=$ac_cv_prog_CC"
echo "CFLAGS=$CFLAGS"
echo "Compiler version:"
$CC --version || echo "Compiler not found"
echo "Testing basic compilation:"
echo 'int main() { return 0; }' > /tmp/test.c
$CC $CFLAGS -o /tmp/test /tmp/test.c && echo "✓ Basic compilation works" || echo "✗ Basic compilation FAILED"
rm -f /tmp/test /tmp/test.c
echo "Environment variables that will be passed to php-build:"
env | grep -E "^(CC|CXX|CFLAGS|CXXFLAGS|LDFLAGS|ac_cv_)" | sort
fi
# Install PHP version with enhanced error handling for old versions
echo "Installing PHP ${{ matrix.os.version }}..."
if [ "${{ matrix.os.version }}" = "8.0.0" ] || [ "${{ matrix.os.version }}" = "7.4.14" ]; then
asdf install php ${{ matrix.os.version }} || {
echo "Build failed, examining config.log and environment..."
echo "=== Final Environment Check ==="
echo "CC: $CC ($(which $CC 2>/dev/null || echo 'NOT FOUND'))"
echo "ac_cv_prog_CC: $ac_cv_prog_CC"
echo "CONFIG_SHELL: $CONFIG_SHELL"
echo "=== Config Log ==="
find /tmp -name "config.log" -path "*/php-build/source/${{ matrix.os.version }}/*" -exec tail -100 {} \;
echo "=== Configure Script Status ==="
find /tmp -path "*/php-build/source/${{ matrix.os.version }}/configure" -ls
echo "=== Full PHP build log ==="
find /tmp -name "php-build.${{ matrix.os.version }}.*.log" -exec tail -200 {} \;
exit 1
}
else
asdf install php ${{ matrix.os.version }}
fi
# Set global and test
asdf global php ${{ matrix.os.version }}
echo "Testing PHP installation..."
php --version
echo "PHP installation path:"
asdf where php
- name: Test Composer (if available)
if: success()
run: |
composer --version || echo "Composer not available"
continue-on-error: true
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install ShellCheck and make
run: |
sudo apt-get update
sudo apt-get install -y shellcheck make
- name: Run ShellCheck
run: make lint
format:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install shfmt and make
run: |
sudo apt-get update
sudo apt-get install -y make
curl -L "https://github.com/mvdan/sh/releases/download/v3.8.0/shfmt_v3.8.0_linux_amd64" -o shfmt
chmod +x shfmt
sudo mv shfmt /usr/local/bin/
- name: Run shfmt
run: make fmt-check