@@ -531,6 +531,94 @@ jobs:
531531 DEFAULT_CROSS_BUILD_ENV_URL : " https://github.com/pyodide/pyodide/releases/download/0.28.0a3/xbuildenv-0.28.0a3.tar.bz2"
532532 RUSTFLAGS : " -C link-arg=-sSIDE_MODULE=2 -Z link-native-libraries=no -Z emscripten-wasm-eh"
533533
534+ test-php :
535+ strategy :
536+ fail-fast : false
537+ matrix :
538+ os : [ubuntu-22.04, macos-13]
539+ php-version : ["8.2", "8.3", "8.4"]
540+ clang : ["20"]
541+
542+ name : PHP ${{ matrix.php-version }} on ${{ matrix.os }}
543+ runs-on : ${{ matrix.os }}
544+ steps :
545+ - uses : actions/checkout@v4
546+
547+ - uses : dtolnay/rust-toolchain@stable
548+
549+ - name : Cache cargo dependencies
550+ uses : Swatinem/rust-cache@v2
551+ with :
552+ workspaces : bindings/php
553+
554+ - name : Cache LLVM and Clang
555+ id : cache-llvm
556+ uses : actions/cache@v4
557+ if : matrix.os == 'ubuntu-22.04'
558+ with :
559+ path : ${{ runner.temp }}/llvm-${{ matrix.clang }}
560+ key : ${{ matrix.os }}-llvm-${{ matrix.clang }}
561+
562+ - name : Setup LLVM & Clang
563+ id : clang
564+ uses : KyleMayes/install-llvm-action@v2
565+ if : matrix.os == 'ubuntu-22.04'
566+ with :
567+ version : ${{ matrix.clang }}
568+ directory : ${{ runner.temp }}/llvm-${{ matrix.clang }}
569+ cached : ${{ steps.cache-llvm.outputs.cache-hit }}
570+
571+ - name : Configure Clang
572+ if : matrix.os == 'ubuntu-22.04'
573+ run : |
574+ echo "LIBCLANG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/lib" >> $GITHUB_ENV
575+ echo "LLVM_VERSION=${{ steps.clang.outputs.version }}" >> $GITHUB_ENV
576+ echo "LLVM_CONFIG_PATH=${{ runner.temp }}/llvm-${{ matrix.clang }}/bin/llvm-config" >> $GITHUB_ENV
577+
578+ - uses : shivammathur/setup-php@v2
579+ with :
580+ php-version : ${{ matrix.php-version }}
581+ extensions : mbstring
582+ coverage : none
583+
584+ - name : Build PHP extension
585+ run : |
586+ export PHP_CONFIG=$(which php-config)
587+
588+ cargo build --release
589+
590+ EXT_DIR=$(php -r "echo ini_get('extension_dir');")
591+
592+ # Find the built library - ext-php-rs names it differently on different platforms
593+ if [[ "${{ matrix.os }}" == "macos-13" ]]; then
594+ BUILT_LIB=$(find target/release -name "*.dylib" | head -1)
595+ else
596+ BUILT_LIB=$(find target/release -name "*.so" | head -1)
597+ fi
598+ sudo cp "$BUILT_LIB" "$EXT_DIR/css_inline.so"
599+ working-directory : ./bindings/php
600+ shell : bash
601+
602+ - name : Enable and verify extension
603+ run : |
604+ if [[ "${{ matrix.os }}" == "macos-13" ]]; then
605+ PHP_INI=$(php -i | grep "Loaded Configuration File" | cut -d' ' -f9)
606+ PHP_INI_DIR=$(dirname "$PHP_INI")/conf.d
607+ sudo mkdir -p "$PHP_INI_DIR"
608+ echo "extension=css_inline" | sudo tee "$PHP_INI_DIR/99-css_inline.ini"
609+ else
610+ echo "extension=css_inline" | sudo tee /etc/php/${{ matrix.php-version }}/cli/conf.d/99-css_inline.ini
611+ fi
612+ shell : bash
613+
614+ - name : Install dependencies
615+ run : composer install --no-interaction --prefer-dist
616+ working-directory : ./bindings/php
617+
618+ - name : Run tests
619+ run : composer test
620+ working-directory : ./bindings/php
621+
534622 test-ruby :
535623 strategy :
536624 fail-fast : false
0 commit comments