Skip to content

Merge pull request #16 from Agent-Field/santosh/functional-doc-test #16

Merge pull request #16 from Agent-Field/santosh/functional-doc-test

Merge pull request #16 from Agent-Field/santosh/functional-doc-test #16

name: Functional Tests
on:
push:
branches:
- testing
- main
pull_request:
branches:
- main
workflow_dispatch:
inputs:
storage_mode:
description: 'Storage mode to test'
required: false
default: 'both'
type: choice
options:
- both
- local
- postgres
openrouter_model:
description: 'OpenRouter model to use'
required: false
default: 'openrouter/google/gemini-2.5-flash-lite'
type: string
jobs:
functional-tests:
name: Functional Tests (${{ matrix.storage_mode }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
storage_mode:
- local
- postgres
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
OPENROUTER_MODEL: ${{ github.event.inputs.openrouter_model || 'openrouter/google/gemini-2.5-flash-lite' }}
DOCKER_BUILDKIT: 1
COMPOSE_DOCKER_CLI_BUILD: 1
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Verify OpenRouter configuration
run: |
if [ -z "$OPENROUTER_API_KEY" ]; then
echo "::error::OPENROUTER_API_KEY secret is not set"
echo "Please add your OpenRouter API key as a repository secret"
exit 1
fi
echo "✓ OPENROUTER_API_KEY is configured"
echo "✓ OPENROUTER_MODEL: $OPENROUTER_MODEL"
- name: Run functional tests (${{ matrix.storage_mode }})
run: |
cd tests/functional
if [ "${{ matrix.storage_mode }}" = "local" ]; then
docker compose -f docker/docker-compose.local.yml up \
--build \
--abort-on-container-exit \
--exit-code-from test-runner
else
docker compose -f docker/docker-compose.postgres.yml up \
--build \
--abort-on-container-exit \
--exit-code-from test-runner
fi
- name: Extract test reports
if: always()
run: |
# Create reports directory
mkdir -p test-reports
# Try to copy reports from Docker volume
VOLUME_NAME="functional_test-reports"
if docker volume inspect $VOLUME_NAME >/dev/null 2>&1; then
docker run --rm \
-v $VOLUME_NAME:/reports \
-v $(pwd)/test-reports:/output \
busybox cp -r /reports/. /output/ 2>/dev/null || true
fi
- name: Upload test reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-${{ matrix.storage_mode }}
path: test-reports/
retention-days: 7
- name: Upload logs
if: failure()
run: |
mkdir -p logs
cd tests/functional
docker compose -f docker/docker-compose.${{ matrix.storage_mode }}.yml logs > ../../logs/docker-${{ matrix.storage_mode }}.log || true
- name: Upload failure logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: logs-${{ matrix.storage_mode }}
path: logs/
retention-days: 7
- name: Cleanup
if: always()
run: |
cd tests/functional
docker compose -f docker/docker-compose.${{ matrix.storage_mode }}.yml down -v || true
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: functional-tests
if: always()
steps:
- name: Check test results
run: |
if [ "${{ needs.functional-tests.result }}" = "failure" ]; then
echo "::error::Functional tests failed"
exit 1
elif [ "${{ needs.functional-tests.result }}" = "cancelled" ]; then
echo "::warning::Functional tests were cancelled"
exit 1
else
echo "✅ All functional tests passed"
fi