Skip to content

Commit 67d85da

Browse files
committed
Run ansible-test sanity from quay image not from build
Issue: AAH-1884
1 parent eb5ead4 commit 67d85da

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

CHANGES/1884.removal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Remove use of docker build, instead use quay image to run ansible-test sanity

galaxy_importer/ansible_test/runners/local_image.py

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,43 +15,52 @@
1515
# You should have received a copy of the Apache License
1616
# along with Galaxy. If not, see <http://www.apache.org/licenses/>.
1717

18+
import os
1819
import shutil
19-
from subprocess import Popen, PIPE, STDOUT
20+
from subprocess import PIPE, STDOUT, Popen
2021

21-
from galaxy_importer import config
22-
from galaxy_importer import exceptions
23-
from galaxy_importer.ansible_test.builders.local_image_build import Build
22+
from galaxy_importer import config, exceptions
2423
from galaxy_importer.ansible_test.runners.base import BaseTestRunner
2524

2625

2726
class LocalImageTestRunner(BaseTestRunner):
28-
"""Run image locally with docker or podman."""
27+
"""
28+
Run `ansible-test sanity` in container defined in repo and hosted on quay.
2929
30-
def run(self):
31-
cfg = config.Config(config_data=config.ConfigFile.load())
30+
Container defined at galaxy_importer/ansible_test/container
3231
33-
build = Build(
34-
self.filepath,
35-
f"{self.metadata.namespace}-{self.metadata.name}-{self.metadata.version}",
36-
cfg,
37-
self.log,
38-
)
32+
Image used is hosted on quay: quay.io/cloudservices/automation-hub-ansible-test
33+
"""
3934

40-
container_engine = build.get_container_engine(cfg)
35+
def run(self):
36+
cfg = config.Config(config_data=config.ConfigFile.load())
4137

38+
# Get preferred container image and check if installed
39+
container_engine = "podman"
40+
if cfg.local_image_docker is True:
41+
container_engine = "docker"
4242
if not shutil.which(container_engine):
4343
self.log.warning(f'"{container_engine}" not found, skipping ansible-test sanity')
4444
return
4545

46-
image_id = build.build_image()
46+
# Copy user-provided archive into path that can be used as volume
47+
archive_path = os.path.join(self.dir, "archive.tar.gz")
48+
self.log.debug(f"archive_path={archive_path}")
49+
shutil.copy(self.filepath, archive_path)
50+
volume = f"{archive_path}:/archive/archive.tar.gz"
4751

4852
self.log.info("Running image...")
49-
self._run_image(image_id=image_id, container_engine=container_engine)
53+
self._run_image(container_engine=container_engine, volume=volume)
5054

51-
build.cleanup()
55+
def _run_image(self, container_engine, volume):
56+
cmd = [
57+
container_engine, "run",
58+
"-v", volume,
59+
"quay.io/cloudservices/automation-hub-ansible-test",
60+
"LOCAL_IMAGE_RUNNER",
61+
] # fmt: skip
62+
self.log.debug(f"cmd={cmd}")
5263

53-
def _run_image(self, image_id, container_engine):
54-
cmd = [container_engine, "run", image_id, "LOCAL_IMAGE_RUNNER"]
5564
proc = Popen(
5665
cmd,
5766
stdout=PIPE,

0 commit comments

Comments
 (0)