Skip to content

Commit c4f0b33

Browse files
authored
Merge pull request #216 from FoolCode/ci/migrate-to-github-actions
ci: migrate from Travis to GitHub Actions
2 parents b1eb01c + 012e3ff commit c4f0b33

File tree

15 files changed

+471
-54
lines changed

15 files changed

+471
-54
lines changed

.github/workflows/ci.yml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- master
8+
9+
concurrency:
10+
group: ci-${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test:
15+
name: PHP ${{ matrix.php }} / ${{ matrix.driver }} / ${{ matrix.search_build }}
16+
runs-on: ubuntu-22.04
17+
timeout-minutes: 30
18+
continue-on-error: ${{ matrix.search_build == 'SPHINX3' }}
19+
permissions:
20+
contents: read
21+
packages: read
22+
strategy:
23+
fail-fast: false
24+
matrix:
25+
php: ['7.4', '8.0', '8.1']
26+
driver: [mysqli, pdo]
27+
search_build: [SPHINX2, SPHINX3, MANTICORE]
28+
env:
29+
DRIVER: ${{ matrix.driver }}
30+
SEARCH_BUILD: ${{ matrix.search_build }}
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup PHP
37+
uses: shivammathur/setup-php@v2
38+
with:
39+
php-version: ${{ matrix.php }}
40+
coverage: none
41+
extensions: mysqli, pdo_mysql, mbstring
42+
tools: composer:v2
43+
44+
- name: Resolve search image and group exclusions
45+
id: vars
46+
run: |
47+
EXCLUDE_GROUP=""
48+
SEARCH_IMAGE=""
49+
SEARCH_DOCKERFILE=""
50+
case "$SEARCH_BUILD" in
51+
SPHINX2)
52+
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-sphinx2:sphinx2-latest"
53+
SEARCH_DOCKERFILE="docker/search/sphinx2/Dockerfile"
54+
EXCLUDE_GROUP="--exclude-group=Manticore"
55+
;;
56+
SPHINX3)
57+
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-sphinx3:sphinx3-latest"
58+
SEARCH_DOCKERFILE="docker/search/sphinx3/Dockerfile"
59+
EXCLUDE_GROUP="--exclude-group=Manticore"
60+
;;
61+
MANTICORE)
62+
SEARCH_IMAGE="ghcr.io/foolcode/sphinxql-query-builder-search-manticore:manticore-latest"
63+
SEARCH_DOCKERFILE="docker/search/manticore/Dockerfile"
64+
;;
65+
*)
66+
echo "Unknown SEARCH_BUILD: $SEARCH_BUILD"
67+
exit 1
68+
;;
69+
esac
70+
{
71+
echo "search_image=$SEARCH_IMAGE"
72+
echo "search_dockerfile=$SEARCH_DOCKERFILE"
73+
echo "exclude_group=$EXCLUDE_GROUP"
74+
} >> "$GITHUB_OUTPUT"
75+
76+
- name: Fetch search image
77+
run: |
78+
if ! docker pull "${{ steps.vars.outputs.search_image }}"; then
79+
echo "Unable to pull image, building from repository Dockerfile fallback."
80+
docker build -f "${{ steps.vars.outputs.search_dockerfile }}" -t "${{ steps.vars.outputs.search_image }}" .
81+
fi
82+
83+
- name: Start search daemon container
84+
run: |
85+
docker run -d --name searchd \
86+
-p 9307:9307 \
87+
-p 9312:9312 \
88+
"${{ steps.vars.outputs.search_image }}"
89+
90+
- name: Wait for searchd
91+
run: |
92+
n=0
93+
while [ "$n" -lt 60 ]; do
94+
if (echo > /dev/tcp/127.0.0.1/9307) >/dev/null 2>&1; then
95+
exit 0
96+
fi
97+
n=$((n + 1))
98+
sleep 1
99+
done
100+
echo "searchd did not become ready on 127.0.0.1:9307"
101+
docker logs searchd || true
102+
exit 1
103+
104+
- name: Install dependencies
105+
run: composer update --prefer-dist --no-interaction
106+
107+
- name: Prepare autoload
108+
run: composer dump-autoload
109+
110+
- name: Run tests
111+
run: |
112+
./vendor/bin/phpunit --configuration "tests/travis/${DRIVER}.phpunit.xml" --coverage-text ${{ steps.vars.outputs.exclude_group }}
113+
114+
- name: Upload debug artifacts on failure
115+
if: failure()
116+
uses: actions/upload-artifact@v4
117+
with:
118+
name: ci-debug-php${{ matrix.php }}-${{ matrix.driver }}-${{ matrix.search_build }}
119+
if-no-files-found: ignore
120+
path: |
121+
tests/searchd.log
122+
tests/searchd.pid
123+
tests/data/*
124+
125+
- name: Show searchd logs
126+
if: always()
127+
run: docker logs searchd || true
128+
129+
- name: Stop searchd container
130+
if: always()
131+
run: docker rm -f searchd || true
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Publish Search Images
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- master
8+
paths:
9+
- .github/workflows/publish-search-images.yml
10+
- docker/search/**
11+
- tests/sphinx.conf
12+
- tests/manticore.conf
13+
- tests/test_udf.c
14+
- tests/ms_test_udf.c
15+
16+
permissions:
17+
contents: read
18+
packages: write
19+
20+
jobs:
21+
publish:
22+
name: Publish ${{ matrix.target }} image
23+
runs-on: ubuntu-latest
24+
strategy:
25+
fail-fast: false
26+
matrix:
27+
include:
28+
- target: sphinx2
29+
version: 2.3.2-beta
30+
dockerfile: docker/search/sphinx2/Dockerfile
31+
- target: sphinx3
32+
version: 3.9.1
33+
dockerfile: docker/search/sphinx3/Dockerfile
34+
- target: manticore
35+
version: 2.6.3
36+
dockerfile: docker/search/manticore/Dockerfile
37+
38+
steps:
39+
- name: Checkout
40+
uses: actions/checkout@v4
41+
42+
- name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v3
44+
45+
- name: Login to GHCR
46+
uses: docker/login-action@v3
47+
with:
48+
registry: ghcr.io
49+
username: ${{ github.actor }}
50+
password: ${{ secrets.GITHUB_TOKEN }}
51+
52+
- name: Build and push
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
file: ${{ matrix.dockerfile }}
57+
push: true
58+
tags: |
59+
ghcr.io/foolcode/sphinxql-query-builder-search-${{ matrix.target }}:${{ matrix.target }}-${{ matrix.version }}
60+
ghcr.io/foolcode/sphinxql-query-builder-search-${{ matrix.target }}:${{ matrix.target }}-latest
61+
cache-from: type=gha
62+
cache-to: type=gha,mode=max

.travis.yml

Lines changed: 0 additions & 42 deletions
This file was deleted.

Dockerfile.test

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM php:8.3-cli
2+
3+
RUN apt-get update \
4+
&& apt-get install -y --no-install-recommends \
5+
ca-certificates \
6+
gcc \
7+
git \
8+
libonig-dev \
9+
unzip \
10+
wget \
11+
&& rm -rf /var/lib/apt/lists/*
12+
13+
RUN docker-php-ext-install mysqli pdo_mysql mbstring
14+
15+
RUN php -r "copy('https://composer.github.io/installer.sig', 'composer.sig');" \
16+
&& php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \
17+
&& 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); }" \
18+
&& php composer-setup.php --install-dir=/usr/local/bin --filename=composer \
19+
&& php -r "unlink('composer-setup.php'); unlink('composer.sig');"
20+
21+
WORKDIR /work
22+
23+
ENV COMPOSER_ALLOW_SUPERUSER=1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Query Builder for SphinxQL
22
==========================
33

4-
[![Build Status](https://travis-ci.org/FoolCode/SphinxQL-Query-Builder.png)](https://travis-ci.org/FoolCode/SphinxQL-Query-Builder)
4+
[![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)
55
[![Latest Stable Version](https://poser.pugx.org/foolz/sphinxql-query-builder/v/stable)](https://packagist.org/packages/foolz/sphinxql-query-builder)
66
[![Latest Unstable Version](https://poser.pugx.org/foolz/sphinxql-query-builder/v/unstable)](https://packagist.org/packages/foolz/sphinxql-query-builder)
77
[![Total Downloads](https://poser.pugx.org/foolz/sphinxql-query-builder/downloads)](https://packagist.org/packages/foolz/sphinxql-query-builder)

docker/search/manticore/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu:22.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV MANTICORE_VERSION=2.6.3
5+
ENV LD_LIBRARY_PATH=/opt/manticore/usr/lib/x86_64-linux-gnu:/opt/manticore/usr/lib
6+
7+
RUN apt-get update \
8+
&& apt-get install -y --no-install-recommends \
9+
ca-certificates \
10+
wget \
11+
gcc \
12+
libc6-dev \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
WORKDIR /opt/sphinx-tests
16+
17+
RUN wget --quiet -O /opt/sphinx-tests/search.deb \
18+
"https://github.com/manticoresoftware/manticoresearch/releases/download/${MANTICORE_VERSION}/manticore_${MANTICORE_VERSION}-180328-cccb538-release-stemmer.trusty_amd64-bin.deb" \
19+
&& dpkg -x /opt/sphinx-tests/search.deb /opt/manticore \
20+
&& rm -f /opt/sphinx-tests/search.deb
21+
22+
COPY tests/manticore.conf /opt/sphinx-tests/manticore.conf
23+
COPY tests/ms_test_udf.c /opt/sphinx-tests/ms_test_udf.c
24+
25+
RUN mkdir -p /opt/sphinx-tests/data \
26+
&& gcc -shared -fPIC -I/opt/manticore/usr/include -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/ms_test_udf.c
27+
28+
EXPOSE 9307 9312
29+
30+
CMD ["/opt/manticore/usr/bin/searchd", "-c", "/opt/sphinx-tests/manticore.conf", "--nodetach"]

docker/search/sphinx2/Dockerfile

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV SPHINX2_VERSION=2.3.2-beta
5+
6+
RUN apt-get update \
7+
&& apt-get install -y --no-install-recommends \
8+
ca-certificates \
9+
wget \
10+
gcc \
11+
g++ \
12+
make \
13+
autoconf \
14+
automake \
15+
libtool \
16+
pkg-config \
17+
bison \
18+
flex \
19+
libexpat1-dev \
20+
zlib1g-dev \
21+
libssl-dev \
22+
&& rm -rf /var/lib/apt/lists/*
23+
24+
WORKDIR /opt/sphinx-tests
25+
26+
RUN wget --quiet "https://sphinxsearch.com/files/sphinx-${SPHINX2_VERSION}.tar.gz" \
27+
&& tar zxf "sphinx-${SPHINX2_VERSION}.tar.gz" \
28+
&& cd "sphinx-${SPHINX2_VERSION}" \
29+
&& ./configure --prefix=/opt/sphinx --without-mysql \
30+
&& make -j"$(nproc)" \
31+
&& make install \
32+
&& cd /opt/sphinx-tests \
33+
&& rm -rf "sphinx-${SPHINX2_VERSION}" "sphinx-${SPHINX2_VERSION}.tar.gz"
34+
35+
COPY tests/sphinx.conf /opt/sphinx-tests/sphinx.conf
36+
COPY tests/test_udf.c /opt/sphinx-tests/test_udf.c
37+
38+
RUN mkdir -p /opt/sphinx-tests/data \
39+
&& gcc -shared -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/test_udf.c
40+
41+
EXPOSE 9307 9312
42+
43+
CMD ["/opt/sphinx/bin/searchd", "-c", "/opt/sphinx-tests/sphinx.conf", "--nodetach"]

docker/search/sphinx3/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM ubuntu:24.04
2+
3+
ENV DEBIAN_FRONTEND=noninteractive
4+
ENV SPHINX3_VERSION=3.9.1
5+
ENV SPHINX3_BUILD=141d2ea
6+
7+
RUN apt-get update \
8+
&& apt-get install -y --no-install-recommends \
9+
ca-certificates \
10+
wget \
11+
gcc \
12+
libc6-dev \
13+
&& rm -rf /var/lib/apt/lists/*
14+
15+
WORKDIR /opt/sphinx-tests
16+
17+
RUN wget --quiet "https://sphinxsearch.com/files/sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz" \
18+
&& tar zxf "sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz" \
19+
&& mv "sphinx-${SPHINX3_VERSION}" /opt/sphinx3 \
20+
&& rm -f "sphinx-${SPHINX3_VERSION}-${SPHINX3_BUILD}-linux-amd64.tar.gz"
21+
22+
COPY tests/sphinx.conf /opt/sphinx-tests/sphinx.conf
23+
COPY tests/test_udf.c /opt/sphinx-tests/test_udf.c
24+
25+
RUN mkdir -p /opt/sphinx-tests/data \
26+
&& gcc -shared -o /opt/sphinx-tests/data/test_udf.so /opt/sphinx-tests/test_udf.c
27+
28+
EXPOSE 9307 9312
29+
30+
CMD ["/opt/sphinx3/bin/searchd", "-c", "/opt/sphinx-tests/sphinx.conf", "--nodetach"]

0 commit comments

Comments
 (0)