This is an automated email from the ASF dual-hosted git repository. hgruszecki pushed a commit to branch 1889-test-examples in repository https://gitbox.apache.org/repos/asf/iggy.git
commit d8aa6d1412556bff6516b0aac836e7bba1d6e7aa Author: Huan-Cheng Chang <[email protected]> AuthorDate: Sun Sep 28 11:50:27 2025 +0100 move task --- .../python-maturin/test-examples/action.yml | 76 ++++++++++++++++++++++ .github/workflows/_test_examples.yml | 16 +---- examples/python/requirements.txt | 2 +- scripts/run-python-examples-from-readme.sh | 35 +--------- 4 files changed, 80 insertions(+), 49 deletions(-) diff --git a/.github/actions/python-maturin/test-examples/action.yml b/.github/actions/python-maturin/test-examples/action.yml new file mode 100644 index 000000000..082e4450e --- /dev/null +++ b/.github/actions/python-maturin/test-examples/action.yml @@ -0,0 +1,76 @@ +# 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: python-test-examples +description: Test Python examples + +runs: + using: "composite" + steps: + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: "3.11" + + - name: Setup Rust with cache + uses: ./.github/actions/utils/setup-rust-with-cache + with: + cache-targets: false # Only cache registry and git deps, not target dir (sccache handles that) + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ~/.cache/pip + key: pip-${{ runner.os }}-${{ hashFiles('foreign/python/pyproject.toml') }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip wheel setuptools + + # Install maturin for building + pip install 'maturin>=1.2,<2.0' + + # Install testing dependencies from pyproject.toml + cd foreign/python + pip install -e ".[testing,examples,dev]" + cd ../.. + + # Install dependencies for examples + pip -r examples/python/requirements.txt + shell: bash + + - name: Build Python wheel for testing + if: inputs.task == 'test' || inputs.task == 'build' + run: | + cd foreign/python + + # Build the module + echo "Building Python wheel..." + maturin build -o dist + + # Install the built wheel for testing + echo "Installing built wheel..." + pip install dist/*.whl --force-reinstall + shell: bash + + - name: Run examples + run: | + cd $GITHUB_WORKSPACE + + echo "Running Python example tests..." + # Run the examples script which will use the prebuilt server binary + ./scripts/run-python-examples-from-readme.sh diff --git a/.github/workflows/_test_examples.yml b/.github/workflows/_test_examples.yml index 6aeaa926f..b1779984a 100644 --- a/.github/workflows/_test_examples.yml +++ b/.github/workflows/_test_examples.yml @@ -112,21 +112,9 @@ jobs: # Run the examples script which will use the prebuilt server binary ./scripts/run-csharp-examples-from-readme.sh - - name: Download pre-built python wheels - id: download-python-wheels - if: inputs.component == 'examples-suite' && inputs.task == 'examples-python' - uses: actions/download-artifact@v4 - with: - name: python-test-results-${{ github.run_id }}-${{ github.run_attempt }} - path: ./scripts/python-dist - - name: Run Python examples - if: inputs.component == 'examples-suite' && inputs.task == 'examples-python' && steps.download-python-wheels.outcome == 'success' - run: | - whl_path=$(realpath "$(find ./scripts -name "*.whl")") - echo "Running Python examples tests..." - # Run the examples script which will use the prebuilt server binary - ./scripts/run-python-examples-from-readme.sh "$whl_path" + if: inputs.component == 'examples-suite' && inputs.task == 'examples-python' + uses: ./.github/actions/python-maturin/test-examples - name: Upload reports if: always() diff --git a/examples/python/requirements.txt b/examples/python/requirements.txt index 11231bec6..e46e8562d 100644 --- a/examples/python/requirements.txt +++ b/examples/python/requirements.txt @@ -15,6 +15,6 @@ # specific language governing permissions and limitations # under the License. -apache-iggy==0.5.0 +apache-iggy loguru==0.7.3 argparse==1.4.0 diff --git a/scripts/run-python-examples-from-readme.sh b/scripts/run-python-examples-from-readme.sh index e5ce01c50..7d6fc6997 100755 --- a/scripts/run-python-examples-from-readme.sh +++ b/scripts/run-python-examples-from-readme.sh @@ -40,32 +40,7 @@ readonly LOG_FILE="iggy-server.log" readonly PID_FILE="iggy-server.pid" readonly TIMEOUT=300 -SDK_WHEEL_PATH="${1:-}" - -if [ -z "${SDK_WHEEL_PATH}" ]; then - echo "Python SDK wheel path is missing." - echo "Usage: $0 <SDK_WHEEL_PATH> [--target TARGET]" - exit 1 -fi - -shift 1 - -TARGET="" # Iggy server target architecture - -# Get Cargo --target values from arguments or use defaults -while [[ $# -gt 0 ]]; do - case "$1" in - --target) - TARGET="$2" - shift 2 - ;; - *) - echo "Unknown option: $1" - echo "Usage: $0 <SDK_WHEEL_PATH> [--target TARGET]" - exit 1 - ;; - esac -done +TARGET="${1:-}" # Iggy server target architecture if [ -n "${TARGET}" ]; then echo "Using target architecture: ${TARGET}" @@ -118,16 +93,8 @@ while ! grep -q "Iggy server has started" ${LOG_FILE}; do ((SERVER_START_TIME += 1)) done -echo "🚀 Running python example scripts..." - cd examples/python || exit 1 -echo "Installing dependencies" -pip -r requirements.txt - -echo "Installing SDK from $SDK_WHEEL_PATH" -pip install --force-reinstall $SDK_WHEEL_PATH - exit_code=0 # Execute all example commands from examples/python/README.md and check if they pass or fail
