-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'richtja/podman_build'
Signed-off-by: Cleber Rosa <[email protected]>
- Loading branch information
Showing
4 changed files
with
36 additions
and
13 deletions.
There are no files selected for viewing
This file contains 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 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,5 @@ | ||
FROM centos:stream9 | ||
WORKDIR /home/autils | ||
COPY ./ ./ | ||
RUN dnf install -y git | ||
RUN python3 -m ensurepip && python3 -m pip install . |
This file contains 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 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,30 +1,51 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
import os | ||
import sys | ||
|
||
import yaml | ||
from avocado.core.job import Job | ||
from avocado.core.suite import TestSuite | ||
from avocado.utils.podman import Podman | ||
|
||
CONTAINER_IMAGE_MAPPING = { | ||
"CentOS Stream 9": "centos:stream9", | ||
"Fedora 36": "fedora:36", | ||
"Fedora 37": "fedora:37", | ||
"CentOS Stream 9": ("redhat_based", "centos:stream9"), | ||
"Fedora 36": ("redhat_based", "fedora:36"), | ||
"Fedora 37": ("redhat_based", "fedora:37"), | ||
} | ||
|
||
METADATA_PATH = sys.argv[1] | ||
with open(METADATA_PATH, "rb") as m: | ||
metadata = yaml.load(m, Loader=yaml.SafeLoader) | ||
|
||
images = [] | ||
test_suites = [] | ||
for platform in metadata["supported_platforms"]: | ||
name = platform.replace(" ", "_") | ||
image = CONTAINER_IMAGE_MAPPING.get(platform) | ||
containerfile, image_version = CONTAINER_IMAGE_MAPPING.get(platform) | ||
loop = asyncio.get_event_loop() | ||
_, result, _ = loop.run_until_complete( | ||
Podman().execute( | ||
"build", | ||
"--no-cache", | ||
"--from", | ||
image_version, | ||
"-f", | ||
os.path.join("tests", "containerfiles", containerfile), | ||
".", | ||
) | ||
) | ||
image = result.splitlines()[-1].decode() | ||
images.append(image) | ||
config = {"run.spawner": "podman", "spawner.podman.image": image} | ||
|
||
config["resolver.references"] = metadata["tests"] | ||
test_suites.append(TestSuite.from_config(config, name)) | ||
|
||
|
||
with Job(test_suites=test_suites) as j: | ||
sys.exit(j.run()) | ||
rc = j.run() | ||
for image in images: | ||
loop.run_until_complete(Podman().execute("image", "rm", "-f", image)) | ||
sys.exit(rc) |