# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. name: Bindings PHP CI on: push: tags: - '*' pull_request: branches: - main paths: - "bindings/php/**" - ".github/actions/setup/**" - ".github/workflows/ci_bindings_php.yml" workflow_call: workflow_dispatch: concurrency: group: ci-bindings-php-${{ github.ref }}-${{ github.event_name }} cancel-in-progress: ${{ github.event_name == 'pull_request' }} permissions: contents: read jobs: test: runs-on: ubuntu-latest strategy: fail-fast: true matrix: php: [8.2, 8.4] steps: - name: Checkout code uses: actions/checkout@v7 - name: Setup PHP uses: shivammathur/setup-php@eb7c497e18156a6bbabfef1d3a82760b9eda3962 # 2.40.0 with: php-version: ${{ matrix.php }} ini-values: error_reporting=E_ALL tools: composer:v2 coverage: none - name: Setup Rust toolchain uses: ./.github/actions/setup - name: Use matching Clang and libclang for bindgen run: | # The runner ships multiple LLVM versions. Bindgen discovers Clang and libclang separately. clang_path="$(realpath -e /usr/bin/clang)" llvm_dir="$(dirname "$(dirname "$clang_path")")" { echo "CLANG_PATH=$clang_path" echo "LIBCLANG_PATH=$llvm_dir/lib" } >> "$GITHUB_ENV" # Useful for debugging - name: Print Clippy version working-directory: "bindings/php" run: cargo clippy --version - name: Clippy Check working-directory: "bindings/php" run: cargo clippy -- -D warnings - name: Build opendal-php extension working-directory: "bindings/php" run: cargo build - name: Enable opendal-php extension in php.ini working-directory: "bindings/php" run: | # 1. Find the extension_dir extension_dir=$(php -r "echo ini_get('extension_dir');") # 2. Create the extension_dir if it doesn't exist sudo mkdir -p $extension_dir # 3. Copy the extension to the extension_dir sudo cp target/debug/libopendal_php.so $extension_dir/libopendal_php.so # 4. Enable the extension echo "extension=libopendal_php.so" >> $(php -r "echo php_ini_loaded_file();") - name: Check PHP Extensions run: php -m - name: Run getting-started example working-directory: "bindings/php" run: php examples/getting-started.php - name: Install Composer dependencies working-directory: "bindings/php" run: | composer update --prefer-stable --prefer-dist --no-interaction --no-progress - name: Test PHP working-directory: "bindings/php" run: | composer test