alpine: use LLVM 19 #317
This file contains 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: | |
branches: | |
- main | |
tags: | |
- "*" | |
pull_request: | |
concurrency: | |
group: ${{ github.head_ref || github.sha }}-${{ github.workflow }} | |
cancel-in-progress: true | |
jobs: | |
build: | |
name: ${{ matrix.id }} | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false | |
matrix: | |
id: | |
- "alpine-17" | |
- "alpine-16" | |
- "alpine-15" | |
- "alpine-14" | |
- "alpine-13" | |
- "alpine-12" | |
- "alpine-17-slim" | |
- "alpine-16-slim" | |
- "alpine-15-slim" | |
- "alpine-14-slim" | |
- "alpine-13-slim" | |
- "alpine-12-slim" | |
- "debian-17" | |
- "debian-16" | |
- "debian-15" | |
- "debian-14" | |
- "debian-13" | |
- "debian-12" | |
steps: | |
- uses: actions/checkout@v4 | |
- 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-17" -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@v4 | |
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 | |
if [ ${POSTGRESQL_VERSION} -lt 13 ]; then | |
rm sql/full-text-search/text/single/declarative-partitioning.sql | |
fi | |
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 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/data/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/data/pgroonga.log /host/ || : | |
sudo chown ${USER}: pgroonga.log || : | |
- name: Upload logs | |
if: always() | |
uses: actions/upload-artifact@v4 | |
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 |