This method wasn't even utilized before this patch. This patch adds all the necessary logic to successfully execute a container workload via lcitool (which will later allow us to ditch ci/Makefile). Because container executions via lcitool creates the following inside the container: $ ls script datadir where 'datadir' is the workload directory (in this case a local git repo clone) and 'script' is the code that runs whatever the workload is over 'datadir'. In order to satisfy the ^above, our helper generates a trivial temporary 'script' that will source ci/build.sh and run whatever was specified as --job essentially to simulate the exact steps a GitLab pipeline job would go through. Signed-off-by: Erik Skultety <eskultet@xxxxxxxxxx> --- ci/helper | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/ci/helper b/ci/helper index d704d1f711..887e64ece1 100755 --- a/ci/helper +++ b/ci/helper @@ -11,6 +11,9 @@ import subprocess import sys import textwrap +from pathlib import Path +from tempfile import TemporaryDirectory + import util @@ -216,8 +219,51 @@ class Application: return repo.clone(dest, local=True) def _lcitool_run(self, args): - output = subprocess.check_output([self._args.lcitool] + args) - return output.decode("utf-8") + positional_args = ["container"] + opts = ["--user", self._args.login] + tmpdir = TemporaryDirectory(prefix="scratch", + dir=Path(self.repo.working_dir, "ci")) + + repo_dest_path = Path(tmpdir.name, "libvirt.git").as_posix() + repo_clone = self._prepare_repo_copy(self.repo, repo_dest_path) + opts.extend(["--workload-dir", repo_clone.working_dir]) + + if self._args.job == "shell": + positional_args.append("shell") + else: + job2func = { + "test": "run_test", + "build": "run_build", + "codestyle": "run_codestyle", + "potfile": "run_potfile", + "rpmbuild": "run_rpmbuild", + "website": "run_website_build", + } + + if self._args.engine != "auto": + positional_args.extend(["--engine", self._args.engine]) + + with open(Path(tmpdir.name, "script"), "w") as f: + script_path = f.name + contents = textwrap.dedent(f"""\ + #!/bin/sh + + cd datadir + . ci/build.sh + + {job2func[self._args.job]} + """) + + f.write(contents) + + positional_args.append("run") + opts.extend(["--script", script_path]) + + opts.append(f"{self._args.image_prefix}{self._args.target}:{self._args.image_tag}") + subprocess.run([self._args.lcitool] + positional_args + opts) + + # this will take care of the generated script file above as well + tmpdir.cleanup() def _check_stale_images(self): namespace = self._args.namespace -- 2.41.0