Skip to content
Draft
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
52 changes: 52 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ stages:
- build
- ostree-gen
- ostree-build
- bootc-gen
- bootc-build
- verify
- finish

Expand Down Expand Up @@ -2030,6 +2032,56 @@ fail:
needs:
- "generate-ostree-build-config: [rhel-9.9, x86_64]"

"generate-bootc-config: [centos-10, aarch64]":
stage: bootc-gen
extends: .terraform
variables:
RUNNER: aws/fedora-44-aarch64
INTERNAL_NETWORK: "false"
script:
- sudo -E ./test/scripts/setup-osbuild-repo
- sudo ./test/scripts/install-dependencies
- ./test/scripts/generate-bootc-config --bootc-source centos-10 --arch aarch64 boot-config.yml
artifacts:
paths:
- boot-config.yml


"generate-bootc-config: [centos-10, x86_64]":
stage: bootc-gen
extends: .terraform
variables:
RUNNER: aws/fedora-44-x86_64
INTERNAL_NETWORK: "false"
script:
- sudo -E ./test/scripts/setup-osbuild-repo
- sudo ./test/scripts/install-dependencies
- ./test/scripts/generate-bootc-config --bootc-source centos-10 --arch x86_64 boot-config.yml
artifacts:
paths:
- boot-config.yml

"bootc-build-trigger: [centos-10, aarch64]":
stage: bootc-build
trigger:
include:
- artifact: boot-config.yml
job: "generate-bootc-config: [centos-10, aarch64]"
strategy: depend
needs:
- "generate-bootc-config: [centos-10, aarch64]"


"bootc-build-trigger: [centos-10, x86_64]":
stage: bootc-build
trigger:
include:
- artifact: boot-config.yml
job: "generate-bootc-config: [centos-10, x86_64]"
strategy: depend
needs:
- "generate-bootc-config: [centos-10, x86_64]"

"generate-manifests: [centos-10, ppc64le]":
stage: gen
extends: .terraform
Expand Down
9 changes: 8 additions & 1 deletion cmd/gen-manifests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,12 @@ func main() {

fmt.Fprintln(os.Stderr, "Collecting jobs")

distros, invalidDistros := distros.ResolveArgValues(testedRepoRegistry.ListDistros())
// With --bootc-refs and no --distros, skip loop to get repositories
repoDistros := testedRepoRegistry.ListDistros()
if len(distros) == 0 && len(bootcRefs) > 0 {
repoDistros = nil
}
distros, invalidDistros := distros.ResolveArgValues(repoDistros)
if len(invalidDistros) > 0 {
fmt.Fprintf(os.Stderr, "WARNING: invalid distro names: [%s]\n", strings.Join(invalidDistros, ","))
}
Expand Down Expand Up @@ -639,11 +644,13 @@ func main() {
}
}

arches, _ := arches.ResolveArgValues(distribution.ListArches())
for _, archName := range arches {
archi, err := distribution.GetArch(archName)
if err != nil {
panic(err)
}
imgTypes, _ := imgTypes.ResolveArgValues(archi.ListImageTypes())
for _, imgTypeName := range imgTypes {
imgType, err := archi.GetImageType(imgTypeName)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion test/configs/bootc-remote-with-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"options": {
"bootc": {
"installer_payload_ref": "payload-container-fake-ref",
"installer_payload_ref": "quay.io/centos-bootc/centos-bootc:stream10",
"use_remote_container_source": true
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/configs/bootc-with-payload.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
},
"options": {
"bootc": {
"installer_payload_ref": "payload-container-fake-ref"
"installer_payload_ref": "quay.io/centos-bootc/centos-bootc:stream10"

Copy link
Copy Markdown
Contributor Author

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:)

Copy link
Copy Markdown
Member

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).

}
}
}
14 changes: 14 additions & 0 deletions test/data/bootcrefs/centos-10.json
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.

157 changes: 157 additions & 0 deletions test/scripts/generate-bootc-config
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}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basicaly the only change in the JOB_TEMPLATE compared to generate-build-config. I think we can also later test this without the podman pull. 👁️

- ./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()
Loading
Loading