Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test/imgtestlib/get_osbuild_commit(): consider only gitlab-ci-runner distro (HMS-5243) #1124

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions test/scripts/build-image
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@ def main():

osbuild_ver, _ = testlib.runcmd(["osbuild", "--version"])

osrelease = testlib.read_osrelease()
distro_version = osrelease["ID"] + "-" + osrelease["VERSION_ID"]
osbuild_commit = testlib.get_osbuild_commit(distro_version)
osbuild_commit = testlib.get_osbuild_commit()
if osbuild_commit is None:
osbuild_commit = "RELEASE"

Expand Down
35 changes: 9 additions & 26 deletions test/scripts/imgtestlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,37 +371,20 @@ def clargs():
return parser


def read_osrelease():
"""Read Operating System Information from `os-release`

This creates a dictionary with information describing the running operating system. It reads the information from
the path array provided as `paths`. The first available file takes precedence. It must be formatted according to
the rules in `os-release(5)`.
"""
osrelease = {}

with open(OS_RELEASE_FILE, encoding="utf8") as orf:
for line in orf:
line = line.strip()
if not line:
continue
if line[0] == "#":
continue
key, value = line.split("=", 1)
osrelease[key] = value.strip('"')

return osrelease


def get_osbuild_commit(distro_version):
def get_osbuild_commit():
"""
Get the osbuild commit defined in the Schutzfile for the host distro.
If not set, returns None.
Get the osbuild commit defined in the Schutzfile for the 'gitlab-ci-runner'
distro.
If not set, raises a KeyError.
"""
with open(SCHUTZFILE, encoding="utf-8") as schutzfile:
data = json.load(schutzfile)

return data.get(distro_version, {}).get("dependencies", {}).get("osbuild", {}).get("commit", None)
gitlab_ci_runner_distro = get_common_ci_runner().split("/")[1]

if (commit := data.get(gitlab_ci_runner_distro, {}).get("dependencies", {}).get("osbuild", {}).get("commit", None)) is None:
raise KeyError(f"osbuild dependency commit not defined for {gitlab_ci_runner_distro} in {SCHUTZFILE}")
return commit


def get_bib_ref():
Expand Down
Loading