@@ -13,9 +13,12 @@ concurrency:
1313jobs :
1414 test :
1515 name : PHP ${{ matrix.php }} / ${{ matrix.driver }} / ${{ matrix.search_build }}
16- runs-on : ubuntu-latest
16+ runs-on : ubuntu-22.04
1717 timeout-minutes : 30
1818 continue-on-error : ${{ matrix.search_build == 'SPHINX3' }}
19+ permissions :
20+ contents : read
21+ packages : read
1922 strategy :
2023 fail-fast : false
2124 matrix :
@@ -38,48 +41,75 @@ jobs:
3841 extensions : mysqli, pdo_mysql, mbstring
3942 tools : composer:v2
4043
41- - name : Install system dependencies
44+ - name : Resolve search image and group exclusions
45+ id : vars
4246 run : |
43- sudo apt-get update
44- if ! sudo apt-get install -y --no-install-recommends libodbc1; then
45- sudo apt-get install -y --no-install-recommends libodbc2
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 }}" .
4681 fi
47- sudo apt-get install -y --no-install-recommends \
48- gcc \
49- g++ \
50- make \
51- autoconf \
52- automake \
53- libtool \
54- pkg-config \
55- wget \
56- tar
5782
58- - name : Install search engine
83+ - name : Start search daemon container
5984 run : |
60- mkdir -p "$HOME/search"
61- pushd "$HOME/search"
62- "$GITHUB_WORKSPACE/tests/install.sh"
63- popd
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
64103
65104 - name : Install dependencies
66105 run : composer update --prefer-dist --no-interaction
67106
68107 - name : Prepare autoload
69108 run : composer dump-autoload
70109
71- - name : Start search daemon
72- run : |
73- cd tests
74- "$GITHUB_WORKSPACE/tests/run.sh"
75-
76110 - name : Run tests
77111 run : |
78- EXCLUDE_GROUP=""
79- if [ "$SEARCH_BUILD" != "MANTICORE" ]; then
80- EXCLUDE_GROUP="--exclude-group=Manticore"
81- fi
82- ./vendor/bin/phpunit --configuration "tests/travis/${DRIVER}.phpunit.xml" --coverage-text $EXCLUDE_GROUP
112+ ./vendor/bin/phpunit --configuration "tests/travis/${DRIVER}.phpunit.xml" --coverage-text ${{ steps.vars.outputs.exclude_group }}
83113
84114 - name : Upload debug artifacts on failure
85115 if : failure()
@@ -91,3 +121,11 @@ jobs:
91121 tests/searchd.log
92122 tests/searchd.pid
93123 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
0 commit comments