From 8a26d0648e7047b81a822ddb1315a28e9e5b96fe Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 30 Oct 2018 12:24:19 -0700 Subject: [PATCH] Stop using build to run the tests, allow using podman To use podman run the tests like this: DOCKER=podman make test-in-docker This now builds the welder/lorax-tests image as a separate step from running the tests. Running the tests uses the welder/lorax-tests image and mounts the source directory read-only, copies it into /lorax-test/ and runs the tests from there. --- Dockerfile.test | 14 +++----------- Makefile | 11 +++++++++-- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Dockerfile.test b/Dockerfile.test index 462073ff..5a6a887b 100644 --- a/Dockerfile.test +++ b/Dockerfile.test @@ -1,6 +1,5 @@ FROM registry.fedoraproject.org/fedora:rawhide - -RUN dnf -y install \ +RUN dnf -y install \ anaconda-tui \ libgit2-glib \ libselinux-python3 \ @@ -22,15 +21,8 @@ RUN dnf -y install \ beakerlib \ sudo \ tito \ + rsync \ which - RUN useradd weldr - -RUN mkdir /lorax -COPY . /lorax -# remove byte-compiled files to avoid issues between Python 2/3 -# this can happen when you switch between rhel7 and master branches -RUN find /lorax -name "*.pyc" -exec rm -f {} \; - +VOLUME /lorax WORKDIR /lorax -RUN make check test diff --git a/Makefile b/Makefile index 8fba6fb0..9002fe0b 100644 --- a/Makefile +++ b/Makefile @@ -2,12 +2,14 @@ PYTHON ?= /usr/bin/python3 DESTDIR ?= / PREFIX ?= /usr mandir ?= $(PREFIX)/share/man +DOCKER ?= docker PKGNAME = lorax VERSION = $(shell awk '/Version:/ { print $$2 }' $(PKGNAME).spec) RELEASE = $(shell awk '/Release:/ { print $$2 }' $(PKGNAME).spec | sed -e 's|%.*$$||g') TAG = lorax-$(VERSION)-$(RELEASE) +IMAGE_RELEASE = $(shell awk -F: '/FROM/ { print $$2}' Dockerfile.test) default: all @@ -74,11 +76,16 @@ local: @rm -rf /var/tmp/$(PKGNAME)-$(VERSION) @echo "The archive is in $(PKGNAME)-$(VERSION).tar.gz" +test-in-copy: + rsync -aP --exclude=.git /lorax/ /lorax-test/ + make -C /lorax-test/ check test + test-in-docker: - sudo docker build -t welder/lorax:latest -f Dockerfile.test . + sudo $(DOCKER) build -t welder/lorax-tests:$(IMAGE_RELEASE) -f Dockerfile.test . + sudo $(DOCKER) run --rm -it -v `pwd`:/lorax:ro --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make test-in-copy docs-in-docker: - sudo docker run -it --rm -v `pwd`/docs/html/:/lorax/docs/html/ --security-opt label=disable welder/lorax-composer:latest make docs + sudo $(DOCKER) run -it --rm -v `pwd`/docs/html/:/lorax/docs/html/ --security-opt label=disable welder/lorax-tests:$(IMAGE_RELEASE) make docs ci: check test