From efb9f7135f7f2fbd731c8de2e41944c9ad434b2f Mon Sep 17 00:00:00 2001 From: MarcoIeni <11428655+MarcoIeni@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:28:03 +0100 Subject: [PATCH] fix python script --- src/ci/github-actions/calculate-job-matrix.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/ci/github-actions/calculate-job-matrix.py b/src/ci/github-actions/calculate-job-matrix.py index 7de6d5fcd5f75..faa6da7243c01 100755 --- a/src/ci/github-actions/calculate-job-matrix.py +++ b/src/ci/github-actions/calculate-job-matrix.py @@ -176,6 +176,21 @@ def format_run_type(run_type: WorkflowRunType) -> str: raise AssertionError() +# Add new function before main: +def substitute_github_vars(jobs: list) -> list: + """Replace GitHub context variables with environment variables in job configs.""" + for job in jobs: + if "os" in job: + job["os"] = job["os"].replace( + "${{ github.run_id }}", + os.environ["GITHUB_RUN_ID"] + ).replace( + "${{ github.run_attempt }}", + os.environ["GITHUB_RUN_ATTEMPT"] + ) + return jobs + + if __name__ == "__main__": logging.basicConfig(level=logging.INFO) @@ -195,6 +210,7 @@ def format_run_type(run_type: WorkflowRunType) -> str: jobs = calculate_jobs(run_type, data) jobs = skip_jobs(jobs, channel) + if not jobs: raise Exception("Scheduled job list is empty, this is an error")