Fix the setting incorrect the latest version when PostgreSQL is released new major version #366
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: ${{ matrix.id }} | |
| # Currently, If we use ubuntu-latest(ubuntu-24.04), | |
| # compiler crashed as below when we build docker image on Alpine Linux. | |
| # | |
| # 286.7 ninja: job terminated due to signal 11: /usr/bin/cc | |
| # -DGGML_SHARED -DHAVE_CONFIG_H -DLLAMA_SHARED | |
| # -Dtsv_query_expander_EXPORTS | |
| # -I/build/groonga.build/lib/.. -I/build/groonga.build/lib/../include | |
| # -I/build/groonga-15.0.0/lib/../include | |
| # -I/build/groonga-15.0.0/lib | |
| # -I/build/groonga.build/_deps/llama_cpp-src/src/. -I/build/groonga.build/_deps/llama_cpp-src/src/../include | |
| # -I/build/groonga.build/_deps/llama_cpp-src/ggml/src/../include | |
| # -I/build/groonga-15.0.0/vendor/mruby/../mruby-source/include -O3 | |
| # -DNDEBUG -std=gnu99 -fPIC -Wall -Wno-unused-but-set-variable | |
| # -Wno-unused-parameter -Wno-pointer-sign -Wfloat-equal -Wformat | |
| # -Wno-format-truncation -Wstrict-aliasing=2 -fno-strict-aliasing | |
| # -Wno-disabled-optimization -Wpointer-arith -Wbad-function-cast | |
| # -Wwrite-strings -Wsign-compare -Wmissing-field-initializers | |
| # -Wno-declaration-after-statement -Wno-implicit-fallthrough -MD -MT | |
| # plugins/query_expanders/CMakeFiles/tsv_query_expander.dir/tsv.c.o -MF | |
| # plugins/query_expanders/CMakeFiles/tsv_query_expander.dir/tsv.c.o.d -o | |
| # plugins/query_expanders/CMakeFiles/tsv_query_expander.dir/tsv.c.o -c | |
| # /build/groonga-15.0.0/plugins/query_expanders/tsv.c | |
| # | |
| # So, we avoid this issue by using ubuntu-22.04. | |
| runs-on: ubuntu-22.04 | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| id: | |
| - "alpine-18" | |
| - "alpine-17" | |
| - "alpine-16" | |
| - "alpine-15" | |
| - "alpine-14" | |
| - "alpine-13" | |
| - "alpine-18-slim" | |
| - "alpine-17-slim" | |
| - "alpine-16-slim" | |
| - "alpine-15-slim" | |
| - "alpine-14-slim" | |
| - "alpine-13-slim" | |
| - "debian-18" | |
| - "debian-17" | |
| - "debian-16" | |
| - "debian-15" | |
| - "debian-14" | |
| - "debian-13" | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Parse ID | |
| run: | | |
| set -x | |
| distribution=$(echo ${{ matrix.id }} | grep -o "^[^-]*") | |
| postgresql_version=$(echo ${{ matrix.id }} | grep -o "[0-9]*") | |
| variant=$(echo ${{ matrix.id }} | sed -e "s/^[^-]*-//g") | |
| case "${GITHUB_REF}" in | |
| refs/tags/*) | |
| version=${GITHUB_REF_NAME} | |
| pgroonga_ref=${version} | |
| ;; | |
| *) | |
| version=latest | |
| pgroonga_ref=$( \ | |
| grep --no-filename PGROONGA_VERSION= alpine/*/Dockerfile | \ | |
| head -n 1 | \ | |
| grep -o '[0-9.]*' \ | |
| ) | |
| ;; | |
| esac | |
| tag="groonga/pgroonga:${version}-${{ matrix.id }}" | |
| tags="${tag}" | |
| if [ ${{ matrix.id }} = "alpine-18" -a "${version}" = "latest" ]; then | |
| tags="${tags},groonga/pgroonga:latest" | |
| fi | |
| echo "DOCKERFILE=${distribution}/${variant}/Dockerfile" >> ${GITHUB_ENV} | |
| echo "DISTRIBUTION=${distribution}" >> ${GITHUB_ENV} | |
| echo "PGROONGA_REF=${pgroonga_ref}" >> ${GITHUB_ENV} | |
| echo "POSTGRESQL_VERSION=${postgresql_version}" >> ${GITHUB_ENV} | |
| echo "TAG=${tag}" >> ${GITHUB_ENV} | |
| echo "TAGS=${tags}" >> ${GITHUB_ENV} | |
| echo "VARIANT=${variant}" >> ${GITHUB_ENV} | |
| echo "VERSION=${version}" >> ${GITHUB_ENV} | |
| NEED_PUSH=no | |
| PLATFORMS="linux/amd64" | |
| if [[ "${GITHUB_EVENT_NAME}" = "push" && \ | |
| "${GITHUB_REPOSITORY}" = "pgroonga/docker" && \ | |
| ("${GITHUB_REF_NAME}" = "main" || \ | |
| "${GITHUB_REF_TYPE}" = "tag") ]]; then | |
| NEED_PUSH=yes | |
| # Include linux/arm64 only when pushing. | |
| # When not pushing, the image is loaded locally, but this will cause an error | |
| # if linux/arm64 is included. | |
| PLATFORMS+=",linux/arm64" | |
| fi | |
| echo "NEED_PUSH=${NEED_PUSH}" >> ${GITHUB_ENV} | |
| echo "PLATFORMS=${PLATFORMS}" >> ${GITHUB_ENV} | |
| - uses: docker/login-action@v3 | |
| if: env.NEED_PUSH == 'yes' | |
| with: | |
| username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
| password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
| - uses: docker/setup-qemu-action@v3 | |
| - uses: docker/setup-buildx-action@v3 | |
| id: buildx | |
| - uses: docker/build-push-action@v6 | |
| id: build-push | |
| with: | |
| context: . | |
| file: ${{ env.DOCKERFILE }} | |
| platforms: ${{ env.PLATFORMS }} | |
| push: ${{ env.NEED_PUSH == 'yes' }} | |
| load: ${{ env.NEED_PUSH != 'yes' }} | |
| tags: ${{ env.TAGS }} | |
| - name: Image info | |
| if: env.NEED_PUSH == 'yes' | |
| run: | | |
| echo "ref: ${GITHUB_REF}" | |
| echo "tags: ${TAGS}" | |
| echo "digest: ${{ steps.build-push.outputs.digest }}" | |
| - uses: actions/checkout@v6 | |
| with: | |
| path: pgroonga | |
| ref: ${{ env.PGROONGA_REF }} | |
| repository: pgroonga/pgroonga | |
| - name: Test | |
| env: | |
| PGPASSWORD: pgroonga | |
| run: | | |
| echo "::group::Prepare tests" | |
| pushd pgroonga | |
| if [ "${DISTRIBUTION}" = "alpine" ]; then | |
| # TODO: Remove me when Groonga bundles libstemmer | |
| rm sql/full-text-search/text/options/token-filters/custom.sql | |
| fi | |
| # Reduce tests to reduce test time | |
| rm -r sql/compatibility | |
| ruby test/prepare.rb > schedule | |
| popd | |
| echo "::endgroup" | |
| for platform in $(echo ${PLATFORMS} | tr "," " "); do | |
| echo "::group::Prepare Docker container for ${platform}" | |
| docker run \ | |
| --name pgroonga \ | |
| --detach \ | |
| --env PGDATA=/var/lib/postgresql/${postgresql_version}/docker \ | |
| --env POSTGRES_DB=pgroonga \ | |
| --env POSTGRES_PASSWORD=${PGPASSWORD} \ | |
| --env POSTGRES_USER=pgroonga \ | |
| --publish 127.0.0.1:5432:5432 \ | |
| --platform ${platform} \ | |
| --volume ${PWD}:/host \ | |
| ${TAG} \ | |
| postgres \ | |
| -c max_prepared_transactions=1 \ | |
| -c search_path=public | |
| for i in {1..60}; do | |
| if pg_isready -h 127.0.0.1; then | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| if [ $i -eq 60 ]; then | |
| echo "PostgreSQL isn't available" | |
| exit 1 | |
| fi | |
| echo "::endgroup" | |
| echo "::group::Test for ${platform}" | |
| docker exec pgroonga /host/test/run.sh | |
| echo "::endgroup" | |
| echo "::group::Postpare Docker container" | |
| log_path=pgroonga-$(echo ${platform} | cut -d/ -f2).log | |
| docker exec pgroonga \ | |
| cp \ | |
| /var/lib/postgresql/${postgresql_version}/docker/pgroonga.log \ | |
| /host/${log_path} | |
| sudo chown ${USER}: ${log_path} | |
| docker kill --signal TERM pgroonga | |
| for i in {1..60}; do | |
| if [ $(docker ps --filter id=pgroonga | wc -l) -eq 1 ]; then | |
| break | |
| fi | |
| sleep 1 | |
| done | |
| if [ $i -eq 60 ]; then | |
| echo "Can't shutdown PostgreSQL" | |
| exit 1 | |
| fi | |
| docker rm --force pgroonga | |
| echo "::endgroup" | |
| done | |
| - name: Collect logs | |
| if: always() | |
| run: | | |
| docker exec pgroonga cp /var/lib/postgresql/${postgresql_version}/docker/pgroonga.log /host/ || : | |
| sudo chown ${USER}: pgroonga.log || : | |
| - name: Upload logs | |
| if: always() | |
| uses: actions/upload-artifact@v5 | |
| with: | |
| name: logs-${{ matrix.id }} | |
| path: | | |
| *.log | |
| - name: Show logs | |
| if: always() | |
| run: | | |
| for log in *.log; do | |
| echo "::group::${log}" | |
| cat "${log}" | |
| echo "::endgroup" | |
| done |