ci: Add an interactive mode (testTTY) for the CI image builder
This commit is contained in:
parent
eef880f509
commit
f6b346f2e2
|
@ -1,2 +1,3 @@
|
|||
/build_*
|
||||
/test_*
|
||||
/user.sh
|
||||
|
|
|
@ -26,7 +26,7 @@ PACMAN_OPTS='--needed --noprogressbar --noconfirm'
|
|||
# Patch config files
|
||||
sed -i 's/#Color/Color/g' /etc/pacman.conf
|
||||
sed -i 's,#MAKEFLAGS="-j2",MAKEFLAGS="-j$(nproc)",g' /etc/makepkg.conf
|
||||
sed -i "s,PKGEXT='.pkg.tar.xz',PKGEXT='.pkg.tar',g" /etc/makepkg.conf
|
||||
sed -i "s,PKGEXT='.pkg.tar.zst',PKGEXT='.pkg.tar',g" /etc/makepkg.conf
|
||||
|
||||
# Install packages
|
||||
pacman -Syu $PACMAN_OPTS "${pkgs[@]}"
|
||||
|
|
|
@ -140,12 +140,13 @@ class ImageTester(BuilderBase):
|
|||
ignore=shutil.ignore_patterns(
|
||||
'.git',
|
||||
'*_cache',
|
||||
'work area',
|
||||
'__pycache__',
|
||||
# 'work area',
|
||||
self.temp_dir.name,
|
||||
)
|
||||
)
|
||||
|
||||
def do_test(self):
|
||||
def do_test(self, tty: bool = False) -> None:
|
||||
self.copy_meson()
|
||||
self.gen_dockerfile()
|
||||
|
||||
|
@ -158,11 +159,26 @@ class ImageTester(BuilderBase):
|
|||
if subprocess.run(build_cmd).returncode != 0:
|
||||
raise RuntimeError('Failed to build the test docker image')
|
||||
|
||||
test_cmd = [
|
||||
self.docker, 'run', '--rm', '-t', 'meson_test_image',
|
||||
'/bin/bash', '-c', 'source /ci/env_vars.sh; cd meson; ./run_tests.py $CI_ARGS'
|
||||
]
|
||||
if subprocess.run(test_cmd).returncode != 0:
|
||||
test_cmd = []
|
||||
if tty:
|
||||
test_cmd = [
|
||||
self.docker, 'run', '--rm', '-t', '-i', 'meson_test_image',
|
||||
'/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;'
|
||||
]
|
||||
else:
|
||||
test_cmd = [
|
||||
self.docker, 'run', '--rm', '-t', 'meson_test_image',
|
||||
'/bin/bash', '-c', 'source /ci/env_vars.sh; cd meson; ./run_tests.py $CI_ARGS'
|
||||
]
|
||||
|
||||
if subprocess.run(test_cmd).returncode != 0 and not tty:
|
||||
raise RuntimeError('Running tests failed')
|
||||
finally:
|
||||
cleanup_cmd = [self.docker, 'rmi', '-f', 'meson_test_image']
|
||||
|
@ -171,7 +187,7 @@ class ImageTester(BuilderBase):
|
|||
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'], help='What to do', required=True)
|
||||
parser.add_argument('-t', '--type', choices=['build', 'test', 'testTTY'], help='What to do', required=True)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -188,6 +204,9 @@ def main() -> None:
|
|||
elif args.type == 'test':
|
||||
tester = ImageTester(ci_data, ci_build, ci_root)
|
||||
tester.do_test()
|
||||
elif args.type == 'testTTY':
|
||||
tester = ImageTester(ci_data, ci_build, ci_root)
|
||||
tester.do_test(tty=True)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Reference in New Issue