Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 125 additions & 0 deletions .github/actions/php/pre-merge/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# 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: php-pre-merge
description: PHP pre-merge testing github iggy actions

inputs:
task:
description: "Task to run (lint, test, build)"
required: true

runs:
using: "composite"
steps:
- name: Install PHP build dependencies
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
clang \
libclang-dev \
libssl-dev \
php-cli \
php-dev \
pkg-config \
unzip

echo "PHP=$(command -v php)" >> "$GITHUB_ENV"
echo "PHP_CONFIG=$(command -v php-config)" >> "$GITHUB_ENV"
php --version
php-config --version

- name: Setup Rust with cache
uses: ./.github/actions/utils/setup-rust-with-cache
with:
shared-key: dev
save-cache: ${{ inputs.task == 'test' }}

- name: Use shared Cargo target directory
shell: bash
run: echo "CARGO_TARGET_DIR=${GITHUB_WORKSPACE}/target" >> "$GITHUB_ENV"

- name: Validate task
shell: bash
run: |
case "${{ inputs.task }}" in
lint|test|build) ;;
*)
echo "Unknown PHP SDK task: ${{ inputs.task }}"
exit 1
;;
esac

- name: Lint
if: inputs.task == 'lint'
shell: bash
run: |
php -r 'json_decode(file_get_contents("foreign/php/composer.json"), true, 512, JSON_THROW_ON_ERROR);'
cargo fmt --manifest-path foreign/php/Cargo.toml -- --check
find foreign/php \
-path foreign/php/vendor -prune -o \
-name '*.php' -print0 \
| xargs -0 -n1 php -l

- name: Build PHP extension
if: inputs.task == 'build'
shell: bash
run: |
cargo build --release --manifest-path foreign/php/Cargo.toml
extension="$(find "${CARGO_TARGET_DIR}/release" -maxdepth 1 -name 'libiggy_php.so' -print -quit)"
if [ -z "$extension" ]; then
echo "PHP extension was not produced"
exit 1
fi
ls -lh "$extension"

- name: Build PHP extension for tests
if: inputs.task == 'test'
shell: bash
run: |
cargo build --manifest-path foreign/php/Cargo.toml
extension="$(find "${CARGO_TARGET_DIR}/debug" -maxdepth 1 -name 'libiggy_php.so' -print -quit)"
if [ -z "$extension" ]; then
echo "PHP extension was not produced"
exit 1
fi
echo "PHP_IGGY_EXTENSION=$(realpath "$extension")" >> "$GITHUB_ENV"
ls -lh "$extension"

- name: Start Iggy server
if: inputs.task == 'test'
id: iggy
uses: ./.github/actions/utils/server-start

- name: Run PHP SDK tests
if: inputs.task == 'test'
shell: bash
working-directory: foreign/php
env:
IGGY_HOST: 127.0.0.1
IGGY_PORT: 8090
IGGY_USERNAME: iggy
IGGY_PASSWORD: iggy
run: ./scripts/test.sh

- name: Stop Iggy server
if: always() && inputs.task == 'test'
uses: ./.github/actions/utils/server-stop
with:
pid-file: ${{ steps.iggy.outputs.pid_file }}
log-file: ${{ steps.iggy.outputs.log_file }}
9 changes: 9 additions & 0 deletions .github/config/components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,15 @@ components:
- "foreign/python/**"
tasks: ["lint", "test", "build"]

sdk-php:
depends_on:
- "rust-sdk" # PHP SDK wraps the Rust SDK
- "rust-server" # For integration tests
- "ci-infrastructure" # CI changes trigger full regression
paths:
- "foreign/php/**"
tasks: ["lint", "test", "build"]

sdk-node:
depends_on:
- "rust-sdk" # Node SDK depends on core SDK
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/_detect.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ on:
python_matrix:
description: "Matrix for Python SDK"
value: ${{ jobs.detect.outputs.python_matrix }}
php_matrix:
description: "Matrix for PHP SDK"
value: ${{ jobs.detect.outputs.php_matrix }}
node_matrix:
description: "Matrix for Node SDK"
value: ${{ jobs.detect.outputs.node_matrix }}
Expand Down Expand Up @@ -60,6 +63,7 @@ jobs:
outputs:
rust_matrix: ${{ steps.mk.outputs.rust_matrix }}
python_matrix: ${{ steps.mk.outputs.python_matrix }}
php_matrix: ${{ steps.mk.outputs.php_matrix }}
node_matrix: ${{ steps.mk.outputs.node_matrix }}
go_matrix: ${{ steps.mk.outputs.go_matrix }}
java_matrix: ${{ steps.mk.outputs.java_matrix }}
Expand Down Expand Up @@ -230,7 +234,7 @@ jobs:
console.log(`Total files changed: ${files.length}`);
}

const groups = { rust:[], python:[], node:[], go:[], java:[], csharp:[], cpp:[], bdd:[], examples:[], other:[] };
const groups = { rust:[], python:[], php:[], node:[], go:[], java:[], csharp:[], cpp:[], bdd:[], examples:[], other:[] };

// Process affected components and generate tasks
console.log('');
Expand All @@ -253,6 +257,7 @@ jobs:

if (name === 'rust') groups.rust.push(...entries);
else if (name === 'sdk-python') groups.python.push(...entries);
else if (name === 'sdk-php') groups.php.push(...entries);
else if (name === 'sdk-node') groups.node.push(...entries);
else if (name === 'sdk-go') groups.go.push(...entries);
else if (name === 'sdk-java') groups.java.push(...entries);
Expand Down Expand Up @@ -299,6 +304,7 @@ jobs:
// Clear existing groups to avoid duplicates - we'll run everything anyway
groups.rust = [];
groups.python = [];
groups.php = [];
groups.node = [];
groups.go = [];
groups.java = [];
Expand All @@ -313,6 +319,7 @@ jobs:
const entries = cfg.tasks.map(task => ({ component: name, task }));
if (name === 'rust') groups.rust.push(...entries);
else if (name === 'sdk-python') groups.python.push(...entries);
else if (name === 'sdk-php') groups.php.push(...entries);
else if (name === 'sdk-node') groups.node.push(...entries);
else if (name === 'sdk-go') groups.go.push(...entries);
else if (name === 'sdk-java') groups.java.push(...entries);
Expand Down Expand Up @@ -349,6 +356,7 @@ jobs:
const jobSummary = [
{ name: 'Rust', tasks: groups.rust },
{ name: 'Python SDK', tasks: groups.python },
{ name: 'PHP SDK', tasks: groups.php },
{ name: 'Node SDK', tasks: groups.node },
{ name: 'Go SDK', tasks: groups.go },
{ name: 'Java SDK', tasks: groups.java },
Expand Down Expand Up @@ -381,6 +389,7 @@ jobs:

setOutput('rust_matrix', JSON.stringify(matrix(groups.rust)));
setOutput('python_matrix', JSON.stringify(matrix(groups.python)));
setOutput('php_matrix', JSON.stringify(matrix(groups.php)));
setOutput('node_matrix', JSON.stringify(matrix(groups.node)));
setOutput('go_matrix', JSON.stringify(matrix(groups.go)));
setOutput('java_matrix', JSON.stringify(matrix(groups.java)));
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ jobs:
(inputs.task == 'build-aarch64-gnu' || inputs.task == 'build-aarch64-musl') && 'ubuntu-24.04-arm' ||
inputs.task == 'build-macos-aarch64' && 'macos-14' ||
inputs.task == 'build-windows-sdk' && 'windows-latest' ||
inputs.component == 'sdk-php' && 'ubuntu-24.04' ||
'ubuntu-latest'
}}
timeout-minutes: 60
Expand Down Expand Up @@ -97,6 +98,13 @@ jobs:
verbose: true
override_pr: ${{ github.event.pull_request.number }}

# PHP SDK
- name: Run PHP SDK task
if: inputs.component == 'sdk-php'
uses: ./.github/actions/php/pre-merge
with:
task: ${{ inputs.task }}

# Node SDK
- name: Run Node SDK task
if: inputs.component == 'sdk-node'
Expand Down
21 changes: 20 additions & 1 deletion .github/workflows/pre-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ jobs:
secrets:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# PHP SDK
test-php:
name: PHP • ${{ matrix.task }}
needs: detect
if: ${{ fromJson(needs.detect.outputs.php_matrix).include[0].component != 'noop' }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.detect.outputs.php_matrix) }}
uses: ./.github/workflows/_test.yml
with:
component: ${{ matrix.component }}
task: ${{ matrix.task }}

Comment thread
countradooku marked this conversation as resolved.
# Node SDK
test-node:
name: Node • ${{ matrix.task }}
Expand Down Expand Up @@ -194,7 +207,7 @@ jobs:
status:
name: CI Status
runs-on: ubuntu-latest
needs: [common, detect, test-rust, test-python, test-node, test-go, test-java, test-csharp, test-cpp, test-bdd, test-examples, test-other]
needs: [common, detect, test-rust, test-python, test-php, test-node, test-go, test-java, test-csharp, test-cpp, test-bdd, test-examples, test-other]
if: always()
steps:
- name: Get job execution times
Expand Down Expand Up @@ -272,6 +285,7 @@ jobs:
// Set outputs for each component
const rust = findJobInfo('Rust •');
const python = findJobInfo('Python •');
const php = findJobInfo('PHP •');
const node = findJobInfo('Node •');
const go = findJobInfo('Go •');
const java = findJobInfo('Java •');
Expand All @@ -292,6 +306,7 @@ jobs:
// Output formatted durations
core.setOutput('rust_time', formatJobDuration(rust));
core.setOutput('python_time', formatJobDuration(python));
core.setOutput('php_time', formatJobDuration(php));
core.setOutput('node_time', formatJobDuration(node));
core.setOutput('go_time', formatJobDuration(go));
core.setOutput('java_time', formatJobDuration(java));
Expand Down Expand Up @@ -382,6 +397,7 @@ jobs:
# Language/component tests
rust_status=$(format_status "${{ needs.test-rust.result }}" "${{ steps.times.outputs.rust_time }}")
python_status=$(format_status "${{ needs.test-python.result }}" "${{ steps.times.outputs.python_time }}")
php_status=$(format_status "${{ needs.test-php.result }}" "${{ steps.times.outputs.php_time }}")
node_status=$(format_status "${{ needs.test-node.result }}" "${{ steps.times.outputs.node_time }}")
go_status=$(format_status "${{ needs.test-go.result }}" "${{ steps.times.outputs.go_time }}")
java_status=$(format_status "${{ needs.test-java.result }}" "${{ steps.times.outputs.java_time }}")
Expand All @@ -393,6 +409,7 @@ jobs:

echo "| 🦀 Rust | $rust_status | ${{ steps.times.outputs.rust_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🐍 Python | $python_status | ${{ steps.times.outputs.python_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🐘 PHP | $php_status | ${{ steps.times.outputs.php_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🟢 Node | $node_status | ${{ steps.times.outputs.node_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| 🐹 Go | $go_status | ${{ steps.times.outputs.go_time }} |" >> $GITHUB_STEP_SUMMARY
echo "| ☕ Java | $java_status | ${{ steps.times.outputs.java_time }} |" >> $GITHUB_STEP_SUMMARY
Expand All @@ -409,6 +426,7 @@ jobs:
[[ "${{ needs.detect.result }}" == "failure" ]] || \
[[ "${{ needs.test-rust.result }}" == "failure" ]] || \
[[ "${{ needs.test-python.result }}" == "failure" ]] || \
[[ "${{ needs.test-php.result }}" == "failure" ]] || \
[[ "${{ needs.test-node.result }}" == "failure" ]] || \
[[ "${{ needs.test-go.result }}" == "failure" ]] || \
[[ "${{ needs.test-java.result }}" == "failure" ]] || \
Expand All @@ -424,6 +442,7 @@ jobs:
[[ "${{ needs.detect.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-rust.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-python.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-php.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-node.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-go.result }}" == "cancelled" ]] || \
[[ "${{ needs.test-java.result }}" == "cancelled" ]] || \
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ members = [
"core/tools",
"examples/rust",
]
exclude = ["foreign/cpp", "foreign/python"]
exclude = ["foreign/cpp", "foreign/php", "foreign/python"]
resolver = "2"

[workspace.dependencies]
Expand Down
22 changes: 22 additions & 0 deletions foreign/php/.cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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.

[target.aarch64-apple-darwin]
rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]

[target.x86_64-apple-darwin]
rustflags = ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
4 changes: 4 additions & 0 deletions foreign/php/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/target
/vendor
Cargo.lock
composer.lock
39 changes: 39 additions & 0 deletions foreign/php/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# 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.

[package]
name = "iggy-php"
version = "0.1.0"
edition = "2024"
authors = ["Iggy Committers <dev@iggy.apache.org>"]
license = "Apache-2.0"
description = "PHP extension bindings for Apache Iggy."
documentation = "https://iggy.apache.org/docs/"
repository = "https://github.com/apache/iggy"

[lib]
crate-type = ["cdylib"]

[dependencies]
bytes = "1.11.1"
futures = "0.3.32"
ext-php-rs = "0.15.13"
iggy = { path = "../../core/sdk", version = "0.10.0" }
tokio = "1.50.0"

[profile.release]
strip = "debuginfo"
Loading