From e1557f080b106a9e551d6f2c61adc230ada251c0 Mon Sep 17 00:00:00 2001 From: Kenneth Moreland Date: Wed, 21 Feb 2024 16:43:59 -0500 Subject: [PATCH] Fix issue with nested script strings in CI reproduce script The `reproduce_ci_env.py` script reads in the yaml for the GitLab runners and replicates the runs using Docker. Through a quirk of the implemenation of MR !3191, some of the scripts, which are expected to be a list of command strings, get defined as a list of lists. This is fixed by flattening this list of commands. --- Utilities/CI/reproduce_ci_env.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Utilities/CI/reproduce_ci_env.py b/Utilities/CI/reproduce_ci_env.py index 0abdc581e..a96c2d54a 100755 --- a/Utilities/CI/reproduce_ci_env.py +++ b/Utilities/CI/reproduce_ci_env.py @@ -196,13 +196,22 @@ def create_container(ci_file_path, *args): if os.getenv('https_proxy'): gitlab_env = [ 'https_proxy=' + os.getenv('https_proxy') ] + gitlab_env + def clean_script(script): + if isinstance(script, list): + from itertools import chain + return list(chain(*[clean_script(command) for command in script])) + elif isinstance(script, str): + return [script.strip()] + else: + raise(TypeError('Encountered bad type in script: `{}`'.format(type(script).__name__))) + # The script and before_script could be anywhere! script_search_locations = [ci_state, subset, runner] for loc in script_search_locations: if 'before_script' in loc: - before_script = [command.strip() for command in loc['before_script']] + before_script = clean_script(loc['before_script']) if 'script' in loc: - script = [command.strip() for command in loc['script']] + script = clean_script(loc['script']) docker_template = string.Template(''' FROM $image