diff --git a/.github/workflows/pytest.yaml b/.github/workflows/pytest.yaml index 091afc9..98a7174 100644 --- a/.github/workflows/pytest.yaml +++ b/.github/workflows/pytest.yaml @@ -34,6 +34,8 @@ jobs: run: | sudo apt update sudo apt install -y python3-pytest golang + - name: Install cross build dependencies + run: sudo apt install -y qemu-user-static - name: Run integration tests via pytest run: | diff --git a/Containerfile b/Containerfile index f54639f..65362f2 100644 --- a/Containerfile +++ b/Containerfile @@ -13,6 +13,8 @@ RUN CGO_ENABLED=0 go build -tags "containers_image_openpgp exclude_graphdriver_b FROM registry.fedoraproject.org/fedora:41 +# podman mount needs this +RUN mkdir -p /etc/containers/networks # Fast-track osbuild so we don't depend on the "slow" Fedora release process to implement new features in bib RUN dnf install -y dnf-plugins-core \ && dnf copr enable -y @osbuild/osbuild \ diff --git a/test/test_container.py b/test/test_container.py index 2c09c80..8e80255 100644 --- a/test/test_container.py +++ b/test/test_container.py @@ -96,3 +96,29 @@ def test_container_with_progress(tmp_path, build_fake_container, progress, needl ], text=True) assert needle in output assert forbidden not in output + + +# only test a subset here to avoid overly long runtimes +@pytest.mark.parametrize("arch", ["aarch64", "ppc64le", "riscv64", "s390x"]) +def test_container_cross_build(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", + "--privileged", + "-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")