1+ import os
2+
13from configuration .builders .infra .runtime import (
24 BuildSequence ,
35 DockerConfig ,
46 InContainer ,
57)
8+ from configuration .steps .commands .base import URL , BashCommand
69from configuration .steps .commands .download import GitInitFromCommit
7- from configuration .steps .commands .foundry import BuildPlugin
10+ from configuration .steps .commands .foundry import (
11+ BuildPlugin ,
12+ InstallBuiltPackages ,
13+ RunPluginMTRSuite ,
14+ )
815from configuration .steps .commands .packages import (
916 InstallDEBPackages ,
1017 InstallRPMPackages ,
18+ SavePackages ,
1119 SetupDEBRepoFromURL ,
1220 SetupRPMRepoFromURL ,
1321)
14- from configuration .steps .remote import ShellStep
22+ from configuration .steps .remote import PropFromShellStep , ShellStep
1523
1624_MARIADB_VERSION_ENV = [("MARIADB_VERSION" , "%(prop:mariadb_version)s" )]
1725
@@ -30,9 +38,49 @@ def _clone_foundry_step(config: DockerConfig):
3038 )
3139
3240
41+ def _capture_foundry_revision_step (config : DockerConfig ):
42+ # foundry_force_scheduler never gives us a concrete revision (see
43+ # _clone_foundry_step), so read back the commit that actually got
44+ # checked out -- needed to tell apart saved packages built from
45+ # different foundry/plugin source revisions.
46+ return InContainer (
47+ PropFromShellStep (
48+ command = BashCommand (cmd = "git rev-parse --short HEAD" ),
49+ property = "foundry_revision" ,
50+ ),
51+ docker_environment = config ,
52+ )
53+
54+
55+ def _save_packages_step (config : DockerConfig , package_glob : str ):
56+ # The same builder gets triggered once per mariadb_version (and, on a
57+ # different run, for a different plugin, or a different foundry commit)
58+ # -- all three need to be in the destination path, or a later run
59+ # silently overwrites an earlier one's saved packages.
60+ # mariadb_version-tarbuildnum is kept as a single segment so it reads
61+ # unambiguously as "the tarbuildnum for this mariadb_version", not some
62+ # unrelated build number.
63+ destination = (
64+ "/packages/foundry/%(prop:mariadb_version)s-%(prop:tarbuildnum)s/%(prop:plugin)s"
65+ "/%(prop:foundry_revision)s/%(prop:buildername)s"
66+ )
67+ url = (
68+ f"{ os .environ ['ARTIFACTS_URL' ]} /foundry/%(prop:mariadb_version)s-%(prop:tarbuildnum)s"
69+ "/%(prop:plugin)s/%(prop:foundry_revision)s/%(prop:buildername)s"
70+ )
71+ return InContainer (
72+ ShellStep (
73+ command = SavePackages (packages = [package_glob ], destination = destination ),
74+ url = URL (url = url , url_text = "Packages" ),
75+ ),
76+ docker_environment = config ,
77+ )
78+
79+
3380def deb (config : DockerConfig , repo_file_url : str ):
3481 sequence = BuildSequence ()
3582 sequence .add_step (_clone_foundry_step (config ))
83+ sequence .add_step (_capture_foundry_revision_step (config ))
3684 sequence .add_step (
3785 InContainer (
3886 ShellStep (command = SetupDEBRepoFromURL (repo_file_url )),
@@ -53,12 +101,36 @@ def deb(config: DockerConfig, repo_file_url: str):
53101 docker_environment = config ,
54102 )
55103 )
104+ sequence .add_step (
105+ InContainer (
106+ ShellStep (command = InstallBuiltPackages ("DEB" )),
107+ docker_environment = config ,
108+ container_commit = True ,
109+ )
110+ )
111+ sequence .add_step (_save_packages_step (config , "*.deb" ))
112+ sequence .add_step (
113+ InContainer (
114+ ShellStep (
115+ command = InstallDEBPackages (packages = ["mariadb-server" , "mariadb-test" ])
116+ ),
117+ docker_environment = config ,
118+ container_commit = True ,
119+ )
120+ )
121+ sequence .add_step (
122+ InContainer (
123+ ShellStep (command = RunPluginMTRSuite ("/usr/share/mysql/mysql-test" )),
124+ docker_environment = config ,
125+ )
126+ )
56127 return sequence
57128
58129
59130def rpm (config : DockerConfig , repo_file_url : str ):
60131 sequence = BuildSequence ()
61132 sequence .add_step (_clone_foundry_step (config ))
133+ sequence .add_step (_capture_foundry_revision_step (config ))
62134 sequence .add_step (
63135 InContainer (
64136 ShellStep (command = SetupRPMRepoFromURL (repo_file_url )),
@@ -79,4 +151,27 @@ def rpm(config: DockerConfig, repo_file_url: str):
79151 docker_environment = config ,
80152 )
81153 )
154+ sequence .add_step (
155+ InContainer (
156+ ShellStep (command = InstallBuiltPackages ("RPM" )),
157+ docker_environment = config ,
158+ container_commit = True ,
159+ )
160+ )
161+ sequence .add_step (_save_packages_step (config , "*.rpm" ))
162+ sequence .add_step (
163+ InContainer (
164+ ShellStep (
165+ command = InstallRPMPackages (packages = ["MariaDB-server" , "MariaDB-test" ])
166+ ),
167+ docker_environment = config ,
168+ container_commit = True ,
169+ )
170+ )
171+ sequence .add_step (
172+ InContainer (
173+ ShellStep (command = RunPluginMTRSuite ("/usr/share/mysql-test" )),
174+ docker_environment = config ,
175+ )
176+ )
82177 return sequence
0 commit comments