-
Notifications
You must be signed in to change notification settings - Fork 97
many: gitlab: add bootc disk build + boot-test pipelines (HMS-10854) #2581
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
base: main
Are you sure you want to change the base?
Changes from all commits
0e92360
515ce47
eac9e88
fdba165
8276413
7c30ab4
59789cf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| { | ||
| "aarch64": { | ||
| "ref": "quay.io/centos-bootc/centos-bootc:stream10" | ||
| }, | ||
| "ppc64le": { | ||
| "ref": "quay.io/centos-bootc/centos-bootc:stream10" | ||
| }, | ||
| "s390x": { | ||
| "ref": "quay.io/centos-bootc/centos-bootc:stream10" | ||
| }, | ||
| "x86_64": { | ||
| "ref": "quay.io/centos-bootc/centos-bootc:stream10" | ||
| } | ||
| } |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,157 @@ | ||
| #!/usr/bin/env python3 | ||
| # | ||
| # Generates gitlab child pipelines for building bootc images. | ||
| # Each pipeline should build a single image configuration test. | ||
| import os | ||
| from tempfile import TemporaryDirectory | ||
|
|
||
| import imgtestlib as testlib | ||
|
|
||
| BOOTC_CONFIGS = {"bootc-empty", "bootc-with-payload"} | ||
|
|
||
| BOOTC_IMAGE_TYPES = [ | ||
| "qcow2", | ||
| "ami", | ||
| "raw", | ||
| "gce", | ||
| "vhd", | ||
| "vmdk", | ||
| "ova", | ||
| "anaconda-iso", | ||
| "bootc-generic-iso", | ||
| "bootc-installer", | ||
| "pxe-tar-xz", | ||
| ] | ||
|
|
||
| # TODO: Fix these and remove the skips; they break gen-manifests today: | ||
| # * anaconda-iso — depsolve fails: InvalidRequest: No 'repos' or 'root_dir' | ||
| # * pxe-tar-xz — initramfs requires ostree, dmsquash-live and livenet modules | ||
| BOOTC_SKIP_IMAGE_TYPES = { | ||
| "anaconda-iso", | ||
| "pxe-tar-xz", | ||
| } | ||
|
|
||
| JOB_TEMPLATE = """ | ||
| build/{distro}/{arch}/{image_type}/{config_name}: | ||
| stage: test | ||
| script: | ||
| - sudo -E ./test/scripts/setup-osbuild-repo | ||
| - sudo ./test/scripts/install-dependencies | ||
| - podman pull {bootc_ref} | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is basicaly the only change in the JOB_TEMPLATE compared to |
||
| - ./test/scripts/build-image "{distro}" "{image_type}" "{config}" | ||
| - ./test/scripts/boot-image "{image_path}" "{config}" | ||
| - sudo -E ./test/scripts/upload-results "{distro}" "{image_type}" "{config}" | ||
| extends: .terraform | ||
| tags: | ||
| - {tag} | ||
| variables: | ||
| RUNNER: {runner}-{arch} | ||
| INTERNAL_NETWORK: "{internal}" | ||
| """ | ||
|
|
||
|
|
||
| def should_skip(config_name, image_type): | ||
| return image_type in BOOTC_SKIP_IMAGE_TYPES or config_name not in BOOTC_CONFIGS | ||
|
|
||
|
|
||
| @testlib.gitlab.log_section("Generating manifests") | ||
| def generate_manifests(outputdir, arch, bootc_source, bootc_installer_ref=None): | ||
| """ | ||
| Generate bootc manifests using the default config list and return a | ||
| dictionary mapping each manifest file to the manifest data and its ID. | ||
| """ | ||
| bootc_entry = testlib.bootcsource.resolve_bootc_source(bootc_source, arch) | ||
| bootc_ref = bootc_entry["ref"] | ||
| bootc_refspec = bootc_ref | ||
| if build_ref := bootc_entry.get("build_ref"): | ||
| bootc_refspec = f"{bootc_ref}#{build_ref}" | ||
|
|
||
| # TODO: fix broken image types | ||
| # don't ask gen-manifests for them in the meantime | ||
| images = [t for t in BOOTC_IMAGE_TYPES if t not in BOOTC_SKIP_IMAGE_TYPES] | ||
|
|
||
| print(f"🗒️ Generating bootc manifests using the default config list for {bootc_source} [{arch}]") | ||
| # Omit --distros: with --bootc-refs, gen-manifests skips the RPM/repo loop. | ||
| err = testlib.core.gen_manifests(outputdir, arches=[arch], | ||
| images=images, | ||
| bootc_refs=[bootc_refspec], | ||
| bootc_installer_ref=bootc_installer_ref, | ||
| skip_no_config=True) | ||
|
|
||
| # print stderr in case there were errors or warnings about skipped configurations | ||
| # but filter out the annoying ones | ||
| stderr = err.decode().splitlines() | ||
| for line in stderr: | ||
| if "No match for group package" in line: | ||
| continue | ||
| if "Failed to load consumer certs" in line: | ||
| continue | ||
| print(line) | ||
|
|
||
| print("✅ Manifest generation done!\n") | ||
| return testlib.core.read_manifests(outputdir) | ||
|
|
||
|
|
||
| def generate_configs(build_requests, pipeline_file, bootc_source, bootc_ref): | ||
| print(f"🧪 Generating dynamic pipelines for {len(build_requests)} builds") | ||
| expected_distro = f"bootc-{bootc_source}" | ||
| for build in build_requests: | ||
| distro = build["distro"] | ||
| arch = build["arch"] | ||
| image_type = build["image-type"] | ||
| config = build["config"] | ||
| config_name = config["name"] | ||
|
|
||
| if distro != expected_distro: | ||
| print(f"🦘 Skipping {distro}/{arch}/{image_type}/{config_name}: " | ||
| f"expected distro {expected_distro} for bootc source {bootc_source}") | ||
| continue | ||
|
|
||
| if should_skip(config_name, image_type): | ||
| print(f"🦘 Skipping {distro}/{arch}/{image_type}/{config_name}") | ||
| continue | ||
|
|
||
| build_name = testlib.build.gen_build_name(distro, arch, image_type, config_name) | ||
| image_path = f"./build/{build_name}" | ||
|
|
||
| runner = testlib.testenv.get_ci_runner_for(distro, arch, image_type) | ||
| tag = testlib.core.get_tag_for(runner) | ||
|
|
||
| config_path = os.path.join(testlib.core.CONFIGS_PATH, config_name + ".json") | ||
| pipeline_file.write(JOB_TEMPLATE.format(distro=distro, arch=arch, image_type=image_type, | ||
| runner=runner, tag=tag, | ||
| config_name=config_name, config=config_path, | ||
| internal="true" if "rhel" in distro else "false", | ||
| image_path=image_path, bootc_ref=bootc_ref)) | ||
| print("✅ DONE!") | ||
|
|
||
|
|
||
| def main(): | ||
| parser = testlib.core.bootc_clargs() | ||
| args = parser.parse_args() | ||
|
|
||
| arch = args.arch | ||
| bootc_source = args.bootc_source | ||
| bootc_installer_ref = args.bootc_installer_ref | ||
|
|
||
| testlib.core.check_config_names() | ||
|
|
||
| bootc_ref = testlib.bootcsource.resolve_bootc_source(bootc_source, arch)["ref"] | ||
|
|
||
| with TemporaryDirectory() as manifest_dir: | ||
| manifests = generate_manifests(manifest_dir, arch, bootc_source, | ||
| bootc_installer_ref=bootc_installer_ref) | ||
| build_requests = testlib.core.filter_builds(manifests, arch=arch) | ||
|
|
||
| with open(args.config, "w", encoding="utf-8") as config_file: | ||
| if len(build_requests) == 0: | ||
| print("⚫ No manifest changes detected. Generating null config.") | ||
| config_file.write(testlib.core.NULL_CONFIG) | ||
| return | ||
|
|
||
| config_file.write(testlib.core.BASE_CONFIG) | ||
| generate_configs(build_requests, config_file, bootc_source, bootc_ref) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change produced changes in manifest-checksums btw:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. We generate fake content IDs based on the inputs (package names, container refs, ostree commit URLs).