From 8454e642c09ec2700b8ae2923f363c9f5325a489 Mon Sep 17 00:00:00 2001 From: Miro Stauder Date: Fri, 11 Apr 2025 14:18:45 +0000 Subject: [PATCH] add support for containerised tap test builds --- Makefile | 35 ++++++++++++------- docker-compose.yml | 1 + .../deb-compliant/entrypoint/entrypoint.bash | 13 +++++-- .../rhel-compliant/entrypoint/entrypoint.bash | 13 +++++-- .../suse-compliant/entrypoint/entrypoint.bash | 13 +++++-- 5 files changed, 53 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index c7bdbd966..b9ad6f71f 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,14 @@ GIT_VERSION ?= $(shell git describe --long --abbrev=7) ifndef GIT_VERSION $(error GIT_VERSION is not set) endif +export GIT_VERSION + +### NOTES: +### SOURCE_DATE_EPOCH is used for reproducible builds +### for details consult https://reproducible-builds.org/docs/source-date-epoch/ + +SOURCE_DATE_EPOCH ?= $(shell git show -s --format=%ct HEAD || date +%s) +export SOURCE_DATE_EPOCH ### NOTES: ### to compile without jemalloc, set environment variable NOJEMALLOC=1 @@ -314,7 +322,7 @@ amd64-fedora: fedora40 fedora40-clang fedora40-dbg fedora41 fedora41-clang fedor amd64-opensuse: opensuse15 opensuse15-clang opensuse15-dbg amd64-ubuntu: ubuntu22 ubuntu22-clang ubuntu22-dbg ubuntu24 ubuntu24-clang ubuntu24-dbg amd64-pkglist: - @make -nk amd64-packages 2>/dev/null | grep -Po '(?<=binaries/)proxysql\S+$$' + @${MAKE} -nk amd64-packages 2>/dev/null | grep -Po '(?<=binaries/)proxysql\S+$$' arm64-%: SYS_ARCH := aarch64 arm64-packages: arm64-centos arm64-debian arm64-ubuntu arm64-fedora arm64-opensuse arm64-almalinux @@ -325,7 +333,7 @@ arm64-fedora: fedora40 fedora41 arm64-opensuse: opensuse15 arm64-ubuntu: ubuntu22 ubuntu24 arm64-pkglist: - @make -nk arm64-packages 2>/dev/null | grep -Po '(?<=binaries/)proxysql\S+$$' + @${MAKE} -nk arm64-packages 2>/dev/null | grep -Po '(?<=binaries/)proxysql\S+$$' almalinux%: build-almalinux% ; centos%: build-centos% ; @@ -339,7 +347,7 @@ ubuntu%: build-ubuntu% ; .NOTPARALLEL: build-% build-%: BLD_NAME=$(patsubst build-%,%,$@) build-%: PKG_VERS=$(if $(filter $(shell echo ${BLD_NAME} | grep -Po '[a-z]+'),debian ubuntu),$(DEB_VERS),$(RPM_VERS)) -build-%: PKG_TYPE=$(if $(filter $(shell echo $(BLD_NAME) | grep -Po '\-de?bu?g'),-dbg -debug),-dbg,) +build-%: PKG_TYPE=$(if $(filter $(shell echo $(BLD_NAME) | grep -Po '\-de?bu?g|\-test|\-tap'),-dbg -debug -test -tap),-dbg,) build-%: PKG_NAME=$(firstword $(subst -, ,$(BLD_NAME))) build-%: PKG_COMP=$(if $(filter $(shell echo $(BLD_NAME) | grep -Po '\-clang'),-clang),-clang,) build-%: PKG_ARCH=$(if $(filter $(shell echo ${BLD_NAME} | grep -Po '[a-z]+'),debian ubuntu),$(DEB_ARCH),$(RPM_ARCH)) @@ -347,16 +355,13 @@ build-%: PKG_KIND=$(if $(filter $(shell echo ${BLD_NAME} | grep -Po '[a-z]+'),de build-%: PKG_FILE=binaries/proxysql$(PKG_VERS)$(PKG_TYPE)-$(PKG_NAME)$(PKG_COMP)$(PKG_ARCH).$(PKG_KIND) build-%: @echo 'building $@' - @IMG_NAME=$(PKG_NAME) IMG_TYPE=$(subst -,_,$(PKG_TYPE)) IMG_COMP=$(subst -,_,$(PKG_COMP)) $(MAKE) $(PKG_FILE) + @IMG_NAME=$(PKG_NAME) IMG_TYPE=$(subst -,_,$(PKG_TYPE)) IMG_COMP=$(subst -,_,$(PKG_COMP)) BLD_NAME=$(BLD_NAME) $(MAKE) $(PKG_FILE) .NOTPARALLEL: binaries/proxysql% binaries/proxysql%: - cd deps && ${MAKE} cleanall - cd lib && ${MAKE} clean - cd src && ${MAKE} clean - cd test/tap && ${MAKE} clean - cd test/deps && ${MAKE} cleanall - find . -not -path "./binaries/*" -not -path "./.git/*" -exec touch -h --date=@`git show -s --format=%ct HEAD` {} \; + ${MAKE} cleanbuild + ${MAKE} cleantest + find . -not -path "./binaries/*" -not -path "./.git/*" | xargs touch -h --date=@${SOURCE_DATE_EPOCH} @docker compose -p "${GIT_VERSION/./}" down -v --remove-orphans @docker compose -p "${GIT_VERSION/./}" up $(IMG_NAME)$(IMG_TYPE)$(IMG_COMP)_build @docker compose -p "${GIT_VERSION/./}" down -v --remove-orphans @@ -383,6 +388,11 @@ cleandev: cd lib && ${MAKE} clean cd src && ${MAKE} clean +.PHONY: cleantest +cleantest: + cd test/tap && ${MAKE} clean + cd test/deps && ${MAKE} cleanall + .PHONY: cleanall cleanall: cd deps && ${MAKE} cleanall @@ -390,9 +400,7 @@ cleanall: cd src && ${MAKE} clean cd test/tap && ${MAKE} clean cd test/deps && ${MAKE} cleanall - rm -f binaries/*deb || true - rm -f binaries/*rpm || true - rm -f binaries/*id-hash || true + rm -f binaries/* || true rm -rf pkgroot || true .PHONY: cleanbuild @@ -400,6 +408,7 @@ cleanbuild: cd deps && ${MAKE} cleanall cd lib && ${MAKE} clean cd src && ${MAKE} clean + rm -rf pkgroot || true ### install targets diff --git a/docker-compose.yml b/docker-compose.yml index b902a21d9..8354d95d9 100755 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,6 +15,7 @@ services: - WITHGCOV - NOJEMALLOC - WITHASAN + - BLD_NAME command: bash -l -c /opt/entrypoint/entrypoint.bash #################################################################################################### diff --git a/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash b/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash index f0c6ae079..a453c79a9 100755 --- a/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash +++ b/docker/images/proxysql/deb-compliant/entrypoint/entrypoint.bash @@ -25,9 +25,10 @@ echo "==> Building" git config --system --add safe.directory '/opt/proxysql' cd /opt/proxysql echo "==> ProxySQL '$(git describe --long --abbrev=7)'" -#export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) -#echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" -#find /opt/proxysql -not -path "/opt/proxysql/binaries/*" -exec touch -h --date=@${SOURCE_DATE_EPOCH} {} \; +export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) +echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" +# touch is expensive, do it before, outside of container +#find . -not -path "./binaries/*" -not -path "./.git/*" | xargs touch -h --date=@${SOURCE_DATE_EPOCH} if [[ -z ${PROXYSQL_BUILD_TYPE:-} ]] ; then deps_target="build_deps" @@ -36,6 +37,8 @@ else deps_target="build_deps_$PROXYSQL_BUILD_TYPE" build_target="$PROXYSQL_BUILD_TYPE" fi + +# clean is expensive, do it before, outside of container #${MAKE} cleanbuild ${MAKE} ${MAKEOPT} "${deps_target}" @@ -46,6 +49,10 @@ else fi touch /opt/proxysql/src/proxysql +if [[ ${BLD_NAME} =~ \-test|\-tap ]]; then + ${MAKE} ${MAKEOPT} build_tap_test_debug +fi + # Prepare package files and build DEB echo "==> Packaging" mkdir -p /opt/proxysql/pkgroot/tmp || true diff --git a/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash b/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash index 619e5878c..48cca878f 100755 --- a/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash +++ b/docker/images/proxysql/rhel-compliant/entrypoint/entrypoint.bash @@ -25,9 +25,10 @@ echo "==> Building" git config --system --add safe.directory '/opt/proxysql' cd /opt/proxysql echo "==> ProxySQL '$(git describe --long --abbrev=7)'" -#export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) -#echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" -#find /opt/proxysql -not -path "/opt/proxysql/binaries/*" -exec touch -h --date=@${SOURCE_DATE_EPOCH} {} \; +export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) +echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" +# touch is expensive, do it before, outside of container +#find . -not -path "./binaries/*" -not -path "./.git/*" | xargs touch -h --date=@${SOURCE_DATE_EPOCH} if [[ -z ${PROXYSQL_BUILD_TYPE:-} ]] ; then deps_target="build_deps" @@ -36,6 +37,8 @@ else deps_target="build_deps_$PROXYSQL_BUILD_TYPE" build_target="$PROXYSQL_BUILD_TYPE" fi + +# clean is expensive, do it before, outside of container #${MAKE} cleanbuild ${MAKE} ${MAKEOPT} "${deps_target}" @@ -46,6 +49,10 @@ else fi touch /opt/proxysql/src/proxysql +if [[ ${BLD_NAME} =~ \-test|\-tap ]]; then + ${MAKE} ${MAKEOPT} build_tap_test_debug +fi + # Prepare package files and build RPM echo "==> Packaging" mkdir -p proxysql/usr/bin proxysql/etc diff --git a/docker/images/proxysql/suse-compliant/entrypoint/entrypoint.bash b/docker/images/proxysql/suse-compliant/entrypoint/entrypoint.bash index cecea77ee..12704248c 100755 --- a/docker/images/proxysql/suse-compliant/entrypoint/entrypoint.bash +++ b/docker/images/proxysql/suse-compliant/entrypoint/entrypoint.bash @@ -25,9 +25,10 @@ echo "==> Building" git config --system --add safe.directory '/opt/proxysql' cd /opt/proxysql echo "==> ProxySQL '$(git describe --long --abbrev=7)'" -#export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) -#echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" -#find /opt/proxysql -not -path "/opt/proxysql/binaries/*" -exec touch -h --date=@${SOURCE_DATE_EPOCH} {} \; +export SOURCE_DATE_EPOCH=$(git show -s --format=%ct HEAD) +echo "==> Setting SOURCE_DATE_EPOCH=${SOURCE_DATE_EPOCH}" +# touch is expensive, do it before, outside of container +#find . -not -path "./binaries/*" -not -path "./.git/*" | xargs touch -h --date=@${SOURCE_DATE_EPOCH} if [[ -z ${PROXYSQL_BUILD_TYPE:-} ]] ; then deps_target="build_deps" @@ -36,6 +37,8 @@ else deps_target="build_deps_$PROXYSQL_BUILD_TYPE" build_target="$PROXYSQL_BUILD_TYPE" fi + +# clean is expensive, do it before, outside of container #${MAKE} cleanbuild ${MAKE} ${MAKEOPT} "${deps_target}" @@ -46,6 +49,10 @@ else fi touch /opt/proxysql/src/proxysql +if [[ ${BLD_NAME} =~ \-test|\-tap ]]; then + ${MAKE} ${MAKEOPT} build_tap_test_debug +fi + # Prepare package files and build RPM echo "==> Packaging" # prepare build root