From 4af8e8d679b68a7cc27ce7ca8943e158a44b0289 Mon Sep 17 00:00:00 2001
From: artembo <artembo@me.com>
Date: Sun, 24 Apr 2022 23:51:12 +0300
Subject: [PATCH] ci: build Tarantool with enabled gc64

To make tarantool-gc64 available in repository we need to provide
a product name in a package itself and in the repository.

To build Tarantool with gc64 enabled, the flag -DLUAJIT_ENABLE_GC64
needs to be passed to cmake flags. For this purposes GC64 env var
was added to all workflows for Debian, Ubuntu, Centos and Fedora.

This variable is processed to rename PRODUCT_NAME. If GC64 is
eanbled, PRODUCT_NAME is `tarantool-gc64`, otherwise it stays
`tarantool`, which goes to repository name and the package itself.
Thus, Tarantool with gc64 enabled can be installed by
`<packaen_manager> install -y tarantool-gc64`
in the one single repository.

NO_DOC=ci
NO_TEST=ci
NO_CHANGELOG=ci

Closes: tarantool/tarantool-qa#161
---
 .github/actions/environment/action.yml |  2 +-
 .github/workflows/centos_7.yml         |  6 ++++++
 .github/workflows/centos_8.yml         |  6 ++++++
 .github/workflows/debian_10.yml        |  6 ++++++
 .github/workflows/debian_11.yml        |  6 ++++++
 .github/workflows/debian_9.yml         |  6 ++++++
 .github/workflows/fedora_30.yml        |  6 ++++++
 .github/workflows/fedora_31.yml        |  6 ++++++
 .github/workflows/fedora_32.yml        |  6 ++++++
 .github/workflows/fedora_33.yml        |  6 ++++++
 .github/workflows/fedora_34.yml        |  6 ++++++
 .github/workflows/fedora_35.yml        |  6 ++++++
 .github/workflows/ubuntu_16_04.yml     |  6 ++++++
 .github/workflows/ubuntu_18_04.yml     |  6 ++++++
 .github/workflows/ubuntu_20_04.yml     |  6 ++++++
 .github/workflows/ubuntu_21_04.yml     |  6 ++++++
 .github/workflows/ubuntu_21_10.yml     |  6 ++++++
 .gitlab.mk                             | 20 +++++++++++++++++---
 debian/rules                           |  6 ++++++
 rpm/tarantool.spec                     | 17 +++++++++++++++++
 20 files changed, 137 insertions(+), 4 deletions(-)

diff --git a/.github/actions/environment/action.yml b/.github/actions/environment/action.yml
index c5cfd18e00..412bcc1714 100644
--- a/.github/actions/environment/action.yml
+++ b/.github/actions/environment/action.yml
@@ -10,7 +10,7 @@ runs:
         echo REPLICATION_SYNC_TIMEOUT=300 | tee -a $GITHUB_ENV
         echo TEST_TIMEOUT=310 | tee -a $GITHUB_ENV
         echo NO_OUTPUT_TIMEOUT=320 | tee -a $GITHUB_ENV
-        echo PRESERVE_ENVVARS=TEST_RUN_RETRIES,SERVER_START_TIMEOUT,REPLICATION_SYNC_TIMEOUT,TEST_TIMEOUT,NO_OUTPUT_TIMEOUT | tee -a $GITHUB_ENV
+        echo PRESERVE_ENVVARS=TEST_RUN_RETRIES,SERVER_START_TIMEOUT,REPLICATION_SYNC_TIMEOUT,TEST_TIMEOUT,NO_OUTPUT_TIMEOUT,GC64 | tee -a $GITHUB_ENV
         # Configure AWS Region to avoid of issue:
         #   https://github.com/tarantool/tarantool-qa/issues/111
         echo AWS_DEFAULT_REGION=MS | tee -a $GITHUB_ENV
diff --git a/.github/workflows/centos_7.yml b/.github/workflows/centos_7.yml
index d3397fc8c9..df67349ca5 100644
--- a/.github/workflows/centos_7.yml
+++ b/.github/workflows/centos_7.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'el'
           DIST: '7'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/centos_8.yml b/.github/workflows/centos_8.yml
index 309994d92d..56cc624502 100644
--- a/.github/workflows/centos_8.yml
+++ b/.github/workflows/centos_8.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'el'
           DIST: '8'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/debian_10.yml b/.github/workflows/debian_10.yml
index 5f22619551..bb52780727 100644
--- a/.github/workflows/debian_10.yml
+++ b/.github/workflows/debian_10.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'debian'
           DIST: 'buster'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/debian_11.yml b/.github/workflows/debian_11.yml
index 5ed4a5958d..a37fdf3b50 100644
--- a/.github/workflows/debian_11.yml
+++ b/.github/workflows/debian_11.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'debian'
           DIST: 'bullseye'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/debian_9.yml b/.github/workflows/debian_9.yml
index b94747ceb8..38259e7ea4 100644
--- a/.github/workflows/debian_9.yml
+++ b/.github/workflows/debian_9.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'debian'
           DIST: 'stretch'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_30.yml b/.github/workflows/fedora_30.yml
index 0b6a196e3d..6c52de05f5 100644
--- a/.github/workflows/fedora_30.yml
+++ b/.github/workflows/fedora_30.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '30'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_31.yml b/.github/workflows/fedora_31.yml
index 47e3edaf1e..b4b38cdb73 100644
--- a/.github/workflows/fedora_31.yml
+++ b/.github/workflows/fedora_31.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '31'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_32.yml b/.github/workflows/fedora_32.yml
index bcb3d76e2d..eba3feeabb 100644
--- a/.github/workflows/fedora_32.yml
+++ b/.github/workflows/fedora_32.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '32'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_33.yml b/.github/workflows/fedora_33.yml
index 149e7a2961..4c46c7b5f6 100644
--- a/.github/workflows/fedora_33.yml
+++ b/.github/workflows/fedora_33.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '33'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_34.yml b/.github/workflows/fedora_34.yml
index ebf13dd07e..ffc8e7560c 100644
--- a/.github/workflows/fedora_34.yml
+++ b/.github/workflows/fedora_34.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '34'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/fedora_35.yml b/.github/workflows/fedora_35.yml
index 7029513a73..78f0521c0a 100644
--- a/.github/workflows/fedora_35.yml
+++ b/.github/workflows/fedora_35.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF", "GC64=ON" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'fedora'
           DIST: '35'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/ubuntu_16_04.yml b/.github/workflows/ubuntu_16_04.yml
index be7bce7772..c385af4ebd 100644
--- a/.github/workflows/ubuntu_16_04.yml
+++ b/.github/workflows/ubuntu_16_04.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'ubuntu'
           DIST: 'xenial'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/ubuntu_18_04.yml b/.github/workflows/ubuntu_18_04.yml
index 62f77884a8..4dc01de86c 100644
--- a/.github/workflows/ubuntu_18_04.yml
+++ b/.github/workflows/ubuntu_18_04.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'ubuntu'
           DIST: 'bionic'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/ubuntu_20_04.yml b/.github/workflows/ubuntu_20_04.yml
index 3b13596f2c..2667d3bc2f 100644
--- a/.github/workflows/ubuntu_20_04.yml
+++ b/.github/workflows/ubuntu_20_04.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'ubuntu'
           DIST: 'focal'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/ubuntu_21_04.yml b/.github/workflows/ubuntu_21_04.yml
index 098409fc63..c8d7fb5f5a 100644
--- a/.github/workflows/ubuntu_21_04.yml
+++ b/.github/workflows/ubuntu_21_04.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'ubuntu'
           DIST: 'hirsute'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.github/workflows/ubuntu_21_10.yml b/.github/workflows/ubuntu_21_10.yml
index ed640789ee..921ee58e52 100644
--- a/.github/workflows/ubuntu_21_10.yml
+++ b/.github/workflows/ubuntu_21_10.yml
@@ -41,6 +41,11 @@ jobs:
 
     runs-on: ubuntu-20.04-self-hosted
 
+    strategy:
+      fail-fast: false
+      matrix:
+        gc64: [ "GC64=OFF" ]
+
     steps:
       - uses: actions/checkout@v2.3.4
         with:
@@ -52,6 +57,7 @@ jobs:
           RWS_AUTH: ${{ secrets.RWS_AUTH }}
           OS: 'ubuntu'
           DIST: 'impish'
+          GC64: -DLUAJIT_ENABLE_${{ matrix.gc64 }}
         uses: ./.github/actions/pack_and_deploy
       - name: call action to send Telegram message on failure
         env:
diff --git a/.gitlab.mk b/.gitlab.mk
index 7f9caf20b7..bfec4a9476 100644
--- a/.gitlab.mk
+++ b/.gitlab.mk
@@ -101,7 +101,6 @@ endif
 
 RWS_BASE_URL=https://rws.tarantool.org
 RWS_ENDPOINT=${RWS_BASE_URL}/${REPO_TYPE}/${TARANTOOL_SERIES}/${OS}/${DIST}
-PRODUCT_NAME=tarantool
 
 deploy_prepare:
 	rm -rf packpack
@@ -110,6 +109,15 @@ deploy_prepare:
 	rm -rf build
 
 package: deploy_prepare
+	# Set PRODUCT_NAME for the package itself.
+	if [ "$$(echo $(GC64) | sed 's/.*=//')" = ON ]; then                                                           \
+		export PRODUCT_NAME=tarantool-gc64; \
+		if [ "${OS}" = "ubuntu" ] || [ "${OS}" = "debian" ]; then \
+		    $$(sed -i'' -e 's/Package: tarantool$$/Package: tarantool-gc64/' debian/control); \
+		fi; \
+	else \
+		export PRODUCT_NAME=tarantool; \
+	fi; \
 	if [ -n "$(GIT_TAG)" ]; then                                                                                    \
 		export VERSION="$$(echo $(GIT_TAG) | sed 's/-/~/')";                                                    \
 	else                                                                                                            \
@@ -118,13 +126,19 @@ package: deploy_prepare
 	echo VERSION=$$VERSION;                                                                                         \
 	PACKPACK_EXTRA_DOCKER_RUN_PARAMS="--network=host ${PACKPACK_EXTRA_DOCKER_RUN_PARAMS}"                           \
 	TARBALL_EXTRA_ARGS="--exclude=*.exe --exclude=*.dll"                                                            \
-	PRESERVE_ENVVARS="TARBALL_EXTRA_ARGS,${PRESERVE_ENVVARS}" ./packpack/packpack
+	PRESERVE_ENVVARS="PRODUCT_NAME,TARBALL_EXTRA_ARGS,${PRESERVE_ENVVARS}" ./packpack/packpack
 
 deploy:
 	if [ -z "${REPO_TYPE}" ]; then \
 		echo "Env variable 'REPO_TYPE' must be defined!"; \
 		exit 1; \
 	fi; \
+	# Set PRODUCT_NAME for the package in the repository.
+	if [ "$$(echo $(GC64) | sed 's/.*=//')" = ON ]; then                                                                                    \
+		PRODUCT_NAME=tarantool-gc64; \
+	else \
+		PRODUCT_NAME=tarantool; \
+	fi; \
 	CURL_CMD="curl \
 		--location \
 		--fail \
@@ -134,7 +148,7 @@ deploy:
 		--retry-delay 5 \
 		--request PUT ${RWS_ENDPOINT} \
 		--user $${RWS_AUTH} \
-		--form product=${PRODUCT_NAME}"; \
+		--form product=$${PRODUCT_NAME}"; \
 	for f in $$(ls -I '*build*' -I '*.changes' ./build); do \
 		CURL_CMD="$${CURL_CMD} --form $$(basename $${f})=@./build/$${f}"; \
 	done; \
diff --git a/debian/rules b/debian/rules
index 00b0ae9e45..7e9f73d11b 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,6 +19,12 @@ DEB_CMAKE_EXTRA_FLAGS := \
 	-DWITH_SYSVINIT=ON \
 	-DWITH_SYSTEMD=$(WITH_SYSTEMD)
 
+# Append CMAKE flag with -DLUAJIT_ENABLE_GC64 value. It is required
+# for CI to build Tarantool with GC64 enabled or disabled dynamically.
+ifneq ($(GC64),)
+	DEB_CMAKE_EXTRA_FLAGS += $(GC64)
+endif
+
 # Install tarantool.service within tarantool-common package, but does not
 # install it within tarantool and tarantool-dev packages.
 DEB_DH_INSTALLINIT_ARGS                     := --name=tarantool
diff --git a/rpm/tarantool.spec b/rpm/tarantool.spec
index 950e5790d8..ae01332528 100644
--- a/rpm/tarantool.spec
+++ b/rpm/tarantool.spec
@@ -11,6 +11,11 @@
 # need to use cmake3 package to build Tarantool on old systems.
 %define use_cmake3 0%{?rhel} == 7
 
+# Get GC64 variable which can keep compiler flag -DLUAJIT_ENABLE_GC64
+# with a value of ON or OFF to enable or disable luajit gc64.
+# It needs to build Tarantool in CI dynamically.
+%define _gc64 %{getenv:GC64}
+
 %if %use_cmake3
 # XXX: Unfortunately there is no way to make rpmbuild install and
 # enable EPEL repository prior to the build step. However, the
@@ -105,7 +110,16 @@ BuildRequires: python3-pyyaml
 # Install prove to run LuaJIT tests.
 BuildRequires: perl-Test-Harness
 
+# Set product name from env variable or use default "tarantool".
+# It is a temporary solution to define special name of the package
+# to "tarantool-gc64" in CI. It is required to set up Tarantool
+# with GC64 enabled by "yum install tarantool-gc64"
+%define _product %{getenv:PRODUCT_NAME}
+%if "%{_product}"
+Name: %{_product}
+%else
 Name: tarantool
+%endif
 # ${major}.${major}.${minor}.${patch}, e.g. 1.6.8.175
 # Version is updated automaically using git describe --long --always
 Version: 1.7.2.385
@@ -190,6 +204,9 @@ C and Lua/C modules.
 %endif
 %if 0%{?fedora} >= 33
          -DENABLE_LTO=ON \
+%endif
+%if "%{_gc64}"
+         %{_gc64} \
 %endif
          -DENABLE_WERROR:BOOL=ON \
          -DENABLE_DIST:BOOL=ON
-- 
GitLab