From db6541a41a27a3695771ad061fb69dbe7f14a5cf Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Mon, 6 Nov 2023 16:26:22 +0000 Subject: [PATCH] bin/gitlab_gql: fix --print-merged-yaml when --rev != HEAD Reading the local root config file and then asking gitlab to evaluate it in the context of some other version will cause issues if they are not identical. Instead, the local document should be a simple include of whatever is the root config file at that commit. Part-of: --- bin/ci/gitlab_gql.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/ci/gitlab_gql.py b/bin/ci/gitlab_gql.py index 3f422d5d10a..64d44f09678 100755 --- a/bin/ci/gitlab_gql.py +++ b/bin/ci/gitlab_gql.py @@ -12,6 +12,7 @@ from itertools import accumulate from os import getenv from pathlib import Path from subprocess import check_output +from textwrap import dedent from typing import Any, Iterable, Optional, Pattern, TypedDict, Union import yaml @@ -349,9 +350,10 @@ def print_dag(dag: Dag) -> None: def fetch_merged_yaml(gl_gql: GitlabGQL, params) -> dict[str, Any]: - gitlab_yml_file = get_project_root_dir() / ".gitlab-ci.yml" - content = Path(gitlab_yml_file).read_text().strip() - params["content"] = content + params["content"] = dedent("""\ + include: + - local: .gitlab-ci.yml + """) raw_response = gl_gql.query("job_details.gql", params) if merged_yaml := raw_response["ciConfig"]["mergedYaml"]: return yaml.safe_load(merged_yaml)