blob: 5fb90f4971b3e1b3dd13ff638d7710956ff96b8c [file] [log] [blame]
# 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: _test_examples
on:
workflow_call:
inputs:
component:
type: string
required: true
description: "Component to test (should be 'examples-suite')"
task:
type: string
required: true
description: "Task to run (e.g., 'examples-rust', 'examples-go', 'examples-node')"
permissions:
contents: read
security-events: write
jobs:
run:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Skip noop
if: inputs.component == 'noop'
run: echo "No changes detected, skipping tests"
- name: Setup Rust with cache for examples
if: inputs.component == 'examples-suite'
uses: ./.github/actions/utils/setup-rust-with-cache
- name: Setup Node with cache for examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-node'
uses: ./.github/actions/utils/setup-node-with-cache
with:
node-version: "23"
cache-dependency-path: examples/node/package-lock.json
workspace: examples/node
- name: Setup Python
if: inputs.component == 'examples-suite' && inputs.task == 'examples-python'
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Cache pip
if: inputs.component == 'examples-suite' && inputs.task == 'examples-python'
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip-${{ runner.os }}-${{ hashFiles('foreign/python/pyproject.toml') }}
- name: Setup Java with cache for examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-java'
uses: ./.github/actions/utils/setup-java-with-cache
with:
gradle-cache-disabled: "true"
- name: Setup Go with cache for examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-go'
uses: ./.github/actions/utils/setup-go-with-cache
with:
enabled: "false"
cache-dependency-path: examples/go/go.sum
download-deps: "false"
- name: Build common binaries for all examples
if: inputs.component == 'examples-suite'
run: |
echo "Building common binaries for all examples tests..."
echo "Current directory: $(pwd)"
# Build server (needed by both Rust and Go examples)
echo "Building iggy-server..."
cargo build --locked --bin iggy-server
# For Rust examples, also build CLI and example binaries
if [[ "${{ inputs.task }}" == "examples-rust" ]]; then
echo "Building additional binaries for Rust examples..."
cargo build --locked --bin iggy --examples
fi
# Verify server binary was built (needed by all examples)
echo "Verifying server binary:"
if [ -f "target/debug/iggy-server" ]; then
echo "✅ Server binary found at target/debug/iggy-server"
ls -lh target/debug/iggy-server
else
echo "❌ Server binary NOT found at target/debug/iggy-server"
echo "Checking target directory structure:"
find target -name "iggy-server" -type f 2>/dev/null || true
exit 1
fi
# For Rust examples, verify CLI was built
if [[ "${{ inputs.task }}" == "examples-rust" ]]; then
if [ -f "target/debug/iggy" ]; then
echo "✅ CLI binary found at target/debug/iggy"
ls -lh target/debug/iggy
else
echo "❌ CLI binary NOT found at target/debug/iggy"
exit 1
fi
fi
- name: Run Rust examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-rust'
run: |
echo "Running Rust examples tests..."
./scripts/run-rust-examples-from-readme.sh
- name: Run Go examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-go'
run: |
echo "Running Go examples tests..."
./scripts/run-go-examples-from-readme.sh
- name: Run Csharp examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-csharp'
run: |
echo "Running Csharp examples tests..."
./scripts/run-csharp-examples-from-readme.sh
- name: Run Python examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-python'
run: |
echo "Running Python examples tests..."
./scripts/run-python-examples-from-readme.sh
- name: Run Node.js examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-node'
run: |
echo "Running Node.js examples tests..."
# Build the local Node SDK first (examples use file: link to it)
cd foreign/node
npm ci
npm run build
cd ../..
# Install examples dependencies (will use the local SDK)
cd examples/node
npm ci
cd ../..
./scripts/run-node-examples-from-readme.sh
- name: Run Java examples
if: inputs.component == 'examples-suite' && inputs.task == 'examples-java'
run: |
echo "Running Java examples tests..."
./scripts/run-java-examples-from-readme.sh
- name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.component }}-${{ inputs.task }}-reports-${{ github.run_id }}-${{ github.run_attempt }}
path: |
reports/**
target/llvm-cov/**
coverage.lcov
if-no-files-found: ignore
retention-days: 7