diff --git a/circleci/images/Makefile b/circleci/images/Makefile index d4a574d..06acefe 100644 --- a/circleci/images/Makefile +++ b/circleci/images/Makefile @@ -26,6 +26,9 @@ CITUS_UPGRADE_VERSIONS_17=v13.2.0 # Function to get Citus versions for a specific PG major version get_citus_versions = $(CITUS_UPGRADE_VERSIONS_$(1)) +# Function to get the last Citus version for a specific PG major version +get_last_citus_version = $(lastword $(CITUS_UPGRADE_VERSIONS_$(1))) + # code below creates targets for all postgres versions in PG_VERSIONS define make-image-targets # $1 = PG_VERSION @@ -52,12 +55,12 @@ push-all:: push-extbuilder-$1 push-extbuilder-all:: push-extbuilder-$1 build-exttester-$1: - docker build \ - exttester/ \ + docker build . \ -f exttester/Dockerfile \ --build-arg=PG_VERSION=$1 \ --build-arg=PG_MAJOR=$2 \ --build-arg=PG_VERSION_CLEAN=$3 \ + --build-arg=CITUS_VERSION="$(call get_last_citus_version,$2)" \ --tag=${DOCKER_REPO}/exttester:$3${TAG_SUFFIX} build-all:: build-exttester-$1 diff --git a/circleci/images/citusupgradetester/files/sbin/build-citus b/circleci/images/citusupgradetester/files/sbin/build-citus index 2ae9bac..6ec6fdc 100755 --- a/circleci/images/citusupgradetester/files/sbin/build-citus +++ b/circleci/images/citusupgradetester/files/sbin/build-citus @@ -50,8 +50,9 @@ build_ext() { cd "${installdir}" && find . -type f -print > "${builddir}/files.lst" tar cvf "${basedir}/install-pg${pg_major}-citus${citus_version}.tar" `cat ${builddir}/files.lst` - - cd "${builddir}" && rm -rf install files.lst && make clean + find usr/lib/postgresql/${pg_major}/lib -type f -name '*.so' -printf '%P\n' > "${builddir}/so-files.lst" + tar cvf "${basedir}/so-pg${pg_major}-citus${citus_version}.tar" -C usr/lib/postgresql/${pg_major}/lib -T "${builddir}/so-files.lst" + cd "${builddir}" && rm -rf install files.lst so-files.lst && make clean } for citus_version in ${CITUS_VERSIONS} do diff --git a/circleci/images/exttester/Dockerfile b/circleci/images/exttester/Dockerfile index 661cf3c..4afad9e 100644 --- a/circleci/images/exttester/Dockerfile +++ b/circleci/images/exttester/Dockerfile @@ -50,7 +50,7 @@ RUN tar jxf "postgresql-${PG_VERSION_CLEAN}.tar.bz2" # apply optional patches that might be required for a successful testsuite WORKDIR /build/postgresql-${PG_VERSION_CLEAN}/ -COPY patches/ patches/ +COPY exttester/patches/ patches/ RUN <<'EOF' # apply postgres patches @@ -84,7 +84,7 @@ COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/build/src/te COPY --from=dev-tools-builder /build/postgresql-${PG_VERSION_CLEAN}/src/test/regress/ usr/lib/postgresql/${PG_MAJOR}/lib/regress/ RUN rm -rf usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.c usr/lib/postgresql/${PG_MAJOR}/lib/regress/*.h -FROM buildpack-deps:bullseye +FROM buildpack-deps:bullseye AS setup-environment # add unpriviliged user for tests RUN useradd -ms /bin/bash circleci @@ -137,13 +137,15 @@ ENV PATH="/root/.cargo/bin:${PATH}" RUN cpanm install IPC::Run # make special locales available -COPY locale.gen /etc/locale.gen +COPY exttester/locale.gen /etc/locale.gen RUN locale-gen ARG PG_VERSION ARG PG_MAJOR +ARG CITUS_VERSION ENV PG_VERSION=$PG_VERSION ENV PG_MAJOR=$PG_MAJOR +ENV CITUS_VERSION=$CITUS_VERSION RUN <<'EOF' # install postgres ecosystem for pg version: $PG_VERSION @@ -180,7 +182,40 @@ ENV PATH=/usr/lib/postgresql/$PG_MAJOR/bin/:$PATH # setup /var/run/postgresql for use with circleci RUN mkdir -p /var/run/postgresql && chown -R postgres:postgres /var/run/postgresql && chmod 2777 /var/run/postgresql + +FROM setup-environment AS build-citus + +ENV CITUS_VERSIONS=$CITUS_VERSION + +WORKDIR /build-citus/ +COPY citusupgradetester/files/sbin/build-citus . +RUN if [ -n "${CITUS_VERSION}" ]; then ./build-citus; else echo "Skipping citus build - CITUS_VERSION not set"; fi + + +FROM setup-environment + +ARG CITUS_VERSION +ARG PG_VERSION +ARG PG_MAJOR +ENV CITUS_VERSION=$CITUS_VERSION +ENV PG_MAJOR=$PG_MAJOR +ENV PG_VERSION=$PG_VERSION + # copy the collected files from the collection container at once into the final container COPY --from=dev-tools-collection /collect/ / +# copy citus so files from the build-citus stage +COPY --from=build-citus /build-citus/ /tmp/build-citus/ + +# Extract conditionally in shell +RUN <<'EOF' +set -eux +if [ -n "${CITUS_VERSION}" ] && [ -f "/tmp/build-citus/so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar" ]; then + mkdir -p /opt/citus-versions/${CITUS_VERSION} + cd /opt/citus-versions/${CITUS_VERSION} + tar xvf /tmp/build-citus/so-pg${PG_MAJOR}-citus${CITUS_VERSION}.tar +fi +EOF +RUN rm -rf /tmp/build-citus/ + WORKDIR /home/circleci