From 7a51ac872e2db30d70f1d13b6b1cf5494f59dd47 Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Aug 04 2021 11:04:51 +0000
Subject: [PATCH 1/2] Fix rpmbuild and rpmlint warnings


---

diff --git a/docs/conf.py b/docs/conf.py
index 41ea38c..3a27374 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -148,6 +148,8 @@ latex_documents = [
 # One entry per manual page. List of tuples
 # (source start file, name, description, authors, manual section).
 man_pages = [
+    ('waiverdb', 'waiverdb', u'WaiverDB Server',
+     [author], 1),
     ('waiverdb-cli', 'waiverdb-cli', u'WaiverDB Client',
      [author], 1),
     ('client-conf', 'client.conf', u'waiverdb-cli configuration file',
diff --git a/docs/index.rst b/docs/index.rst
index 94f07d8..f22c9c0 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -11,6 +11,7 @@ test results.
    user-guide
    api
    waiverdb-cli
+   waiverdb
    client-conf
    developer-guide
    admin-guide
diff --git a/docs/waiverdb.rst b/docs/waiverdb.rst
new file mode 100644
index 0000000..2e8da4a
--- /dev/null
+++ b/docs/waiverdb.rst
@@ -0,0 +1,22 @@
+.. _waiverdb:
+
+========
+waiverdb
+========
+
+Synopsis
+========
+
+``waiverdb [OPTIONS]``
+
+Description
+===========
+
+**waiverdb** is CLI tool managing WaiverDB server application.
+
+Options
+=======
+
+.. option:: wait_for_db
+
+    Wait until database server is reachable.
diff --git a/rpmbuild.sh b/rpmbuild.sh
index b94210f..a5ca3d7 100755
--- a/rpmbuild.sh
+++ b/rpmbuild.sh
@@ -19,7 +19,10 @@ source "$HERE"/version.sh
 
 name=waiverdb
 workdir="$(mktemp -d)"
-trap "rm -rf $workdir" EXIT
+cleanup() {
+    rm -rf "$workdir"
+}
+trap cleanup EXIT
 outdir="$(readlink -f ./rpmbuild-output)"
 mkdir -p "$outdir"
 
@@ -29,11 +32,11 @@ if [ -n "$WAIVERDB_RPM_RELEASE" ] ; then
     sed --regexp-extended --in-place \
         -e "/^Version:/cVersion: ${WAIVERDB_RPM_VERSION}" \
         -e "/^Release:/cRelease: ${WAIVERDB_RPM_RELEASE}%{?dist}" \
-        -e "/^Source0:/cSource0: waiverdb-${WAIVERDB_RPM_VERSION}.${WAIVERDB_RPM_RELEASE}.tar.gz" \
+        -e "/^Source0:/cSource0: waiverdb-${WAIVERDB_RPM_VERSION}.tar.gz" \
         "$workdir/${name}.spec"
     # also hack the Python module version
     sed --regexp-extended --in-place \
-        -e "/^__version__ = /c\\__version__ = '$WAIVERDB_VERSION'" \
+        -e "/^__version__ = /c\\__version__ = '$WAIVERDB_RPM_VERSION'" \
         "$workdir/waiverdb/__init__.py"
 fi
 ( cd "$workdir" && python3 setup.py sdist )
diff --git a/version.sh b/version.sh
index 99c4ac7..28e33a0 100644
--- a/version.sh
+++ b/version.sh
@@ -17,7 +17,7 @@ else
     commitcount=$(git rev-list "$revbase" HEAD | wc -l)
 fi
 
-if [ "$(git rev-list "$revbase" HEAD | wc -l)" -eq 0 ] ; then
+if [ "$commitcount" -eq 0 ] ; then
     # building a tag
     rpmver=""
     rpmrel=""
diff --git a/waiverdb.spec b/waiverdb.spec
index 83dae17..2fcac09 100644
--- a/waiverdb.spec
+++ b/waiverdb.spec
@@ -64,11 +64,11 @@ WaiverDB is a companion service to ResultsDB, for recording waivers
 against test results.
 
 %package common
-Summary: Common resources for WaiverDB subpackages.
+Summary: Common resources for WaiverDB sub-packages
 
 %description common
 This package is not useful on its own.  It contains common filesystem resources
-for other WaiverDB subpackages.
+for other WaiverDB sub-packages.
 
 %package cli
 Summary: A CLI tool for interacting with waiverdb
@@ -82,7 +82,7 @@ Requires:       waiverdb-common = %{version}-%{release}
 %description cli
 This package contains a CLI tool for interacting with waiverdb.
 
-Primarily, submitting new waiverdbs.
+Primarily, submitting new waivers.
 
 %prep
 %setup -q -n %{name}-%{version}
@@ -98,6 +98,7 @@ sed -i 's/\.stg\.fedoraproject\.org/.fedoraproject.org/g' conf/client.conf.examp
 %py3_build
 %if %{with docs}
 make -C docs html man text
+rm -rf docs/_build/html/.buildinfo
 %endif
 
 %install
@@ -120,6 +121,10 @@ install -D -m0644 \
     %{buildroot}%{_mandir}/man1/waiverdb-cli.1
 
 install -D -m0644 \
+    docs/_build/man/waiverdb.1 \
+    %{buildroot}%{_mandir}/man1/waiverdb.1
+
+install -D -m0644 \
     docs/_build/man/client.conf.5 \
     %{buildroot}%{_mandir}/man5/waiverdb-client.conf.5
 
@@ -141,6 +146,10 @@ install -D -m0644 \
 %exclude %{python3_sitelib}/%{name}/cli.py
 %exclude %{python3_sitelib}/%{name}/__pycache__/cli.*.pyc
 %attr(755,root,root) %{_bindir}/waiverdb
+
+%if %{with docs}
+%{_mandir}/man1/waiverdb.1*
+%endif
 %endif
 
 %files common

From e8868807a47bc666b0493921d4da745f01ee5344 Mon Sep 17 00:00:00 2001
From: Lukas Holecek <hluk@email.cz>
Date: Aug 04 2021 11:45:35 +0000
Subject: [PATCH 2/2] Drop broken and unused OpenShift template parameter


The value type for replicas property should be integer, not string.

---

diff --git a/openshift/pipelines/snippets/waiverdb-build-and-test.groovy b/openshift/pipelines/snippets/waiverdb-build-and-test.groovy
index 969698e..3369b44 100644
--- a/openshift/pipelines/snippets/waiverdb-build-and-test.groovy
+++ b/openshift/pipelines/snippets/waiverdb-build-and-test.groovy
@@ -150,12 +150,10 @@ stage("Functional tests phase") {
               // Don't set ENVIRONMENT_LABEL in the environment block! Otherwise you will get 2 different UUIDs.
               env.ENVIRONMENT_LABEL = "test-${env.TEST_ID}"
               def template = readYaml file: 'openshift/waiverdb-test-template.yaml'
-              def webPodReplicas = 1 // The current quota in UpShift is agressively limited
               echo "Creating testing environment with TEST_ID=${env.TEST_ID}..."
               def models = openshift.process(template,
                 '-p', "TEST_ID=${env.TEST_ID}",
                 '-p', "WAIVERDB_APP_IMAGE=${env.IMAGE}",
-                '-p', "WAIVERDB_REPLICAS=${webPodReplicas}",
               )
               c3i.deployAndWait(script: this, objs: models, timeout: 15)
               def appPod = openshift.selector('pods', ['environment': env.ENVIRONMENT_LABEL, 'service': 'web']).object()
diff --git a/openshift/waiverdb-test-template.yaml b/openshift/waiverdb-test-template.yaml
index 1627b3e..1da09e8 100644
--- a/openshift/waiverdb-test-template.yaml
+++ b/openshift/waiverdb-test-template.yaml
@@ -37,11 +37,6 @@ parameters:
   description: ResultsDB URL in which to pull results against
   required: true
   value: https://resultsdb-api.engineering.redhat.com/api/v2.0
-- name: WAIVERDB_REPLICAS
-  displayName: WaiverDB-web Replicas
-  description: Number of replicas to deploy for the web frontend
-  required: true
-  value: "2"
 objects:
 - apiVersion: v1
   kind: Secret
@@ -194,7 +189,7 @@ objects:
       app: waiverdb
       service: web
   spec:
-    replicas: ${WAIVERDB_REPLICAS}
+    replicas: 1
     selector:
       environment: "test-${TEST_ID}"
       app: waiverdb

