44from praktika .settings import Settings
55from praktika .utils import MetaClasses , Shell , Utils
66
7+ from ci .jobs .scripts .clickhouse_version import CHVersion
8+
79
810class JobStages (metaclass = MetaClasses .WithIter ):
911 CHECKOUT_SUBMODULES = "checkout"
1012 CMAKE = "cmake"
13+ UNSHALLOW = "unshallow"
1114 BUILD = "build"
15+ PACKAGE = "package"
1216
1317
1418def parse_args ():
@@ -33,8 +37,7 @@ def parse_args():
3337 -DCMAKE_INSTALL_SYSCONFDIR=/etc -DCMAKE_INSTALL_LOCALSTATEDIR=/var -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \
3438 {AUX_DEFS} \
3539 -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 \
36- -DCOMPILER_CACHE={CACHE_TYPE} \
37- -DENABLE_BUILD_PROFILING=1 {DIR}"""
40+ -DCOMPILER_CACHE={CACHE_TYPE} -DENABLE_BUILD_PROFILING=1 {DIR}"""
3841
3942
4043def main ():
@@ -91,6 +94,27 @@ def main():
9194
9295 res = True
9396 results = []
97+ version = ""
98+
99+ if res and JobStages .UNSHALLOW in stages :
100+ results .append (
101+ Result .create_from_command_execution (
102+ name = "Repo Unshallow" ,
103+ command = "git rev-parse --is-shallow-repository | grep -q true && git fetch --depth 10000 --no-tags --filter=tree:0 origin $(git rev-parse --abbrev-ref HEAD)" ,
104+ with_log = True ,
105+ )
106+ )
107+ res = results [- 1 ].is_ok ()
108+ if res :
109+ try :
110+ version = CHVersion .get_version ()
111+ assert version
112+ print (f"Got version from repo [{ version } ]" )
113+ except Exception as e :
114+ results [- 1 ].set_failed ().set_info (
115+ f"Failed to get version from repo, ex [{ e } ]"
116+ )
117+ res = False
94118
95119 if res and JobStages .CHECKOUT_SUBMODULES in stages :
96120 Shell .check (f"rm -rf { build_dir } && mkdir -p { build_dir } " )
@@ -127,6 +151,38 @@ def main():
127151 Shell .check (f"ls -l { build_dir } /programs/" )
128152 res = results [- 1 ].is_ok ()
129153
154+ if res and JobStages .PACKAGE in stages :
155+ if "debug" in build_type :
156+ package_type = "debug"
157+ elif "release" in build_type :
158+ package_type = "release"
159+ elif "asan" in build_type :
160+ package_type = "asan"
161+ else :
162+ assert False , "TODO"
163+
164+ if "amd" in build_type :
165+ deb_arch = "amd64"
166+ else :
167+ deb_arch = "arm64"
168+
169+ output_dir = "/tmp/praktika/output/"
170+ assert Shell .check (f"rm -f { output_dir } /*.deb" )
171+
172+ results .append (
173+ Result .create_from_command_execution (
174+ name = "Build Packages" ,
175+ command = [
176+ f"DESTDIR={ build_dir } /root ninja programs/install" ,
177+ f"ln -sf { build_dir } /root { Utils .cwd ()} /packages/root" ,
178+ f"cd { Utils .cwd ()} /packages/ && OUTPUT_DIR={ output_dir } BUILD_TYPE={ package_type } VERSION_STRING={ version } DEB_ARCH={ deb_arch } ./build --deb" ,
179+ ],
180+ workdir = build_dir ,
181+ with_log = True ,
182+ )
183+ )
184+ res = results [- 1 ].is_ok ()
185+
130186 Result .create_from (results = results , stopwatch = stop_watch ).complete_job ()
131187
132188
0 commit comments