From 08a5bc9eff6c9e9017c7b1d0a276df2a516a8df0 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 1/18] feat: Dockerfile for c8s base and code container added Faster build times by splitting os and container/entrypoint logic. Allows independent re-builds and re-use of the same images for multiple tests without the requirement to re-build Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/base-centos-stream8-rpms-py3 b/dev/containers/base-centos-stream8-rpms-py3 new file mode 100644 index 0000000..e547f1b --- /dev/null +++ b/dev/containers/base-centos-stream8-rpms-py3 @@ -0,0 +1,41 @@ +FROM quay.io/centos/centos:stream8 + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG specfile=https://pagure.io/pagure/raw/master/f/files/pagure.spec + +ENV SPECFILE=$specfile + +RUN dnf -y install \ + epel-release epel-next-release 'dnf-command(config-manager)' \ + && dnf -y config-manager --enable epel-testing epel-next-testing powertools \ + && dnf -y install \ + python3-setuptools \ + python3-beautifulsoup4 \ + python3-coverage \ + python3-mock \ + python3-docutils \ + python3-flake8 \ + python3-pytest-xdist \ + python3-flask-oidc \ + python3-cchardet \ + python3-fedora-messaging \ + python3-pip \ + redis \ + which \ + git \ + && dnf clean all + +RUN pip3 install pagure-messages + +# Install all the requirements from the spec file and replace the macro +# %{python_pkgversion} by '3' which thus installs all the py3 version of +# the dependencies. +RUN curl ${SPECFILE} -o /pagure.spec \ + && dnf install -y `grep "Requires:" /pagure.spec | \ + awk '{split($0, a, " "); print a[2]}' | grep -v "%{name}" | \ + sed -e "s|%{python_pkgversion}|3|"` \ + && dnf clean all \ No newline at end of file diff --git a/dev/containers/code-centos-stream8-rpms-py3 b/dev/containers/code-centos-stream8-rpms-py3 new file mode 100644 index 0000000..5639bb2 --- /dev/null +++ b/dev/containers/code-centos-stream8-rpms-py3 @@ -0,0 +1,16 @@ +FROM base-centos-stream8-rpms-py3:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG repo=https://pagure.io/pagure.git +ARG branch=master + +ENV REPO=$repo +ENV BRANCH=$branch + +COPY entrypoint_rpms.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT /entrypoint.sh \ No newline at end of file From c5333b748f11068b2ca419efbd5e137fbf8fc4cb Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 2/18] feat: Dockerfile fedora rpm base and code container added Faster build times by splitting os and container/entrypoint logic. Allows independent re-builds and re-use of the same images for multiple tests without the requirement to re-build Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/base-fedora-rpms-py3 b/dev/containers/base-fedora-rpms-py3 new file mode 100644 index 0000000..b50036d --- /dev/null +++ b/dev/containers/base-fedora-rpms-py3 @@ -0,0 +1,39 @@ +FROM quay.io/fedora/fedora:36-x86_64 + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG specfile=https://pagure.io/pagure/raw/master/f/files/pagure.spec + +ENV SPECFILE=$specfile + +RUN dnf -y --enablerepo=updates-testing install \ + python3-setuptools \ + python3-beautifulsoup4 \ + python3-coverage \ + python3-mock \ + python3-docutils \ + python3-black \ + python3-flake8 \ + python3-pytest-xdist \ + python3-flask-oidc \ + python3-cchardet \ + python3-fedora-messaging \ + python3-pip \ + redis \ + which \ + git \ + && dnf clean all + +RUN pip install pagure-messages + +# Install all the requirements from the spec file and replace the macro +# %{python_pkgversion} by '3' which thus installs all the py3 version of +# the dependencies. +RUN curl ${SPECFILE} -o /pagure.spec \ + && dnf install -y --enablerepo=updates-testing `grep "Requires:" /pagure.spec | \ + awk '{split($0, a, " "); print a[2]}' | grep -v "%{name}" | \ + sed -e "s|%{python_pkgversion}|3|"` \ + && dnf clean all \ No newline at end of file diff --git a/dev/containers/code-fedora-rpms-py3 b/dev/containers/code-fedora-rpms-py3 new file mode 100644 index 0000000..aca7115 --- /dev/null +++ b/dev/containers/code-fedora-rpms-py3 @@ -0,0 +1,16 @@ +FROM base-fedora-rpms-py3:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG repo=https://pagure.io/pagure.git +ARG branch=master + +ENV REPO=$repo +ENV BRANCH=$branch + +COPY entrypoint_rpms.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT /entrypoint.sh \ No newline at end of file From 4409cdbf6eca9f98c5c3607f13855166a5160001 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 3/18] feat: entrypoint for rpm based container added Common entrypoint file for c8s and fedora rpm containers. Abstraction layer for runtests_py3.py to dynamically define Repo and Branch by passing arguments. Allows to run tests as before against remote repositories but also completly local against the current branch and changes. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/entrypoint_rpms.sh b/dev/containers/entrypoint_rpms.sh new file mode 100644 index 0000000..bdd85f7 --- /dev/null +++ b/dev/containers/entrypoint_rpms.sh @@ -0,0 +1,8 @@ +#!/bin/bash +cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure \ +&& chmod +x /pagure/dev/containers/runtests_py3.sh \ +&& ln -s /results /pagure/results \ +&& cd /pagure \ +&& python3 setup.py build \ +&& dev/containers/runtests_py3.sh \ No newline at end of file From 20e9fe6ea1fd679e164dfc5ee620a4b9911eb1b4 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 4/18] feat: Dockerfile fedora pip base and code container added Faster build times by splitting os and container/entrypoint logic. Allows independent re-builds and re-use of the same images for multiple tests without the requirement to re-build Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/base-fedora-pip-py3 b/dev/containers/base-fedora-pip-py3 new file mode 100644 index 0000000..9433227 --- /dev/null +++ b/dev/containers/base-fedora-pip-py3 @@ -0,0 +1,38 @@ +FROM quay.io/fedora/fedora:36-x86_64 + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG repo=https://pagure.io/pagure.git +ARG branch=master + +ENV REPO=$repo +ENV BRANCH=$branch + +RUN dnf -y install \ + python3-setuptools \ + redhat-rpm-config \ + python3-devel \ + libgit2-devel \ + python3-tox \ + libffi-devel \ + zeromq-devel \ + gcc \ + redis \ + which \ + git \ + glibc-langpack-en \ + && dnf clean all + +# Pre-build tox environments and keep em in the base container +# to avoid re-build on every run, even if tox config not changed +RUN mkdir /tox \ + && echo Repo: ${REPO}, Branch: ${BRANCH} \ + && git clone -b ${BRANCH} ${REPO} /pagure \ + && ln -s /tox /pagure/.tox \ + && cd /pagure \ + && tox --notest \ + && cd / \ + && rm -rf /pagure \ No newline at end of file diff --git a/dev/containers/code-fedora-pip-py3 b/dev/containers/code-fedora-pip-py3 new file mode 100644 index 0000000..400db81 --- /dev/null +++ b/dev/containers/code-fedora-pip-py3 @@ -0,0 +1,17 @@ +FROM base-fedora-pip-py3:latest + +LABEL org.opencontainers.image.authors="pagure community" +LABEL org.opencontainers.image.url="https://pagure.io/pagure" +LABEL org.opencontainers.image.source="https://pagure.io/pagure/blob/master/f/dev/containers" +LABEL org.opencontainers.image.documentation="https://docs.pagure.org/pagure/index.html" + +ARG repo=https://pagure.io/pagure.git +ARG branch=master + +ENV REPO=$repo +ENV BRANCH=$branch + +COPY tox_py3.sh /tox_py3.sh +COPY entrypoint_pip.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh +ENTRYPOINT /entrypoint.sh \ No newline at end of file From b5d95c1d1388c4c01ea9c5bd264a7d054b75c195 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 5/18] feat: entrypoint for pip based container added Abstraction layer for tox_py3.sh to dynamically define Repo and Branch by passing arguments. Allows to run tests, as before, against remote repositories but also completely local against the current branch and changes. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/entrypoint_pip.sh b/dev/containers/entrypoint_pip.sh new file mode 100644 index 0000000..14fdff3 --- /dev/null +++ b/dev/containers/entrypoint_pip.sh @@ -0,0 +1,10 @@ +#!/bin/bash +cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure \ +&& cp /tox_py3.sh /pagure/dev/containers/tox_py3.sh \ +&& chmod +x /pagure/dev/containers/tox_py3.sh \ +&& ln -s /results /pagure/results \ +&& ln -s /tox /pagure/.tox \ +&& cd /pagure \ +&& sed -i -e 's|"alembic-3"|"alembic"|' /pagure/tests/test_alembic.py \ +&& dev/containers/tox_py3.sh From 0449b2e29de523dc54915902a6997a7c11b7545e Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:50 +0000 Subject: [PATCH 6/18] feat(tox_py3): Relative exec path, var for py ver and test case Adjustment to allow definition of python version and test case via argument variable. Path to tests changed from full to relative path, workdir is already /pagure inside the containers. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/tox_py3.sh b/dev/containers/tox_py3.sh index 508662a..6dc5b73 100644 --- a/dev/containers/tox_py3.sh +++ b/dev/containers/tox_py3.sh @@ -23,4 +23,4 @@ git --no-pager log -2 fi export LANG="en_US.UTF-8" -tox -v -e 'py38' -- /pagure/tests/ +tox -v -e "${PYVER:-py38}" -- ${TESTCASE:-tests/} \ No newline at end of file From 4d9c3a6a3ec82364f5280a7a05bc8722deca068e Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 7/18] fix: container entrypoints, write log to results entrypoint files for rpms and pip adjusted to write logs into results folder. /results is mounted into the container, each run write a 'output.log' appended with the timestamp. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/entrypoint_pip.sh b/dev/containers/entrypoint_pip.sh index 14fdff3..8033fcf 100644 --- a/dev/containers/entrypoint_pip.sh +++ b/dev/containers/entrypoint_pip.sh @@ -1,10 +1,11 @@ #!/bin/bash -cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure \ +export TIMESTAMP=$(date +%s) \ +&& cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ && cp /tox_py3.sh /pagure/dev/containers/tox_py3.sh \ && chmod +x /pagure/dev/containers/tox_py3.sh \ -&& ln -s /results /pagure/results \ && ln -s /tox /pagure/.tox \ && cd /pagure \ +&& ln -s /results /pagure/results \ && sed -i -e 's|"alembic-3"|"alembic"|' /pagure/tests/test_alembic.py \ -&& dev/containers/tox_py3.sh +&& dev/containers/tox_py3.sh 2>&1 | tee -a /results/"$TIMESTAMP"_output.log diff --git a/dev/containers/entrypoint_rpms.sh b/dev/containers/entrypoint_rpms.sh index bdd85f7..2236c21 100644 --- a/dev/containers/entrypoint_rpms.sh +++ b/dev/containers/entrypoint_rpms.sh @@ -1,8 +1,9 @@ #!/bin/bash -cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure \ +export TIMESTAMP=$(date +%s) \ +&& cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ && chmod +x /pagure/dev/containers/runtests_py3.sh \ -&& ln -s /results /pagure/results \ && cd /pagure \ -&& python3 setup.py build \ -&& dev/containers/runtests_py3.sh \ No newline at end of file +&& ln -s /results /pagure/results \ +&& python3 setup.py build 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ +&& dev/containers/runtests_py3.sh 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ No newline at end of file From 425b2149950c235fe96d621103e99714cbff3eb5 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 8/18] feat: run tests container migrated to new base and code images usage of new base and code images (c8s rpm, f36 rpm, f36 pip) new functions added to avoid code repetition for repeating tasks.. parameter --rebuild (all images) and --rebuild-code (only code images) added. by default, containers only get build if the not exist on the local system yet, previous images were always build and had to be skipped manually (--skip-build). Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 6f1bea4..ae17eeb 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -8,6 +8,62 @@ import subprocess as sp ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +def _container_image_exist(container_name, container_type): + cmd = [ + "podman", + "image", + "exists", + containers[container_name][container_type] + ] + return _call_command(cmd) + + +def _build_container(container_name, container_type, container_volume=None, **kwargs): + # kwargs can be used to pass '--build-arg' + build_args = [] + for arg in kwargs.values(): + build_args.append("--build-arg") + build_args.append(arg) + + volume = [] + if container_volume: + volume.append("-v") + volume.append(volume) + + container_file = "" + if container_type == "base": + container_file = containers[container_name]["base"] + container_name = container_file + if container_type == "code": + container_file = containers[container_name]["code"] + container_name = container_file + + cmd = [ + "podman", + "build", + "--rm", + "-t", + container_name, + "-f", + ROOT + "/dev/containers/%s" % container_file, + ROOT + "/dev/containers", + ] + + cmd += build_args + cmd += volume + + return _call_command(cmd) + + +def _call_command(cmd): + print("Command: " + " ".join(cmd)) + rc = sp.call(cmd) + if rc != 0: + return False + else: + return True + + def setup_parser(): """ Setup the cli arguments """ parser = argparse.ArgumentParser(prog="pagure-test") @@ -36,6 +92,18 @@ def setup_parser(): help="Skip building the container image", ) parser.add_argument( + "--rebuild", + dest="rebuild", + action="store_true", + help="Enforce rebuild of container images", + ) + parser.add_argument( + "--rebuild-code", + dest="rebuild_code", + action="store_true", + help="Enforce rebuild of code container images only", + ) + parser.add_argument( "--shell", dest="shell", action="store_true", @@ -65,90 +133,103 @@ if __name__ == "__main__": parser = setup_parser() args = parser.parse_args() - if args.centos is True: - container_names = ["pagure-c8s-rpms-py3"] - container_files = ["centos8-rpms-py3"] - elif args.fedora is True: - container_names = ["pagure-fedora-rpms-py3"] - container_files = ["fedora-rpms-py3"] - elif args.pip is True: - container_names = ["pagure-fedora-pip-py3"] - container_files = ["fedora-pip-py3"] + containers = { + "centos": { + "name": "pagure-tests-centos-stream8-rpms-py3", + "base": "base-centos-stream8-rpms-py3", + "code": "code-centos-stream8-rpms-py3" + }, + "fedora": { + "name": "pagure-tests-fedora-rpms-py3", + "base": "base-fedora-rpms-py3", + "code": "code-fedora-rpms-py3" + }, + "pip": { + "name": "pagure-tests-fedora-pip-py3", + "base": "base-fedora-pip-py3", + "code": "code-fedora-pip-py3" + } + } + + if args.centos: + container_names = ["centos"] + elif args.fedora: + container_names = ["fedora"] + elif args.pip: + container_names = ["pip"] else: - container_names = [ - "pagure-fedora-rpms-py3", - "pagure-c8s-rpms-py3", - "pagure-fedora-pip-py3", - ] - container_files = [ - "fedora-rpms-py3", - "centos8-rpms-py3", - "fedora-pip-py3", - ] + container_names = ["centos", "fedora", "pip"] failed = [] - print("Running for {} containers:".format(len(container_names))) + print("Running for %d containers:" % len(container_names)) print(" - " + "\n - ".join(container_names)) - for idx, container_name in enumerate(container_names): - if args.skip_build is not False: - print("------ Building Container Image -----") - cmd = [ - "podman", - "build", - "--build-arg", - "branch={}".format(os.environ.get("BRANCH") or args.branch), - "--build-arg", - "repo={}".format(os.environ.get("REPO") or args.repo), - "--rm", - "-t", + for container_name in container_names: + print("\n------ Building Container Image -----") + + if not _container_image_exist(container_name, "base") or args.rebuild: + print("Container does not exist, building: %s" % containers[container_name]["base"]) + if _build_container( container_name, - "-f", - ROOT + "/dev/containers/%s" % container_files[idx], - ROOT + "/dev/containers", - ] - print(" ".join(cmd)) - output_code = sp.call(cmd) - if output_code: - print("Failed building: %s", container_name) + "base", + branch="{}".format(os.environ.get("BRANCH") or args.branch), + repo="{}".format(os.environ.get("REPO") or args.repo) + ): + base_build = True + else: + print("Failed building: %s" % containers[container_name]["base"]) break + else: + base_build = False + print("Container already exist, skipped building: %s" % containers[container_name]["base"]) - result_path = "{}/results_{}".format(os.getcwd(), container_files[idx]) + if not _container_image_exist(container_name, "code") or \ + base_build or \ + args.rebuild or \ + args.rebuild_code: + print("Container does not exist, building: %s" % containers[container_name]["code"]) + if not _build_container(container_name, "code"): + print("Failed building: %s" % containers[container_name]["code"]) + break + else: + print("Container already exist, skipped building: %s" % containers[container_name]["code"]) + + result_path = "{}/results_{}".format(os.getcwd(), containers[container_name]["name"]) if not os.path.exists(result_path): os.mkdir(result_path) if args.shell: print("--------- Shelling in the container --------------") - command = [ + cmd = [ "podman", "run", "-it", "--rm", "--name", - container_name, + containers[container_name]["name"], "-v", - "{}/results_{}:/pagure/results:z".format( - os.getcwd(), container_files[idx] + "{}/results_{}:/results:z".format( + os.getcwd(), containers[container_name]["name"] ), "-e", "BRANCH={}".format(os.environ.get("BRANCH") or args.branch), "-e", "REPO={}".format(os.environ.get("REPO") or args.repo), "--entrypoint=/bin/bash", - container_name, + containers[container_name]["code"], ] - sp.call(command) + sp.call(cmd) else: print("--------- Running Test --------------") - command = [ + cmd = [ "podman", "run", "-it", "--rm", "--name", - container_name, + containers[container_name]["name"], "-v", - "{}/results_{}:/pagure/results:z".format( - os.getcwd(), container_files[idx] + "{}/results_{}:/results:z".format( + os.getcwd(), containers[container_name]["name"] ), "-e", "BRANCH={}".format(os.environ.get("BRANCH") or args.branch), @@ -156,10 +237,9 @@ if __name__ == "__main__": "REPO={}".format(os.environ.get("REPO") or args.repo), "-e", "TESTCASE={}".format(args.test_case or ""), - container_name, + containers[container_name]["code"], ] - output_code = sp.call(command) - if output_code: + if not _call_command(cmd): failed.append(container_name) if not args.shell: From def653bc91744a16eb2146d9d1e3227372c7c5e0 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 9/18] feat(run-test-container): check for pre-reqs Check if podman and git exist before proceed, exit program with error if one of them not found. Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index ae17eeb..a2e5642 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -64,6 +64,34 @@ def _call_command(cmd): return True +def _check_pre_reqs(): + programs = [ + { + "name": "podman", + "cmd": ["podman", "version"] + }, + { + "name": "git", + "cmd": ["git", "version"] + } + ] + + # 'os.devnull' used for backward compatibility with Python2. + # for Py3 only, 'sp.DEVNULL' can be used and this workaround removed. + FNULL = open(os.devnull, 'w') + + missing = [] + for program in programs: + try: + sp.call(program["cmd"], stdout=FNULL, stderr=sp.STDOUT) + except OSError: + missing.append(program["name"]) + + if len(missing) > 0: + print("Error! Required programs not found: " + ", ".join(missing)) + os._exit(1) + + def setup_parser(): """ Setup the cli arguments """ parser = argparse.ArgumentParser(prog="pagure-test") @@ -130,6 +158,8 @@ def setup_parser(): if __name__ == "__main__": + _check_pre_reqs() + parser = setup_parser() args = parser.parse_args() From f7079870732fa4a046a8c419956f3c24bf04849f Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 10/18] feat(run-tests-container): use local repo and branch by default default repo changed from 'https://pagure.io/pagure.git' to '/wrkdir' and default branch changed from 'master' to 'wrkdirbranch', logic added that will use the git repo and active branch in the current directory to perform tests. It's not necessary to push changes to a remote repository to run all or a specific test case. A repo name without 'http://' or 'https://' will be interpreted as local path and handled accordingly. Both can be overridden to a URL and branch name for the same behavior as before. Also some cleanup / refactoring to reduce redundant code. Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index a2e5642..94a6115 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -142,16 +142,16 @@ def setup_parser(): parser.add_argument( "--repo", dest="repo", - default="https://pagure.io/pagure.git", - help="URL of the public repo to use as source, can be overridden using " - "the REPO environment variable", + default="/wrkdir", + help="URL or local path to git repository as source of the public repo to use as source, " + "defaults to git repo in current directory, can also be overridden using the REPO environment variable", ) parser.add_argument( "--branch", dest="branch", - default="master", - help="Branch of the repo to use as source, can be overridden using " - "the BRANCH environment variable", + default="wrkdirbranch", + help="Branch name to use as source, defaults to the active branch in current directory, " + "can also be overridden by using the BRANCH environment variable", ) return parser @@ -190,6 +190,25 @@ if __name__ == "__main__": else: container_names = ["centos", "fedora", "pip"] + # get full path of git repo in current directory and set var to mount it into the container + if args.repo == "/wrkdir": + # Kudos: Ryne Everett + # https://stackoverflow.com/questions/22081209#comment44778829_22081487 + wrkdir_path = sp.Popen(['git', 'rev-parse', '--show-toplevel'], + stdout=sp.PIPE).communicate()[0].rstrip().decode('ascii') + mount_wrkdir = True + # 'args.repo' will be set as path to mount it into the container and then + # overridden with '/wrkdir' to leverage existing logic to use a local path + elif 'http://' not in args.repo \ + and 'https://' not in args.repo: + wrkdir_path = args.repo + args.repo = "/wrkdir" + mount_wrkdir = True + + if args.branch == "wrkdirbranch": + args.branch = sp.Popen(['git', 'branch', '--show-current'], + stdout=sp.PIPE).communicate()[0].rstrip().decode('ascii') + failed = [] print("Running for %d containers:" % len(container_names)) print(" - " + "\n - ".join(container_names)) @@ -227,6 +246,25 @@ if __name__ == "__main__": if not os.path.exists(result_path): os.mkdir(result_path) + volumes = [ + "-v", + "{}:/results:z".format(result_path) + ] + if mount_wrkdir: + volumes += [ + "-v", + "{}:/wrkdir:z,ro".format(wrkdir_path) + ] + + env_vars = [ + "-e", + "BRANCH={}".format(os.environ.get("BRANCH") or args.branch), + "-e", + "REPO={}".format(os.environ.get("REPO") or args.repo), + "-e", + "TESTCASE={}".format(args.test_case or ""), + ] + if args.shell: print("--------- Shelling in the container --------------") cmd = [ @@ -235,15 +273,11 @@ if __name__ == "__main__": "-it", "--rm", "--name", - containers[container_name]["name"], - "-v", - "{}/results_{}:/results:z".format( - os.getcwd(), containers[container_name]["name"] - ), - "-e", - "BRANCH={}".format(os.environ.get("BRANCH") or args.branch), - "-e", - "REPO={}".format(os.environ.get("REPO") or args.repo), + containers[container_name]["name"] + ] + cmd += volumes + cmd += env_vars + cmd += [ "--entrypoint=/bin/bash", containers[container_name]["code"], ] @@ -257,16 +291,10 @@ if __name__ == "__main__": "--rm", "--name", containers[container_name]["name"], - "-v", - "{}/results_{}:/results:z".format( - os.getcwd(), containers[container_name]["name"] - ), - "-e", - "BRANCH={}".format(os.environ.get("BRANCH") or args.branch), - "-e", - "REPO={}".format(os.environ.get("REPO") or args.repo), - "-e", - "TESTCASE={}".format(args.test_case or ""), + ] + cmd += volumes + cmd += env_vars + cmd += [ containers[container_name]["code"], ] if not _call_command(cmd): @@ -279,4 +307,4 @@ if __name__ == "__main__": else: print(" %s TESTS FAILED:" % len(failed)) for fail in failed: - print(" - %s" % fail) + print(" - %s" % fail) \ No newline at end of file From 0f087c4c947569c5642afd9ce2347546f8cad19f Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 11/18] feat(run-tests-container): ignore cache on rebuild '--rebuild' will now enforce image building and ignore local cache. Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 94a6115..29a23c4 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -41,6 +41,7 @@ def _build_container(container_name, container_type, container_volume=None, **kw cmd = [ "podman", "build", + "--no-cache", "--rm", "-t", container_name, From a37823c53b64955001cc05ecb4b0d8d241a67526 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 12/18] feat(run-tests-container): move logging outside container Writing logs to '/results/' inside the container was done via the entrypoint script. To have a full log coverage, also from build and shell operations, it's now part of the run-tests-container.py3 script and writes to dev/results_. Every log file has the current unix timestamp as prefix, files are not overwritten. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/entrypoint_pip.sh b/dev/containers/entrypoint_pip.sh index 8033fcf..92bcbe6 100644 --- a/dev/containers/entrypoint_pip.sh +++ b/dev/containers/entrypoint_pip.sh @@ -1,11 +1,10 @@ #!/bin/bash -export TIMESTAMP=$(date +%s) \ -&& cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ +cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure \ && cp /tox_py3.sh /pagure/dev/containers/tox_py3.sh \ && chmod +x /pagure/dev/containers/tox_py3.sh \ && ln -s /tox /pagure/.tox \ && cd /pagure \ && ln -s /results /pagure/results \ && sed -i -e 's|"alembic-3"|"alembic"|' /pagure/tests/test_alembic.py \ -&& dev/containers/tox_py3.sh 2>&1 | tee -a /results/"$TIMESTAMP"_output.log +&& dev/containers/tox_py3.sh diff --git a/dev/containers/entrypoint_rpms.sh b/dev/containers/entrypoint_rpms.sh index 2236c21..52c3e38 100644 --- a/dev/containers/entrypoint_rpms.sh +++ b/dev/containers/entrypoint_rpms.sh @@ -1,9 +1,8 @@ #!/bin/bash -export TIMESTAMP=$(date +%s) \ -&& cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ +cd / \ +&& git clone -b ${BRANCH} ${REPO} /pagure \ && chmod +x /pagure/dev/containers/runtests_py3.sh \ && cd /pagure \ && ln -s /results /pagure/results \ -&& python3 setup.py build 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ -&& dev/containers/runtests_py3.sh 2>&1 | tee -a /results/"$TIMESTAMP"_output.log \ No newline at end of file +&& python3 setup.py build \ +&& dev/containers/runtests_py3.sh \ No newline at end of file diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 29a23c4..9a94a83 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -3,9 +3,11 @@ import argparse import os import subprocess as sp +import time ROOT = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +TIMESTAMP = int(time.time()) def _container_image_exist(container_name, container_type): @@ -18,7 +20,7 @@ def _container_image_exist(container_name, container_type): return _call_command(cmd) -def _build_container(container_name, container_type, container_volume=None, **kwargs): +def _build_container(container_name, container_type, result_path, container_volume=None, **kwargs): # kwargs can be used to pass '--build-arg' build_args = [] for arg in kwargs.values(): @@ -53,12 +55,22 @@ def _build_container(container_name, container_type, container_volume=None, **kw cmd += build_args cmd += volume - return _call_command(cmd) + logfile = "{}/{}_{}-build.log".format(result_path, TIMESTAMP, container_type) + return _call_command(cmd, logfile) -def _call_command(cmd): +def _call_command(cmd, logfile=None): print("Command: " + " ".join(cmd)) - rc = sp.call(cmd) + + if logfile is None: + rc = sp.call(cmd) + else: + # 'tee' like behavior, Kudos: falsetru + # https://stackoverflow.com/a/31583238 + tee = sp.Popen(["tee", logfile], stdin=sp.PIPE) + rc = sp.call(cmd, stdout=tee.stdin, stderr=sp.STDOUT) + tee.stdin.close() + if rc != 0: return False else: @@ -193,7 +205,7 @@ if __name__ == "__main__": # get full path of git repo in current directory and set var to mount it into the container if args.repo == "/wrkdir": - # Kudos: Ryne Everett + # 'git rev-parse --show-toplevel' via python, Kudos: Ryne Everett # https://stackoverflow.com/questions/22081209#comment44778829_22081487 wrkdir_path = sp.Popen(['git', 'rev-parse', '--show-toplevel'], stdout=sp.PIPE).communicate()[0].rstrip().decode('ascii') @@ -214,6 +226,10 @@ if __name__ == "__main__": print("Running for %d containers:" % len(container_names)) print(" - " + "\n - ".join(container_names)) for container_name in container_names: + result_path = "{}/results_{}".format(os.getcwd(), containers[container_name]["name"]) + if not os.path.exists(result_path): + os.mkdir(result_path) + print("\n------ Building Container Image -----") if not _container_image_exist(container_name, "base") or args.rebuild: @@ -221,6 +237,7 @@ if __name__ == "__main__": if _build_container( container_name, "base", + result_path, branch="{}".format(os.environ.get("BRANCH") or args.branch), repo="{}".format(os.environ.get("REPO") or args.repo) ): @@ -237,16 +254,12 @@ if __name__ == "__main__": args.rebuild or \ args.rebuild_code: print("Container does not exist, building: %s" % containers[container_name]["code"]) - if not _build_container(container_name, "code"): + if not _build_container(container_name, "code", result_path): print("Failed building: %s" % containers[container_name]["code"]) break else: print("Container already exist, skipped building: %s" % containers[container_name]["code"]) - result_path = "{}/results_{}".format(os.getcwd(), containers[container_name]["name"]) - if not os.path.exists(result_path): - os.mkdir(result_path) - volumes = [ "-v", "{}:/results:z".format(result_path) @@ -282,7 +295,8 @@ if __name__ == "__main__": "--entrypoint=/bin/bash", containers[container_name]["code"], ] - sp.call(cmd) + logfile = "{}/{}_shell.log".format(result_path, TIMESTAMP) + _call_command(cmd, logfile) else: print("--------- Running Test --------------") cmd = [ @@ -298,7 +312,8 @@ if __name__ == "__main__": cmd += [ containers[container_name]["code"], ] - if not _call_command(cmd): + logfile = "{}/{}_tests.log".format(result_path, TIMESTAMP) + if not _call_command(cmd, logfile): failed.append(container_name) if not args.shell: From a82cc32a352abf73ec8f464318eeab9a30dc1c58 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 13/18] chore(run-tests-container): obsolete param --skip-build removed By default, container will be re-used and not re-created on every test run. This makes '--skip-build' obsolete, to force the build of a new image, '--rebuild' and '--rebuild-code' can be used. Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 9a94a83..78524a0 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -127,12 +127,6 @@ def setup_parser(): help="Run the tests in a venv on a Fedora host", ) parser.add_argument( - "--skip-build", - dest="skip_build", - action="store_false", - help="Skip building the container image", - ) - parser.add_argument( "--rebuild", dest="rebuild", action="store_true", From 2aeb8d57b2c27c8104707fb5c5e3dbc3f3f63fca Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 14/18] chore(run-tests-container): black related formatting changes Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index 78524a0..f33e5b2 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -15,12 +15,14 @@ def _container_image_exist(container_name, container_type): "podman", "image", "exists", - containers[container_name][container_type] + containers[container_name][container_type], ] return _call_command(cmd) +# fmt: off def _build_container(container_name, container_type, result_path, container_volume=None, **kwargs): +# fmt: on # kwargs can be used to pass '--build-arg' build_args = [] for arg in kwargs.values(): @@ -55,7 +57,9 @@ def _build_container(container_name, container_type, result_path, container_volu cmd += build_args cmd += volume - logfile = "{}/{}_{}-build.log".format(result_path, TIMESTAMP, container_type) + logfile = "{}/{}_{}-build.log".format( + result_path, TIMESTAMP, container_type + ) return _call_command(cmd, logfile) @@ -79,19 +83,13 @@ def _call_command(cmd, logfile=None): def _check_pre_reqs(): programs = [ - { - "name": "podman", - "cmd": ["podman", "version"] - }, - { - "name": "git", - "cmd": ["git", "version"] - } + {"name": "podman", "cmd": ["podman", "version"]}, + {"name": "git", "cmd": ["git", "version"]}, ] # 'os.devnull' used for backward compatibility with Python2. # for Py3 only, 'sp.DEVNULL' can be used and this workaround removed. - FNULL = open(os.devnull, 'w') + FNULL = open(os.devnull, "w") missing = [] for program in programs: @@ -106,7 +104,7 @@ def _check_pre_reqs(): def setup_parser(): - """ Setup the cli arguments """ + """Setup the cli arguments""" parser = argparse.ArgumentParser(prog="pagure-test") parser.add_argument( "test_case", nargs="?", default="", help="Run the given test case" @@ -174,18 +172,18 @@ if __name__ == "__main__": "centos": { "name": "pagure-tests-centos-stream8-rpms-py3", "base": "base-centos-stream8-rpms-py3", - "code": "code-centos-stream8-rpms-py3" + "code": "code-centos-stream8-rpms-py3", }, "fedora": { "name": "pagure-tests-fedora-rpms-py3", "base": "base-fedora-rpms-py3", - "code": "code-fedora-rpms-py3" + "code": "code-fedora-rpms-py3", }, "pip": { "name": "pagure-tests-fedora-pip-py3", "base": "base-fedora-pip-py3", - "code": "code-fedora-pip-py3" - } + "code": "code-fedora-pip-py3", + }, } if args.centos: @@ -201,68 +199,89 @@ if __name__ == "__main__": if args.repo == "/wrkdir": # 'git rev-parse --show-toplevel' via python, Kudos: Ryne Everett # https://stackoverflow.com/questions/22081209#comment44778829_22081487 - wrkdir_path = sp.Popen(['git', 'rev-parse', '--show-toplevel'], - stdout=sp.PIPE).communicate()[0].rstrip().decode('ascii') + wrkdir_path = ( + sp.Popen(["git", "rev-parse", "--show-toplevel"], stdout=sp.PIPE) + .communicate()[0] + .rstrip() + .decode("ascii") + ) mount_wrkdir = True # 'args.repo' will be set as path to mount it into the container and then # overridden with '/wrkdir' to leverage existing logic to use a local path - elif 'http://' not in args.repo \ - and 'https://' not in args.repo: + elif "http://" not in args.repo and "https://" not in args.repo: wrkdir_path = args.repo args.repo = "/wrkdir" mount_wrkdir = True if args.branch == "wrkdirbranch": - args.branch = sp.Popen(['git', 'branch', '--show-current'], - stdout=sp.PIPE).communicate()[0].rstrip().decode('ascii') + args.branch = ( + sp.Popen(["git", "branch", "--show-current"], stdout=sp.PIPE) + .communicate()[0] + .rstrip() + .decode("ascii") + ) failed = [] print("Running for %d containers:" % len(container_names)) print(" - " + "\n - ".join(container_names)) for container_name in container_names: - result_path = "{}/results_{}".format(os.getcwd(), containers[container_name]["name"]) + result_path = "{}/results_{}".format( + os.getcwd(), containers[container_name]["name"] + ) if not os.path.exists(result_path): os.mkdir(result_path) print("\n------ Building Container Image -----") if not _container_image_exist(container_name, "base") or args.rebuild: - print("Container does not exist, building: %s" % containers[container_name]["base"]) + print( + "Container does not exist, building: %s" + % containers[container_name]["base"] + ) if _build_container( container_name, "base", result_path, branch="{}".format(os.environ.get("BRANCH") or args.branch), - repo="{}".format(os.environ.get("REPO") or args.repo) + repo="{}".format(os.environ.get("REPO") or args.repo), ): base_build = True else: - print("Failed building: %s" % containers[container_name]["base"]) + print( + "Failed building: %s" % containers[container_name]["base"] + ) break else: base_build = False - print("Container already exist, skipped building: %s" % containers[container_name]["base"]) - - if not _container_image_exist(container_name, "code") or \ - base_build or \ - args.rebuild or \ - args.rebuild_code: - print("Container does not exist, building: %s" % containers[container_name]["code"]) + print( + "Container already exist, skipped building: %s" + % containers[container_name]["base"] + ) + + if ( + not _container_image_exist(container_name, "code") + or base_build + or args.rebuild + or args.rebuild_code + ): + print( + "Container does not exist, building: %s" + % containers[container_name]["code"] + ) if not _build_container(container_name, "code", result_path): - print("Failed building: %s" % containers[container_name]["code"]) + print( + "Failed building: %s" % containers[container_name]["code"] + ) break else: - print("Container already exist, skipped building: %s" % containers[container_name]["code"]) + print( + "Container already exist, skipped building: %s" + % containers[container_name]["code"] + ) - volumes = [ - "-v", - "{}:/results:z".format(result_path) - ] + volumes = ["-v", "{}:/results:z".format(result_path)] if mount_wrkdir: - volumes += [ - "-v", - "{}:/wrkdir:z,ro".format(wrkdir_path) - ] + volumes += ["-v", "{}:/wrkdir:z,ro".format(wrkdir_path)] env_vars = [ "-e", @@ -281,7 +300,7 @@ if __name__ == "__main__": "-it", "--rm", "--name", - containers[container_name]["name"] + containers[container_name]["name"], ] cmd += volumes cmd += env_vars @@ -317,4 +336,4 @@ if __name__ == "__main__": else: print(" %s TESTS FAILED:" % len(failed)) for fail in failed: - print(" - %s" % fail) \ No newline at end of file + print(" - %s" % fail) From 7a7456a40cf831351188504c6a7e2a4257adaafd Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 15/18] docs(README): Changes related to 'run-tests-container' Sections adjusted to reflect changes in features, default behavior and functionality of run-tests-container.py Signed-off-by: Dominik Wombacher --- diff --git a/README.rst b/README.rst index 533ee0b..c2223e6 100644 --- a/README.rst +++ b/README.rst @@ -125,28 +125,29 @@ with the ``LOGGING`` parameter. Running the unit-tests in container *********************************** -To run the unit-tests, there is container available with all the dependencies needed. +To run the unit-tests, there are container available with all the dependencies needed. -First you will need to have podman installed on your workstation. :: +First you will need to have podman and git installed on your workstation. :: - $ sudo dnf install podman + $ sudo dnf install podman git - -Use the following command to run the tests :: +Use the following command to run all tests on all container images, if the images not exist on your system, they will be build :: $ ./dev/run-tests-container.py -This command will build a fedora based container and execute the test suite. - If you wish to execute the test suite on a centos based container run the following command :: $ ./dev/run-tests-container.py --centos -When the test container image has been built you can skip the building step to save time -and run directly the test suite. :: +Container images are separated from the pagure source that will be tested. +Therefore they will only automatically build if they not exist. + +A manual rebuild should be done from time to time to include new package versions. +Also if you work on any changes in the pagure spec file, the tox config or any requirements.txt file, +perform a rebuild to ensure your changed will taken into account. :: - $ ./dev/run-tests-container.py --skip-build - $ ./dev/run-tests-container.py --centos --skip-build + $ ./dev/run-tests-container.py --rebuild # all base and code container + $ ./dev/run-tests-container.py --rebuild-code # code container only You can also run a single test case :: @@ -156,16 +157,18 @@ Or a single test :: $ ./dev/run-tests-container.py tests/test_pagure_flask_ui_priorities.py:PagureFlaskPrioritiestests.test_ticket_with_no_priority -You can also get `run-tests-container` help :: +You can also get ``run-tests-container`` help :: $ ./dev/run-tests-container.py --help -Run the tests on your own development branch in your fork :: +By default, tests run against the git repo and the active branch in the current folder. +To override this behavior and run the tests on your remote development branch in your fork :: $ ./dev/run-tests-container.py --repo https://pagure.io/forks//pagure.git --branch - .. note:: This run could take pretty long to finish and there isn't any useful summary. - So it's better to redirect the output to some file. You can use `tee` for this. + .. note:: All build, test and shell activities executed via ``run-tests-container`` will automatically be logged. + Every container has it's own ``dev/results_`` folder, every run creates separate + files with the current unix timestamp as prefix. You should cleanup this folder from time to time. Running the unit-tests in tox From a54c209df823f7613504906ea2f09b8084d2ed1c Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 16/18] tests(run-tests-container): git trace and curl verbose added Aligned to behavior of old Dockerfiles, 'GIT_TRACE=1 GIT_CURL_VERBOSE=1' added in new entrypoint scripts. Signed-off-by: Dominik Wombacher --- diff --git a/dev/containers/entrypoint_pip.sh b/dev/containers/entrypoint_pip.sh index 92bcbe6..2e89c2e 100644 --- a/dev/containers/entrypoint_pip.sh +++ b/dev/containers/entrypoint_pip.sh @@ -1,6 +1,6 @@ #!/bin/bash cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure \ +&& GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b ${BRANCH} ${REPO} /pagure \ && cp /tox_py3.sh /pagure/dev/containers/tox_py3.sh \ && chmod +x /pagure/dev/containers/tox_py3.sh \ && ln -s /tox /pagure/.tox \ diff --git a/dev/containers/entrypoint_rpms.sh b/dev/containers/entrypoint_rpms.sh index 52c3e38..be549be 100644 --- a/dev/containers/entrypoint_rpms.sh +++ b/dev/containers/entrypoint_rpms.sh @@ -1,6 +1,6 @@ #!/bin/bash cd / \ -&& git clone -b ${BRANCH} ${REPO} /pagure \ +&& GIT_TRACE=1 GIT_CURL_VERBOSE=1 git clone -b ${BRANCH} ${REPO} /pagure \ && chmod +x /pagure/dev/containers/runtests_py3.sh \ && cd /pagure \ && ln -s /results /pagure/results \ From 805b2409fc4548b3c681f61b97ddbe8322584b43 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 17/18] chore(run-tests-container): flask8 findings addressed Signed-off-by: Dominik Wombacher --- diff --git a/dev/run-tests-container.py b/dev/run-tests-container.py index f33e5b2..34b3f66 100755 --- a/dev/run-tests-container.py +++ b/dev/run-tests-container.py @@ -21,8 +21,9 @@ def _container_image_exist(container_name, container_type): # fmt: off -def _build_container(container_name, container_type, result_path, container_volume=None, **kwargs): -# fmt: on +def _build_container(container_name, container_type, result_path, + container_volume=None, **kwargs): + # fmt: on # kwargs can be used to pass '--build-arg' build_args = [] for arg in kwargs.values(): @@ -148,15 +149,18 @@ def setup_parser(): "--repo", dest="repo", default="/wrkdir", - help="URL or local path to git repository as source of the public repo to use as source, " - "defaults to git repo in current directory, can also be overridden using the REPO environment variable", + help="URL or local path to git repository as source of the " + "public repo to use as source, defaults to git repo in " + "current directory, can also be overridden using the " + "REPO environment variable", ) parser.add_argument( "--branch", dest="branch", default="wrkdirbranch", - help="Branch name to use as source, defaults to the active branch in current directory, " - "can also be overridden by using the BRANCH environment variable", + help="Branch name to use as source, defaults to the active " + "branch in current directory, can also be overridden by " + "using the BRANCH environment variable", ) return parser @@ -195,7 +199,8 @@ if __name__ == "__main__": else: container_names = ["centos", "fedora", "pip"] - # get full path of git repo in current directory and set var to mount it into the container + # get full path of git repo in current directory + # and set var to mount it into the container if args.repo == "/wrkdir": # 'git rev-parse --show-toplevel' via python, Kudos: Ryne Everett # https://stackoverflow.com/questions/22081209#comment44778829_22081487 From 606c9de2e0fbef542d65c1384d2f4a673a252110 Mon Sep 17 00:00:00 2001 From: Dominik Wombacher Date: Apr 17 2023 19:31:51 +0000 Subject: [PATCH 18/18] docs(README): minor typo corrected Signed-off-by: Dominik Wombacher --- diff --git a/README.rst b/README.rst index c2223e6..58a3acc 100644 --- a/README.rst +++ b/README.rst @@ -125,7 +125,7 @@ with the ``LOGGING`` parameter. Running the unit-tests in container *********************************** -To run the unit-tests, there are container available with all the dependencies needed. +To run the unit-tests, there are containers available with all the dependencies needed. First you will need to have podman and git installed on your workstation. ::