Skip to content

RHAIENG-4029: add tier-2 integration test for agentic RAG agent #24

RHAIENG-4029: add tier-2 integration test for agentic RAG agent

RHAIENG-4029: add tier-2 integration test for agentic RAG agent #24

Workflow file for this run

name: Agent Tests
on:
push:
branches: [main]
paths: ['agents/**']
pull_request:
branches: [main]
paths: ['agents/**']
workflow_dispatch:
permissions:
contents: read
checks: write
concurrency:
group: agent-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
with:
fetch-depth: 0
- name: Setup Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@37802adc94f370d6bfd71619e3f0bf239e1f3b78 # v7.6.0
- name: Run tests
id: run-tests
run: |
# Discover agent dirs containing unit-test files
discovered=$(find agents/*/*/tests -maxdepth 1 -name 'test_*.py' -type f 2>/dev/null \
| cut -d'/' -f1-3 | sort -u)
# On PRs, filter to only agents with changed files
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
base_ref="origin/${{ github.event.pull_request.base.ref }}"
changed_files=$(git diff --name-only "${base_ref}...HEAD")
filtered=""
while IFS= read -r agent_dir; do
[ -z "$agent_dir" ] && continue
if echo "$changed_files" | grep -q "^${agent_dir}/"; then
filtered="${filtered}${filtered:+$'\n'}${agent_dir}"
fi
done <<< "$discovered"
discovered="$filtered"
fi
count=$(echo "$discovered" | grep -c '[^[:space:]]' || true)
if [ "$count" -eq 0 ]; then
echo "No testable agents found (or none changed). Skipping."
exit 0
fi
echo "Running tests for ${count} agents"
mkdir -p test-results
failed=0
while IFS= read -r agent_dir; do
[ -z "$agent_dir" ] && continue
name=$(echo "$agent_dir" | sed 's|agents/||; s|/|-|g')
echo ""
echo "::group::${name}"
echo "=== Testing ${agent_dir} ==="
if make -C "$agent_dir" test PYTEST_ARGS="--junitxml=$(pwd)/test-results/${name}.xml -v --tb=short"; then
echo "✓ ${name} passed"
else
echo "✗ ${name} failed"
failed=1
fi
echo "::endgroup::"
done <<< "$discovered"
exit "$failed"
- name: Publish test report
if: always()
uses: mikepenz/action-junit-report@bccf2e31636835cf0874589931c4116687171386 # v6.4.0
with:
report_paths: test-results/*.xml
check_name: Agent Test Results
include_passed: true
annotate_only: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name != github.repository }}