diff options
author | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-09-04 16:42:41 +0200 |
---|---|---|
committer | Daniel Mensinger <daniel@mensinger-ka.de> | 2021-10-06 16:43:59 +0200 |
commit | ecaa1d19eddcd39d6b62b20cf21cfba9bff5e801 (patch) | |
tree | 62f10b8a6f3a4c49d46a8e9f2d21e147af5efd86 | |
parent | 9d3e9c43ccfbe89e2ac62ec9c2d3f1487d8a9c54 (diff) | |
download | meson-ecaa1d19eddcd39d6b62b20cf21cfba9bff5e801.zip meson-ecaa1d19eddcd39d6b62b20cf21cfba9bff5e801.tar.gz meson-ecaa1d19eddcd39d6b62b20cf21cfba9bff5e801.tar.bz2 |
ci: Add TTY mode to the image builder mounting meson
-rwxr-xr-x | ci/ciimage/build.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/ci/ciimage/build.py b/ci/ciimage/build.py index 2cf0736..1e1f238 100755 --- a/ci/ciimage/build.py +++ b/ci/ciimage/build.py @@ -184,10 +184,36 @@ class ImageTester(BuilderBase): cleanup_cmd = [self.docker, 'rmi', '-f', 'meson_test_image'] subprocess.run(cleanup_cmd).returncode +class ImageTTY(BuilderBase): + def __init__(self, data_dir: Path, temp_dir: Path, ci_root: Path) -> None: + super().__init__(data_dir, temp_dir) + self.meson_root = ci_root.parent.parent.resolve() + + def do_run(self) -> None: + try: + tty_cmd = [ + self.docker, 'run', + '--name', 'meson_test_container', '-t', '-i', '-v', f'{self.meson_root.as_posix()}:/meson', + f'{image_namespace}/{self.data_dir.name}', + '/bin/bash', '-c', '' + + 'cd meson;' + + 'source /ci/env_vars.sh;' + + f'echo -e "\\n\\nInteractive test shell in the {image_namespace}/{self.data_dir.name} container with the current meson tree";' + + 'echo -e "The file ci/ciimage/user.sh will be sourced if it exists to enable user specific configurations";' + + 'echo -e "Run the following command to run all CI tests: ./run_tests.py $CI_ARGS\\n\\n";' + + '[ -f ci/ciimage/user.sh ] && exec /bin/bash --init-file ci/ciimage/user.sh;' + + 'exec /bin/bash;' + ] + subprocess.run(tty_cmd).returncode != 0 + finally: + cleanup_cmd = [self.docker, 'rm', '-f', 'meson_test_container'] + subprocess.run(cleanup_cmd).returncode + + def main() -> None: parser = argparse.ArgumentParser(description='Meson CI image builder') parser.add_argument('what', type=str, help='Which image to build / test') - parser.add_argument('-t', '--type', choices=['build', 'test', 'testTTY'], help='What to do', required=True) + parser.add_argument('-t', '--type', choices=['build', 'test', 'testTTY', 'TTY'], help='What to do', required=True) args = parser.parse_args() @@ -207,6 +233,9 @@ def main() -> None: elif args.type == 'testTTY': tester = ImageTester(ci_data, ci_build, ci_root) tester.do_test(tty=True) + elif args.type == 'TTY': + tester = ImageTTY(ci_data, ci_build, ci_root) + tester.do_run() if __name__ == '__main__': main() |