Skip to content

Feat: Add support for JSON endpoints in Conversational Search #2491

Feat: Add support for JSON endpoints in Conversational Search

Feat: Add support for JSON endpoints in Conversational Search #2491

Workflow file for this run

name: tests
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
GHCR_REPO: ghcr.io/manticoresoftware/manticoresearch
jobs:
ref_detection:
name: Detect CLT tests ref
runs-on: ubuntu-22.04
outputs:
ref: ${{ steps.ref.outputs.ref }}
test_kit_image: ${{ steps.test_kit_image.outputs.image }}
steps:
- name: Get current branch name
id: current_branch
run: |
BRANCH=${{ github.head_ref || github.ref_name }}
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
- name: Checkout manticoresearch repository
uses: actions/checkout@v4
with:
repository: manticoresoftware/manticoresearch
path: manticoresearch
fetch-depth: 0
- name: Check if branch exists in manticoresearch
id: check_branch
working-directory: manticoresearch
run: |
git ls-remote --heads origin ${{ steps.current_branch.outputs.branch }} | grep -q . && \
echo "exists=true" >> $GITHUB_OUTPUT || echo "exists=false" >> $GITHUB_OUTPUT
- name: Detect ref
id: ref
run: |
set -e
if [[ "${{ steps.check_branch.outputs.exists }}" == "true" ]]; then
REF="${{ steps.current_branch.outputs.branch }}"
else
REF="main"
fi
echo "ref=${REF}" >> $GITHUB_OUTPUT
echo "Ref: ${REF}" >> $GITHUB_STEP_SUMMARY
- name: Determine test-kit image
id: test_kit_image
run: |
set -e
if [[ "${{ steps.check_branch.outputs.exists }}" == "true" ]]; then
BRANCH="${{ steps.current_branch.outputs.branch }}"
if [[ "$BRANCH" == "main" ]]; then
IMAGE="ghcr.io/manticoresoftware/manticoresearch:test-kit-latest"
else
fix=$(echo "$BRANCH" | tr '/' '_')
DOCKER_TAG=$(echo "$fix" | sed 's/[^a-zA-Z0-9_.-]//g')
IMAGE="ghcr.io/manticoresoftware/manticoresearch:test-kit-${DOCKER_TAG,,}"
fi
else
IMAGE="ghcr.io/manticoresoftware/manticoresearch:test-kit-latest"
fi
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
echo "Test-kit Image: ${IMAGE}" >> $GITHUB_STEP_SUMMARY
test:
name: Run unit tests
runs-on: ubuntu-22.04
needs: [ref_detection]
container:
image: ${{ needs.ref_detection.outputs.test_kit_image }}
options: --cap-add SYS_ADMIN --security-opt apparmor=unconfined
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run unit tests
run: |
set -e
ln -snf "$GITHUB_WORKSPACE" /workdir
# the entrypoint is rewritten so we need to launch searchd manually
searchd
cd /workdir
composer install --prefer-dist
git clone https://github.com/manticoresoftware/phar_builder.git
bin/test
test_kit:
name: Build test kit Docker image
runs-on: ubuntu-22.04
needs: [ref_detection]
outputs:
docker_repo: ${{ steps.vars.outputs.docker_repo }}
docker_tag: ${{ steps.vars.outputs.docker_tag }}
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha || github.head_ref || github.ref }}
fetch-depth: 0
fetch-tags: true
- name: Set variables
id: vars
run: |
set -e
BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}
fix=$(echo "$BRANCH" | tr '/' '_')
DOCKER_TAG=$(echo "$fix" | sed 's/[^a-zA-Z0-9_.-]//g')
DOCKER_TAG="test-kit-${DOCKER_TAG,,}-buddy"
COMMIT=${GITHUB_SHA::8}
IMAGE="${GHCR_REPO}:${DOCKER_TAG}"
IMAGE_COMMIT="${GHCR_REPO}:test-kit-${COMMIT,,}-buddy"
# Base image to pull from (same logic as ref_detection)
BASE_IMAGE="${{ needs.ref_detection.outputs.test_kit_image }}"
# Check if this is a fork PR
IS_FORK_PR="false"
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
IS_FORK_PR="true"
fi
fi
echo "docker_repo=${GHCR_REPO}" >> $GITHUB_OUTPUT
echo "docker_tag=${DOCKER_TAG}" >> $GITHUB_OUTPUT
echo "image=${IMAGE}" >> $GITHUB_OUTPUT
echo "image_commit=${IMAGE_COMMIT}" >> $GITHUB_OUTPUT
echo "base_image=${BASE_IMAGE}" >> $GITHUB_OUTPUT
echo "is_fork_pr=${IS_FORK_PR}" >> $GITHUB_OUTPUT
echo "Docker Image: ${IMAGE}" >> $GITHUB_STEP_SUMMARY
echo "Docker Image commit: ${IMAGE_COMMIT}" >> $GITHUB_STEP_SUMMARY
echo "Base Image: ${BASE_IMAGE}" >> $GITHUB_STEP_SUMMARY
echo "Is Fork PR: ${IS_FORK_PR}" >> $GITHUB_STEP_SUMMARY
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
if: steps.vars.outputs.is_fork_pr == 'false'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ vars.GHCR_USER }}
password: ${{ secrets.GHCR_PASSWORD }}
- name: Pull base image
run: |
echo "📥 PULLING Base Image: ${{ steps.vars.outputs.base_image }}"
docker pull ${{ steps.vars.outputs.base_image }}
- name: Create test kit image
run: |
# Create temporary container from the base image
docker create --name temp ${{ steps.vars.outputs.base_image }} tail -f /dev/null
docker start temp
# Install buddy code into the container
docker exec temp sh -c 'rm -rf /usr/share/manticore/modules/manticore-buddy && mkdir -p /usr/share/manticore/modules/manticore-buddy'
docker cp . temp:/usr/share/manticore/modules/manticore-buddy/
docker exec temp sh -c 'cd /usr/share/manticore/modules/manticore-buddy/ && composer install --prefer-dist'
docker exec temp sh -c 'git config --system --add safe.directory /usr/share/manticore/modules/manticore-buddy'
# Commit the buddy test-kit images
docker commit temp ${{ steps.vars.outputs.image }}
docker commit temp ${{ steps.vars.outputs.image_commit }}
# Cleanup
docker rm -f temp
- name: Push test kit images
if: steps.vars.outputs.is_fork_pr == 'false'
run: |
# PUSHING: Always push with current branch + buddy suffix
# Example: test-kit-feature-xyz-buddy (branch-based)
# Example: test-kit-abc12345-buddy (commit-based)
echo "🚀 PUSHING Docker Images:"
echo " Branch image: ${{ steps.vars.outputs.image }}"
echo " Commit image: ${{ steps.vars.outputs.image_commit }}"
docker push ${{ steps.vars.outputs.image }}
docker push ${{ steps.vars.outputs.image_commit }}
- name: Save PR comment data
if: github.event_name == 'pull_request'
run: |
# Save PR comment data as artifact for the comment workflow
mkdir -p pr-comment
cat > pr-comment/data.json << 'EOF'
{
"pr_number": "${{ github.event.number }}",
"branch_image": "${{ steps.vars.outputs.image }}",
"commit_image": "${{ steps.vars.outputs.image_commit }}",
"base_image": "${{ steps.vars.outputs.base_image }}",
"is_fork_pr": "${{ steps.vars.outputs.is_fork_pr }}",
"head_sha": "${{ github.event.pull_request.head.sha }}"
}
EOF
echo "PR comment data saved to artifact"
- name: Upload PR comment data
if: github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: pr-comment-data
path: pr-comment/
retention-days: 1
clt:
name: Run CLT tests
needs: [test_kit, ref_detection]
uses: manticoresoftware/manticoresearch/.github/workflows/clt_tests.yml@main
secrets:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
VOYAGE_API_KEY: ${{ secrets.VOYAGE_API_KEY }}
JINA_API_KEY: ${{ secrets.JINA_API_KEY }}
with:
docker_image: ${{ needs.test_kit.outputs.docker_repo }}:${{ needs.test_kit.outputs.docker_tag }}
repository: manticoresoftware/manticoresearch
ref: ${{ needs.ref_detection.outputs.ref }}
continue_on_error: ${{ github.ref == 'refs/heads/main' }}
codestyle:
name: PHPCS validation
runs-on: ubuntu-22.04
needs: [ref_detection]
container:
image: ${{ needs.ref_detection.outputs.test_kit_image }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run PHPCS to check following the standard
run: |
set -e
cd "$GITHUB_WORKSPACE"
composer install --prefer-dist
bin/codestyle
codeanalyze:
name: PHPStan static analysis
runs-on: ubuntu-22.04
needs: [ref_detection]
container:
image: ${{ needs.ref_detection.outputs.test_kit_image }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run PHPStan to analyze the codebase
run: |
set -e
cd "$GITHUB_WORKSPACE"
composer install --prefer-dist
bin/codeanalyze
tests-passed:
runs-on: ubuntu-latest
needs: [clt, codestyle, codeanalyze]
name: Tests passed
if: always()
steps:
- name: Check if all tests passed
run: |
if ${{ ((contains(needs.clt.result, 'completed') && github.ref == 'refs/heads/main' ) || contains(needs.clt.result,'success')) && contains(needs.codestyle.result, 'success') && contains(needs.codeanalyze.result, 'success')}}; then
echo "All tests passed successfully"
exit 0
else
echo "Some tests failed or were cancelled"
exit 1
fi