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
4 changes: 2 additions & 2 deletions .github/workflows/check-spec.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: SPEC file check
name: RPM

on: # yamllint disable-line rule:truthy
pull_request:
Expand All @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy

jobs:
check-spec-images-deps:
name: "🔍 Check spec file osbuild/images dependencies"
name: "Check spec file osbuild/images dependencies"
runs-on: ubuntu-latest
container: registry.fedoraproject.org/fedora:latest
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/container.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build & Deploy Container
name: Container

on: # yamllint disable-line rule:truthy
push:
Expand All @@ -10,7 +10,7 @@ on: # yamllint disable-line rule:truthy

jobs:
build-base:
name: Build & push image
name: Build & Push
runs-on: ubuntu-latest
steps:
- name: Checkout code
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on: # yamllint disable-line rule:truthy

jobs:
build:
name: "Build & Test"
runs-on: ubuntu-latest
container: registry.fedoraproject.org/fedora:41
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pr_best_practices.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Verify PR best practices"
name: "Best Practices"

on: # yamllint disable-line rule:truthy
pull_request_target:
Expand All @@ -11,7 +11,7 @@ jobs:
pr-best-practices:
runs-on: ubuntu-latest
steps:
- name: PR best practice check
- name: Check
uses: osbuild/pr-best-practices@main
with:
token: ${{ secrets.SCHUTZBOT_GITHUB_ACCESS_TOKEN }}
Expand Down
50 changes: 48 additions & 2 deletions .github/workflows/pytest.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Integration tests
name: Integration

on: # yamllint disable-line rule:truthy
push:
Expand All @@ -10,6 +10,7 @@ on: # yamllint disable-line rule:truthy

jobs:
lint:
name: "Lint"
runs-on: ubuntu-latest
steps:
- name: Update apt repositories
Expand All @@ -25,7 +26,37 @@ jobs:
- name: Run linters
run: make lint

manifest:
name: "Manifest"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/testdeps
- name: Install integration test env
run: |
sudo apt update
sudo apt install -y python3-pytest golang
- name: Run integration tests via pytest
run: |
# use "-s" for now for easier debugging
sudo pytest -s -v test/test_manifest.py
build:
name: "Build"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/testdeps
- name: Install integration test env
run: |
sudo apt update
sudo apt install -y python3-pytest golang
- name: Run integration tests via pytest
run: |
# use "-s" for now for easier debugging
sudo pytest -s -v test/test_build.py

build-cross:
name: "Build (Cross-Architecture)"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
Expand All @@ -40,4 +71,19 @@ jobs:
- name: Run integration tests via pytest
run: |
# use "-s" for now for easier debugging
sudo pytest -s -v
sudo pytest -s -v test/test_build_cross.py

smoke:
name: "Smoke"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/testdeps
- name: Install integration test env
run: |
sudo apt update
sudo apt install -y python3-pytest golang
- name: Run integration tests via pytest
run: |
# use "-s" for now for easier debugging
sudo pytest -s -v test/test_smoke.py
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
[FORMAT]
max-line-length=120

[MESSAGES CONTROL]
disable=R0801
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you use 'duplicate-code' instead? I had to look up what R0801 was :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I could/should but it seems the .pylintrc is being ignored in CI anyhow so this might change/move :)

90 changes: 90 additions & 0 deletions test/test_build.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import os
import platform
import subprocess

import pytest

# put common podman run args in once place
podman_run = ["podman", "run", "--rm", "--privileged"]


@pytest.mark.parametrize("use_librepo", [False, True])
@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
def test_build_builds_image(tmp_path, build_container, use_librepo):
output_dir = tmp_path / "output"
output_dir.mkdir()
subprocess.check_call(podman_run + [
"-v", f"{output_dir}:/output",
build_container,
"build",
"minimal-raw",
"--distro", "centos-9",
f"--use-librepo={use_librepo}",
])
arch = "x86_64"
basename = f"centos-9-minimal-raw-{arch}"
assert (output_dir / basename / f"{basename}.raw.xz").exists()
# XXX: ensure no other leftover dirs
dents = os.listdir(output_dir)
assert len(dents) == 1, f"too many dentries in output dir: {dents}"


@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
def test_build_build_generates_manifest(tmp_path, build_container):
output_dir = tmp_path / "output"
output_dir.mkdir()
subprocess.check_call(podman_run + [
"-v", f"{output_dir}:/output",
build_container,
"build",
"minimal-raw",
"--distro", "centos-9",
"--with-manifest",
], stdout=subprocess.DEVNULL)
arch = platform.machine()
fn = f"centos-9-minimal-raw-{arch}/centos-9-minimal-raw-{arch}.osbuild-manifest.json"
image_manifest_path = output_dir / fn
assert image_manifest_path.exists()


@pytest.mark.parametrize("progress,needle,forbidden", [
("verbose", "osbuild-stdout-output", "[|]"),
("term", "[|]", "osbuild-stdout-output"),
])
@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
def test_build_with_progress(tmp_path, build_fake_container, progress, needle, forbidden):
output_dir = tmp_path / "output"
output_dir.mkdir()
output = subprocess.check_output(podman_run + [
"-t",
"-v", f"{output_dir}:/output",
build_fake_container,
"build",
"qcow2",
"--distro", "centos-9",
"--output-dir=.",
f"--progress={progress}",
], text=True)
assert needle in output
assert forbidden not in output


def test_build_builds_bootc(tmp_path, build_container):
bootc_ref = "quay.io/centos-bootc/centos-bootc:stream9"
subprocess.check_call(["podman", "pull", bootc_ref])

output_dir = tmp_path / "output"
output_dir.mkdir()
subprocess.check_call(podman_run + [
"-v", f"{output_dir}:/output",
build_container,
"build",
"qcow2",
"--bootc-ref", bootc_ref,
])
arch = "x86_64"
basename = f"bootc-centos-9-qcow2-{arch}"
assert (output_dir / basename / f"{basename}.qcow2").exists()
# XXX: ensure no other leftover dirs
dents = os.listdir(output_dir)
assert len(dents) == 1, f"too many dentries in output dir: {dents}"
46 changes: 46 additions & 0 deletions test/test_build_cross.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import os
import subprocess

import pytest
import yaml

# put common podman run args in once place
podman_run = ["podman", "run", "--rm", "--privileged"]


# only test a subset here to avoid overly long runtimes
@pytest.mark.parametrize("arch", ["aarch64", "ppc64le", "riscv64", "s390x"])
def test_build_cross_builds(tmp_path, build_container, arch):
# this is only here to speed up builds by sharing downloaded stuff
# when this is run locally (we could cache via GH action though)
os.makedirs("/var/cache/image-builder/store", exist_ok=True)
output_dir = tmp_path / "output"
output_dir.mkdir()
subprocess.check_call(podman_run + [
"-v", "/var/lib/containers/storage:/var/lib/containers/storage",
"-v", "/var/cache/image-builder/store:/var/cache/image-builder/store",
"-v", f"{output_dir}:/output",
build_container,
"build",
"--progress=verbose",
"--output-dir=/output",
"container",
"--distro", "fedora-41",
# selecting a foreign arch here automatically triggers a cross-build
f"--arch={arch}",
], text=True)
assert os.path.exists(output_dir / f"fedora-41-container-{arch}.tar")


@pytest.mark.skipif(os.getuid() != 0, reason="needs root")
def test_container_version_smoke(build_container):
output = subprocess.check_output(podman_run + [
build_container,
"--version",
])

ver_yaml = yaml.load(output, yaml.loader.SafeLoader)

assert ver_yaml["image-builder"]["version"] != ""
assert ver_yaml["image-builder"]["commit"] != ""
assert ver_yaml["image-builder"]["dependencies"]["images"] != ""
Loading
Loading