Skip to content

Commit

Permalink
Merge remote-tracking branch 'richtja/podman_build'
Browse files Browse the repository at this point in the history
Signed-off-by: Cleber Rosa <[email protected]>
  • Loading branch information
clebergnu committed Dec 3, 2024
2 parents 7a2efad + bea5005 commit cb50371
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/modules-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
run: pip3 install 'avocado-framework<104.0'

- name: Include autils directory from source tree into Python's PATH
run: pip3 install .
run: |
pip install --upgrade pip
pip3 install .
- name: run static checks
uses: avocado-framework/avocado-ci-tools@main
Expand Down
5 changes: 5 additions & 0 deletions tests/containerfiles/redhat_based
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 .
9 changes: 2 additions & 7 deletions tests/modules/archive/ar.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
try:
from autils.archive import ar
except ImportError:
# FIXME: this should come instead from autils. This is a
# workaround while the test framework does not know how
# to send the libraries themselves to the test environment
from avocado.utils import ar
from avocado import Test

from autils.archive import ar


class Ar(Test):
def test_is_ar(self):
Expand Down
31 changes: 26 additions & 5 deletions tests/test_module.py
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)

0 comments on commit cb50371

Please sign in to comment.