From 6a8f07ad394167280b822ade7fbc82f2e0b14c58 Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Apr 03 2019 12:45:40 +0000
Subject: [PATCH 1/5] allow single tests in containers, too


---

diff --git a/dev/containers/f29-rpms-py3 b/dev/containers/f29-rpms-py3
index bb000a7..6eea880 100644
--- a/dev/containers/f29-rpms-py3
+++ b/dev/containers/f29-rpms-py3
@@ -12,6 +12,7 @@ RUN dnf -y install \
     which \
     git
 
+# FIXME: this should use $REPO and $BRANCH:
 RUN cd / \
     && git clone https://pagure.io/pagure.git \
     && chmod +x /pagure/dev/containers/runtests_py3.sh
@@ -25,7 +26,6 @@ RUN dnf install -y `grep "Requires:" /pagure/files/pagure.spec | \
     dnf clean all && \
     cd /pagure && python setup.py build
 
-
 WORKDIR /pagure
 ENTRYPOINT ["/pagure/dev/containers/runtests_py3.sh"]
 CMD []
diff --git a/dev/containers/runtests_py2.sh b/dev/containers/runtests_py2.sh
index 9bc6301..ed39786 100644
--- a/dev/containers/runtests_py2.sh
+++ b/dev/containers/runtests_py2.sh
@@ -22,4 +22,4 @@ echo "Last commits:"
 git --no-pager log -2
 fi
 
-python2 /pagure/runtests.py run -f --py2
+python2 /pagure/runtests.py run -f --py2 $TESTCASE
diff --git a/dev/containers/runtests_py3.sh b/dev/containers/runtests_py3.sh
index cefded8..ac2bf03 100644
--- a/dev/containers/runtests_py3.sh
+++ b/dev/containers/runtests_py3.sh
@@ -22,4 +22,4 @@ echo "Last commits:"
 git --no-pager log -2
 fi
 
-python3 /pagure/runtests.py run -f --py3
+python3 /pagure/runtests.py run -f --py3 $TESTCASE
diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py
old mode 100644
new mode 100755
index 55f5648..489f2da
--- a/dev/run-tests-container.py
+++ b/dev/run-tests-container.py
@@ -126,10 +126,10 @@ if __name__ == "__main__":
                 "BRANCH={}".format(os.environ.get("BRANCH") or ""),
                 "-e",
                 "REPO={}".format(os.environ.get("REPO") or ""),
+                "-e",
+                "TESTCASE={}".format(args.test_case or ""),
                 container_name,
-                args.test_case,
             ]
-
             output_code = sp.call(command)
             if output_code:
                 failed.append(container_name)

From 3e761d0c533d6d740b0d8c3582ff387e0846ac2b Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Apr 03 2019 12:55:35 +0000
Subject: [PATCH 2/5] fix documentation about running tests


---

diff --git a/doc/development.rst b/doc/development.rst
index 3e0bdd5..8130c90 100644
--- a/doc/development.rst
+++ b/doc/development.rst
@@ -294,7 +294,7 @@ by alone, allowing easier debugging of the tests. For example:
 
 ::
 
-  python tests/test_pagure_lib.py
+  python runtests.py run tests/test_pagure_lib.py
 
 
 .. note:: In order to have coverage information you might have to install
@@ -313,7 +313,7 @@ by alone, allowing easier debugging of the tests. For example:
 To run the unit-tests, there is also a container available with all the dependencies needed.
 Use the following command to run the tests ::
 
-    $ ./dev/run-tests-docker.py
+    $ ./dev/run-tests-container.py
 
 This command will build a fedora based container and execute the test suite. You can also
 limit the tests to unit-test files or single tests similar to the ``python runtests.py``

From 0998608bd456d0a670b299b3cd0b31817de886b1 Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Apr 03 2019 14:21:59 +0000
Subject: [PATCH 3/5] allow overwriting default repo


---

diff --git a/dev/containers/centos7-rpms-py2 b/dev/containers/centos7-rpms-py2
index 472e36d..40fe373 100644
--- a/dev/containers/centos7-rpms-py2
+++ b/dev/containers/centos7-rpms-py2
@@ -1,5 +1,11 @@
 FROM centos:7
 
+ARG repo
+ARG branch
+
+ENV REPO=$repo
+ENV BRANCH=$branch
+
 RUN yum -y install \
     epel-release
 
@@ -26,7 +32,7 @@ RUN yum -y install \
 RUN yum install -y https://pingou.fedorapeople.org/RPMs/python-werkzeug-0.9.6-1.el7.noarch.rpm
 
 RUN cd / \
-    && git clone https://pagure.io/pagure.git \
+    && git clone -b $BRANCH $REPO \
     && chmod +x /pagure/dev/containers/runtests_py2.sh
 
 # Install all the requirements from the spec file and replace the macro
diff --git a/dev/containers/f29-rpms-py3 b/dev/containers/f29-rpms-py3
index 6eea880..f061d3d 100644
--- a/dev/containers/f29-rpms-py3
+++ b/dev/containers/f29-rpms-py3
@@ -1,5 +1,11 @@
 FROM fedora:29
 
+ARG repo
+ARG branch
+
+ENV REPO=$repo
+ENV BRANCH=$branch
+
 RUN dnf -y install \
     python3-setuptools \
     python3-coverage \
@@ -14,7 +20,7 @@ RUN dnf -y install \
 
 # FIXME: this should use $REPO and $BRANCH:
 RUN cd / \
-    && git clone https://pagure.io/pagure.git \
+    && git clone -b $BRANCH $REPO \
     && chmod +x /pagure/dev/containers/runtests_py3.sh
 
 # Install all the requirements from the spec file and replace the macro
diff --git a/dev/containers/fedora-pip-py3 b/dev/containers/fedora-pip-py3
index 6f4c1b7..d50ec7b 100644
--- a/dev/containers/fedora-pip-py3
+++ b/dev/containers/fedora-pip-py3
@@ -1,5 +1,11 @@
 FROM fedora:latest
 
+ARG repo
+ARG branch
+
+ENV REPO=$repo
+ENV BRANCH=$branch
+
 RUN dnf -y install \
     python3-setuptools \
     redhat-rpm-config \
@@ -15,7 +21,7 @@ RUN dnf -y install \
     git
 
 RUN cd / \
-    && git clone https://pagure.io/pagure.git \
+    && git clone -b $BRANCH $REPO \
     && chmod +x /pagure/dev/containers/tox_py3.sh
 
 # Install pygit2 manually, outside of the virtualenv since it is tightly coupled
diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py
index 489f2da..2793a26 100755
--- a/dev/run-tests-container.py
+++ b/dev/run-tests-container.py
@@ -74,6 +74,10 @@ if __name__ == "__main__":
                 [
                     "podman",
                     "build",
+                    "--build-arg",
+                    "branch={}".format(os.environ.get("BRANCH") or "master"),
+                    "--build-arg",
+                    "repo={}".format(os.environ.get("REPO") or "https://pagure.io/pagure.git"),
                     "--rm",
                     "-t",
                     container_name,
@@ -103,9 +107,9 @@ if __name__ == "__main__":
                 "{}/results_{}:/pagure/results:z".format(
                     os.getcwd(), container_files[idx]),
                 "-e",
-                "BRANCH=$BRANCH",
+                "BRANCH={}".format(os.environ.get("BRANCH") or "master"),
                 "-e",
-                "REPO=$REPO",
+                "REPO={}".format(os.environ.get("REPO") or "https://pagure.io/pagure.git"),
                 "--entrypoint=/bin/bash",
                 container_name,
             ]
@@ -123,9 +127,9 @@ if __name__ == "__main__":
                 "{}/results_{}:/pagure/results:z".format(
                     os.getcwd(), container_files[idx]),
                 "-e",
-                "BRANCH={}".format(os.environ.get("BRANCH") or ""),
+                "BRANCH={}".format(os.environ.get("BRANCH") or "master"),
                 "-e",
-                "REPO={}".format(os.environ.get("REPO") or ""),
+                "REPO={}".format(os.environ.get("REPO") or "https://pagure.io/pagure.git"),
                 "-e",
                 "TESTCASE={}".format(args.test_case or ""),
                 container_name,

From ef713e95502a8d62f6256a4a6944f845bd73206c Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Apr 03 2019 14:46:58 +0000
Subject: [PATCH 4/5] mention REPO and BRANCH in the development documentation


---

diff --git a/dev/containers/f29-rpms-py3 b/dev/containers/f29-rpms-py3
index f061d3d..ec2efd0 100644
--- a/dev/containers/f29-rpms-py3
+++ b/dev/containers/f29-rpms-py3
@@ -18,7 +18,6 @@ RUN dnf -y install \
     which \
     git
 
-# FIXME: this should use $REPO and $BRANCH:
 RUN cd / \
     && git clone -b $BRANCH $REPO \
     && chmod +x /pagure/dev/containers/runtests_py3.sh
diff --git a/doc/development.rst b/doc/development.rst
index 8130c90..5ed3d8d 100644
--- a/doc/development.rst
+++ b/doc/development.rst
@@ -317,6 +317,7 @@ Use the following command to run the tests ::
 
 This command will build a fedora based container and execute the test suite. You can also
 limit the tests to unit-test files or single tests similar to the ``python runtests.py``
-options described above.
+options described above. You need set the environment variables REPO and BRANCH if the
+tests are not yet available in the upstream pagure master branch.
 
 

From 0d4020ec3a11326600db510d4e8640432aee20a3 Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Apr 04 2019 08:43:47 +0000
Subject: [PATCH 5/5] add default values for ARGs


---

diff --git a/dev/containers/centos7-rpms-py2 b/dev/containers/centos7-rpms-py2
index 40fe373..0f5501e 100644
--- a/dev/containers/centos7-rpms-py2
+++ b/dev/containers/centos7-rpms-py2
@@ -1,7 +1,7 @@
 FROM centos:7
 
-ARG repo
-ARG branch
+ARG repo=https://pagure.io/pagure.git
+ARG branch=master
 
 ENV REPO=$repo
 ENV BRANCH=$branch
diff --git a/dev/containers/f29-rpms-py3 b/dev/containers/f29-rpms-py3
index ec2efd0..5b935c6 100644
--- a/dev/containers/f29-rpms-py3
+++ b/dev/containers/f29-rpms-py3
@@ -1,7 +1,7 @@
 FROM fedora:29
 
-ARG repo
-ARG branch
+ARG repo=https://pagure.io/pagure.git
+ARG branch=master
 
 ENV REPO=$repo
 ENV BRANCH=$branch
diff --git a/dev/containers/fedora-pip-py3 b/dev/containers/fedora-pip-py3
index d50ec7b..5a504ba 100644
--- a/dev/containers/fedora-pip-py3
+++ b/dev/containers/fedora-pip-py3
@@ -1,7 +1,7 @@
 FROM fedora:latest
 
-ARG repo
-ARG branch
+ARG repo=https://pagure.io/pagure.git
+ARG branch=master
 
 ENV REPO=$repo
 ENV BRANCH=$branch

