Skip to content

build(deps): Bump docker/setup-buildx-action from 2 to 3 #203

build(deps): Bump docker/setup-buildx-action from 2 to 3

build(deps): Bump docker/setup-buildx-action from 2 to 3 #203

Workflow file for this run

name: Build
on:
push:
branches:
- master
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-15"
- "alpine-14"
- "alpine-13"
- "alpine-12"
- "alpine-11"
- "alpine-15-slim"
- "alpine-14-slim"
- "alpine-13-slim"
- "alpine-12-slim"
- "alpine-11-slim"
- "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-15" -a "${version}" = "latest" ]; then
tags="${tags},groonga/pgroonga:latest"
fi
platforms="linux/amd64"
case "${{ matrix.id }}" in
debian-*)
platforms="${platforms},linux/arm64"
;;
esac
echo "DOCKERFILE=${distribution}/${variant}/Dockerfile" >> ${GITHUB_ENV}
echo "DISTRIBUTION=${distribution}" >> ${GITHUB_ENV}
echo "PLATFORMS=${platforms}" >> ${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}
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- uses: docker/setup-qemu-action@v2
- uses: docker/setup-buildx-action@v3
id: buildx
- uses: docker/build-push-action@v4
id: build-push
with:
context: .
file: ${{ env.DOCKERFILE }}
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ env.TAGS }}
- name: Image info
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 12 ]; then
rm sql/function/highlight-html/declarative-partitioning.sql
rm sql/function/wal-set-applied-position/declarative-partitioning.sql
rm sql/vacuum/two-phase-commit.sql
fi
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@v3
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