Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
131 changes: 131 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
name: CI

on:
pull_request:
push:
branches:
- master

concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: PHP ${{ matrix.php }} / ${{ matrix.driver }} / ${{ matrix.search_build }}
runs-on: ubuntu-22.04
timeout-minutes: 30
continue-on-error: ${{ matrix.search_build == 'SPHINX3' }}
permissions:
contents: read
packages: read
strategy:
fail-fast: false
matrix:
php: ['7.4', '8.0', '8.1']
driver: [mysqli, pdo]
search_build: [SPHINX2, SPHINX3, MANTICORE]
env:
DRIVER: ${{ matrix.driver }}
SEARCH_BUILD: ${{ matrix.search_build }}

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: none
extensions: mysqli, pdo_mysql, mbstring
tools: composer:v2

- name: Resolve search image and group exclusions
id: vars
run: |
EXCLUDE_GROUP=""
SEARCH_IMAGE=""
SEARCH_DOCKERFILE=""
case "$SEARCH_BUILD" in
SPHINX2)
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-sphinx2:sphinx2-latest"
SEARCH_DOCKERFILE="docker/search/sphinx2/Dockerfile"
EXCLUDE_GROUP="--exclude-group=Manticore"
;;
SPHINX3)
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-sphinx3:sphinx3-latest"
SEARCH_DOCKERFILE="docker/search/sphinx3/Dockerfile"
EXCLUDE_GROUP="--exclude-group=Manticore"
;;
MANTICORE)
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-manticore:manticore-latest"
SEARCH_DOCKERFILE="docker/search/manticore/Dockerfile"
;;
*)
echo "Unknown SEARCH_BUILD: $SEARCH_BUILD"
exit 1
;;
esac
{
echo "search_image=$SEARCH_IMAGE"
echo "search_dockerfile=$SEARCH_DOCKERFILE"
echo "exclude_group=$EXCLUDE_GROUP"
} >> "$GITHUB_OUTPUT"

- name: Fetch search image
run: |
if ! docker pull "${{ steps.vars.outputs.search_image }}"; then
echo "Unable to pull image, building from repository Dockerfile fallback."
docker build -f "${{ steps.vars.outputs.search_dockerfile }}" -t "${{ steps.vars.outputs.search_image }}" .
fi

- name: Start search daemon container
run: |
docker run -d --name searchd \
-p 9307:9307 \
-p 9312:9312 \
"${{ steps.vars.outputs.search_image }}"

- name: Wait for searchd
run: |
n=0
while [ "$n" -lt 60 ]; do
if (echo > /dev/tcp/127.0.0.1/9307) >/dev/null 2>&1; then
exit 0
fi
n=$((n + 1))
sleep 1
done
echo "searchd did not become ready on 127.0.0.1:9307"
docker logs searchd || true
exit 1

- name: Install dependencies
run: composer update --prefer-dist --no-interaction

- name: Prepare autoload
run: composer dump-autoload

- name: Run tests
run: |
./vendor/bin/phpunit --configuration "tests/travis/${DRIVER}.phpunit.xml" --coverage-text ${{ steps.vars.outputs.exclude_group }}

- name: Upload debug artifacts on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: ci-debug-php${{ matrix.php }}-${{ matrix.driver }}-${{ matrix.search_build }}
if-no-files-found: ignore
path: |
tests/searchd.log
tests/searchd.pid
tests/data/*

- name: Show searchd logs
if: always()
run: docker logs searchd || true

- name: Stop searchd container
if: always()
run: docker rm -f searchd || true
62 changes: 62 additions & 0 deletions .github/workflows/publish-search-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Publish Search Images

on:
workflow_dispatch:
push:
branches:
- master
paths:
- .github/workflows/publish-search-images.yml
- docker/search/**
- tests/sphinx.conf
- tests/manticore.conf
- tests/test_udf.c
- tests/ms_test_udf.c

permissions:
contents: read
packages: write

jobs:
publish:
name: Publish ${{ matrix.target }} image
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- target: sphinx2
version: 2.3.2-beta
dockerfile: docker/search/sphinx2/Dockerfile
- target: sphinx3
version: 3.9.1
dockerfile: docker/search/sphinx3/Dockerfile
- target: manticore
version: 2.6.3
dockerfile: docker/search/manticore/Dockerfile

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
tags: |
ghcr.io/foolcode/sphinxql-query-builder-search-${{ matrix.target }}:${{ matrix.target }}-${{ matrix.version }}
ghcr.io/foolcode/sphinxql-query-builder-search-${{ matrix.target }}:${{ matrix.target }}-latest
cache-from: type=gha
cache-to: type=gha,mode=max
42 changes: 0 additions & 42 deletions .travis.yml

This file was deleted.

23 changes: 23 additions & 0 deletions Dockerfile.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
FROM php:8.3-cli

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
gcc \
git \
libonig-dev \
unzip \
wget \
&& rm -rf /var/lib/apt/lists/*

RUN docker-php-ext-install mysqli pdo_mysql mbstring

RUN php -r "copy('https://composer.github.io/installer.sig', 'composer.sig');" \
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
&& php -r "if (trim(file_get_contents('composer.sig')) !== hash_file('sha384', 'composer-setup.php')) { fwrite(STDERR, 'Invalid Composer installer checksum'.PHP_EOL); exit(1); }" \
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
&& php -r "unlink('composer-setup.php'); unlink('composer.sig');"

WORKDIR /work

ENV COMPOSER_ALLOW_SUPERUSER=1
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Query Builder for SphinxQL
==========================

[![Build Status](https://travis-ci.org/FoolCode/SphinxQL-Query-Builder.png)](https://travis-ci.org/FoolCode/SphinxQL-Query-Builder)
[![CI](https://github.com/FoolCode/SphinxQL-Query-Builder/actions/workflows/ci.yml/badge.svg)](https://github.com/FoolCode/SphinxQL-Query-Builder/actions/workflows/ci.yml)
[![Latest Stable Version](https://poser.pugx.org/foolz/sphinxql-query-builder/v/stable)](https://packagist.org/packages/foolz/sphinxql-query-builder)
[![Latest Unstable Version](https://poser.pugx.org/foolz/sphinxql-query-builder/v/unstable)](https://packagist.org/packages/foolz/sphinxql-query-builder)
[![Total Downloads](https://poser.pugx.org/foolz/sphinxql-query-builder/downloads)](https://packagist.org/packages/foolz/sphinxql-query-builder)
Expand Down
30 changes: 30 additions & 0 deletions docker/search/manticore/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:22.04

ENV DEBIAN_FRONTEND=noninteractive
ENV MANTICORE_VERSION=2.6.3
ENV LD_LIBRARY_PATH=/opt/manticore/usr/lib/x86_64-linux-gnu:/opt/manticore/usr/lib

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
wget \
gcc \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/sphinx-tests

RUN wget --quiet -O /opt/sphinx-tests/search.deb \
"https://github.com/manticoresoftware/manticoresearch/releases/download/${MANTICORE_VERSION}/manticore_${MANTICORE_VERSION}-180328-cccb538-release-stemmer.trusty_amd64-bin.deb" \
&& dpkg -x /opt/sphinx-tests/search.deb /opt/manticore \
&& rm -f /opt/sphinx-tests/search.deb

COPY tests/manticore.conf /opt/sphinx-tests/manticore.conf
COPY tests/ms_test_udf.c /opt/sphinx-tests/ms_test_udf.c

RUN mkdir -p /opt/sphinx-tests/data \
&& gcc -shared -fPIC -I/opt/manticore/usr/include -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/ms_test_udf.c

EXPOSE 9307 9312

CMD ["/opt/manticore/usr/bin/searchd", "-c", "/opt/sphinx-tests/manticore.conf", "--nodetach"]
43 changes: 43 additions & 0 deletions docker/search/sphinx2/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV SPHINX2_VERSION=2.3.2-beta

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
wget \
gcc \
g++ \
make \
autoconf \
automake \
libtool \
pkg-config \
bison \
flex \
libexpat1-dev \
zlib1g-dev \
libssl-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/sphinx-tests

RUN wget --quiet "https://sphinxsearch.com/files/sphinx-${SPHINX2_VERSION}.tar.gz" \
&& tar zxf "sphinx-${SPHINX2_VERSION}.tar.gz" \
&& cd "sphinx-${SPHINX2_VERSION}" \
&& ./configure --prefix=/opt/sphinx --without-mysql \
&& make -j"$(nproc)" \
&& make install \
&& cd /opt/sphinx-tests \
&& rm -rf "sphinx-${SPHINX2_VERSION}" "sphinx-${SPHINX2_VERSION}.tar.gz"

COPY tests/sphinx.conf /opt/sphinx-tests/sphinx.conf
COPY tests/test_udf.c /opt/sphinx-tests/test_udf.c

RUN mkdir -p /opt/sphinx-tests/data \
&& gcc -shared -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/test_udf.c

EXPOSE 9307 9312

CMD ["/opt/sphinx/bin/searchd", "-c", "/opt/sphinx-tests/sphinx.conf", "--nodetach"]
30 changes: 30 additions & 0 deletions docker/search/sphinx3/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM ubuntu:24.04

ENV DEBIAN_FRONTEND=noninteractive
ENV SPHINX3_VERSION=3.9.1
ENV SPHINX3_BUILD=141d2ea

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
ca-certificates \
wget \
gcc \
libc6-dev \
&& rm -rf /var/lib/apt/lists/*

WORKDIR /opt/sphinx-tests

RUN wget --quiet "https://sphinxsearch.com/files/sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz" \
&& tar zxf "sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz" \
&& mv "sphinx-${SPHINX3_VERSION}" /opt/sphinx3 \
&& rm -f "sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz"

COPY tests/sphinx.conf /opt/sphinx-tests/sphinx.conf
COPY tests/test_udf.c /opt/sphinx-tests/test_udf.c

RUN mkdir -p /opt/sphinx-tests/data \
&& gcc -shared -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/test_udf.c

EXPOSE 9307 9312

CMD ["/opt/sphinx3/bin/searchd", "-c", "/opt/sphinx-tests/sphinx.conf", "--nodetach"]
Loading
Loading