From ac415ff515fccc8a18459768dbf8ef234d03828d Mon Sep 17 00:00:00 2001
From: Jiri Podivin <jpodivin@redhat.com>
Date: Tue, 11 May 2021 13:37:52 +0200
Subject: [PATCH] Reqcheck job for upstream validations-libs

Zuul job queries the requirements.txt and the relevant
spec file using the `rdopkg reqcheck` to find discrepancies
in the listed dependencies.

Just like the original `rdopkg-reqcheck` this job is non-voting.

Depends-On: I18a2249eec77b0b7adc3a14eed530760598f972e

Signed-off-by: Jiri Podivin <jpodivin@redhat.com>
Change-Id: I6fad1cc93e9a89cba857691dffcec5d794e69333
---
 .reqcheck_override.yaml |  6 ++++++
 .zuul.yaml              | 13 ++++++++++++
 playbooks/reqcheck.yaml | 46 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+)
 create mode 100644 .reqcheck_override.yaml
 create mode 100644 playbooks/reqcheck.yaml

diff --git a/.reqcheck_override.yaml b/.reqcheck_override.yaml
new file mode 100644
index 00000000..0c16caf6
--- /dev/null
+++ b/.reqcheck_override.yaml
@@ -0,0 +1,6 @@
+---
+packages:
+  all:
+    - name: "python-yaml"
+    - name: "python-PyYAML"
+    - name: "PyYAML"
diff --git a/.zuul.yaml b/.zuul.yaml
index bfdd27b4..37a612c9 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -15,6 +15,18 @@
       - ^doc/.*$
       - ^releasenotes/.*$
 
+- job:
+    name: validations-libs-reqcheck
+    nodeset: centos-8
+    parent: base
+    run: playbooks/reqcheck.yaml
+    timeout: 1600
+    voting: false
+    required-projects:
+      - openstack/validations-libs
+    files:
+      - ^requirements.txt$
+
 - job:
     name: tripleo-ci-centos-8-standalone-validation-libs
     parent: tripleo-ci-centos-8-standalone
@@ -29,6 +41,7 @@
       - check-requirements
     check:
       jobs:
+        - validations-libs-reqcheck
         - openstack-tox-linters
         - openstack-tox-cover
         - openstack-tox-py36
diff --git a/playbooks/reqcheck.yaml b/playbooks/reqcheck.yaml
new file mode 100644
index 00000000..1c0d447b
--- /dev/null
+++ b/playbooks/reqcheck.yaml
@@ -0,0 +1,46 @@
+---
+- hosts: all
+  name: validations-libs-reqcheck
+  vars:
+    req_check_override: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}/.reqcheck_override.yaml"
+  tasks:
+
+    - name: Install rdopkg
+      changed_when: true
+      shell:
+        cmd: |
+          set -e
+          # Need to inherit system-site-packages for python-yum
+          sudo dnf install -y python3-virtualenv
+          virtualenv --system-site-packages {{ ansible_user_dir }}/.venv
+          source {{ ansible_user_dir }}/.venv/bin/activate
+          git clone https://github.com/softwarefactory-project/rdopkg.git
+          cd rdopkg
+          pip install .
+      args:
+        chdir: "{{ ansible_user_dir }}"
+
+    - name: Get distgit project info
+      changed_when: true
+      shell:
+        cmd: |
+          set -e
+          source {{ ansible_user_dir }}/.venv/bin/activate
+          rdopkg findpkg {{ zuul.project.name }} | sed -n "/^distgit/ s/distgit. \(.*\)/\1/p"
+      register: distgit
+      args:
+        chdir: "{{ ansible_user_dir }}"
+
+    - name: Clone distgit and reqcheck {{ zuul.project.name }} with rdopkg
+      changed_when: true
+      shell:
+        cmd: |
+          set -e
+          source {{ ansible_user_dir }}/.venv/bin/activate
+          git clone {{ distgit.stdout }}
+          cd validations-libs-distgit
+          git remote add upstream {{ ansible_user_dir }}/{{ zuul.project.src_dir }}
+          git fetch upstream
+          rdopkg reqcheck --strict --override {{ req_check_override }}
+      args:
+        chdir: "{{ ansible_user_dir }}"