-
Notifications
You must be signed in to change notification settings - Fork 15
ci: split apart test cases #331
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
Draft
supakeen
wants to merge
5
commits into
osbuild:main
Choose a base branch
from
supakeen:split-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
[FORMAT] | ||
max-line-length=120 | ||
|
||
[MESSAGES CONTROL] | ||
disable=R0801 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] != "" |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could you use 'duplicate-code' instead? I had to look up what R0801 was :)
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.
I could/should but it seems the
.pylintrc
is being ignored in CI anyhow so this might change/move :)