From aa68ffeabd5d3fed14671dd0bfbabcb98843ea7c Mon Sep 17 00:00:00 2001 From: Michal Nowak Date: Wed, 5 Feb 2025 09:59:58 +0100 Subject: [PATCH] Do not evaluate $CI_PROJECT_DIR in generate-stress-test-configs.py GitLab CI Runner's $builds_dir variable is set to "/builds" by default. For technical reasons, the FreeBSD Runners, using the "instance" executor, sets the path differently. The value of $CI_PROJECT_DIR is based on $builds_dir, so if the generate-stress-test-configs.py script generates jobs with $CI_PROJECT_DIR (or variables like $INSTALL_PATH that are based on it) evaluated, it is calcified to whatever was the value in the particular environment, disregarding the FreeBSD "instance" executor specifics in the child pipeline. Instead of evaluating $CI_PROJECT_DIR in the script, evaluate it in the runtime environment. (cherry picked from commit dab7d28b0922980f8ea87202e2eb9b66b3a612d5) --- util/generate-stress-test-configs.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/util/generate-stress-test-configs.py b/util/generate-stress-test-configs.py index 55b27c9711..a1eacc0892 100755 --- a/util/generate-stress-test-configs.py +++ b/util/generate-stress-test-configs.py @@ -22,8 +22,6 @@ with open(".gitlab-ci.yml", encoding="utf-8") as gitlab_ci_yml: # Mandatory environment variables ci_pipeline_source = os.environ["CI_PIPELINE_SOURCE"] -install_path = os.environ["INSTALL_PATH"] -project_directory = os.environ["CI_PROJECT_DIR"] # Optional environment variables all_bind_stress_tests = os.getenv("ALL_BIND_STRESS_TESTS") @@ -62,6 +60,18 @@ else: protocols = ALL_PROTOCOLS platforms = ALL_PLATFORMS +# The binaries built during each "stress" test job should be included in its +# artifacts archive. However, the value of the INSTALL_PATH variable set for +# the job running this script depends on the value of the CI_PROJECT_DIR +# variable, which varies across runners (it is based on the specific runner's +# $build_dir variable). Therefore, the value of the INSTALL_PATH variable is +# not taken from the environment here, when the child pipeline job definitions +# are generated, but rather evaluated by the runners executing the "stress" +# test jobs in the child pipeline. This is achieved by using the "raw" form of +# the variable (as found in .gitlab-ci.yml, e.g. "$CI_PROJECT_DIR/.local") +# here, so that it only gets expanded by Bash in the child pipeline. +install_path = anchors["variables"]["INSTALL_PATH"] + jobs = {} for mode, protocol, platform in itertools.product(modes, protocols, platforms): @@ -113,7 +123,7 @@ for mode, protocol, platform in itertools.product(modes, protocols, platforms): "cd bind9-qa/stress", f'export LD_LIBRARY_PATH="{install_path}/usr/local/lib"', f'export BIND_INSTALL_PATH="{install_path}/usr/local"', - f'export WORKSPACE="{project_directory}"', + 'export WORKSPACE="${CI_PROJECT_DIR}"', "bash stress.sh", ], "rules": [{"if": '$CI_PIPELINE_SOURCE == "parent_pipeline"'}],