From db519e0e41d5bf8671f65af992fb24a4b8a769ce Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Fri, 4 Nov 2022 11:31:14 +1100
Subject: [PATCH] ensure-pip: use dummy package for testing

This currently uses zuul-client to test installation.  Unfortunately
for the testing the recent release dropped support for older pythons
we still need to test with.

To avoid this, make a dummy package that we include in zuul-jobs that
does nothing, but will also install anywhere.

Change-Id: Ia1beed2b21f39db4e2ab75258425d7897238ecf6
---
 test-playbooks/ensure-pip-localhost.yaml      |  4 +--
 test-playbooks/ensure-pip.yaml                |  4 +--
 tools/dummy-package/README.rst                |  1 +
 tools/dummy-package/dummy_package/__init__.py |  2 ++
 tools/dummy-package/setup.cfg                 | 32 +++++++++++++++++++
 tools/dummy-package/setup.py                  |  3 ++
 zuul-tests.d/python-jobs.yaml                 |  3 --
 7 files changed, 42 insertions(+), 7 deletions(-)
 create mode 100644 tools/dummy-package/README.rst
 create mode 100644 tools/dummy-package/dummy_package/__init__.py
 create mode 100644 tools/dummy-package/setup.cfg
 create mode 100644 tools/dummy-package/setup.py

diff --git a/test-playbooks/ensure-pip-localhost.yaml b/test-playbooks/ensure-pip-localhost.yaml
index 54bff4984..66e57940d 100644
--- a/test-playbooks/ensure-pip-localhost.yaml
+++ b/test-playbooks/ensure-pip-localhost.yaml
@@ -28,13 +28,13 @@
 
     - name: Sanity check pip wheel generation
       shell: |
-        cd {{ ansible_user_dir }}/src/opendev.org/zuul/zuul-client
+        cd {{ ansible_user_dir }}/src/opendev.org/zuul/zuul-jobs/tools/dummy-package
         # This should run anywhere without too much logic ...
         run_pip=$(command -v pip3 || command -v pip2 || command -v pip)
         # Preinstall pbr to work around very old distutils lacking SNI support
         $run_pip install pbr
         $run_pip wheel --no-deps .
-        ls zuul_client-*.whl || exit 1
+        ls dummy_package*.whl || exit 1
 
     - name: Test virtualenv
       # NOTE(ianw) 2022-02-03 : not supported on 9-stream, see inline comments
diff --git a/test-playbooks/ensure-pip.yaml b/test-playbooks/ensure-pip.yaml
index 75d0f170f..6c24a350a 100644
--- a/test-playbooks/ensure-pip.yaml
+++ b/test-playbooks/ensure-pip.yaml
@@ -28,13 +28,13 @@
 
     - name: Sanity check pip wheel generation
       shell: |
-        cd {{ ansible_user_dir }}/src/opendev.org/zuul/zuul-client
+        cd {{ ansible_user_dir }}/src/opendev.org/zuul/zuul-jobs/tools/dummy-package
         # This should run anywhere without too much logic ...
         run_pip=$(command -v pip3 || command -v pip2 || command -v pip)
         # Preinstall pbr to work around very old distutils lacking SNI support
         $run_pip install pbr
         $run_pip wheel --no-deps .
-        ls zuul_client-*.whl || exit 1
+        ls dummy_package*.whl || exit 1
 
     - name: Test virtualenv
       # NOTE(ianw) 2022-02-03 : not supported on 9-stream, see inline comments
diff --git a/tools/dummy-package/README.rst b/tools/dummy-package/README.rst
new file mode 100644
index 000000000..ea1e288e7
--- /dev/null
+++ b/tools/dummy-package/README.rst
@@ -0,0 +1 @@
+This is a dummy package to testing building wheels
diff --git a/tools/dummy-package/dummy_package/__init__.py b/tools/dummy-package/dummy_package/__init__.py
new file mode 100644
index 000000000..27f4cb6d9
--- /dev/null
+++ b/tools/dummy-package/dummy_package/__init__.py
@@ -0,0 +1,2 @@
+def console():
+    print("DUMMY PACKAGE")
diff --git a/tools/dummy-package/setup.cfg b/tools/dummy-package/setup.cfg
new file mode 100644
index 000000000..5bdcb11a1
--- /dev/null
+++ b/tools/dummy-package/setup.cfg
@@ -0,0 +1,32 @@
+[metadata]
+name = dummy-package
+version = 0.0.1
+summary = Dummy Package
+description-file =
+    README.rst
+author = OpenStack Infrastructure Team
+author-email = openstack-infra@lists.openstack.org
+home-page = http://docs.opendev.org/infra/system-config/
+classifier =
+    Intended Audience :: Information Technology
+    Intended Audience :: System Administrators
+    License :: OSI Approved :: Apache Software License
+    Operating System :: POSIX :: Linux
+    Programming Language :: Python
+    Programming Language :: Python :: 2
+    Programming Language :: Python :: 2.7
+    Programming Language :: Python :: 2.6
+    Programming Language :: Python :: 3.6
+    Programming Language :: Python :: 3.7
+    Programming Language :: Python :: 3.8
+    Programming Language :: Python :: 3.9
+    Programming Language :: Python :: 3.10
+    Programming Language :: Python :: 3.11
+
+[files]
+  packages =
+    dummy_package
+
+[entry_points]
+console_scripts =
+    dummy-package = dummy_package:console
diff --git a/tools/dummy-package/setup.py b/tools/dummy-package/setup.py
new file mode 100644
index 000000000..b908cbe55
--- /dev/null
+++ b/tools/dummy-package/setup.py
@@ -0,0 +1,3 @@
+import setuptools
+
+setuptools.setup()
diff --git a/zuul-tests.d/python-jobs.yaml b/zuul-tests.d/python-jobs.yaml
index b87b692f9..d289c40d1 100644
--- a/zuul-tests.d/python-jobs.yaml
+++ b/zuul-tests.d/python-jobs.yaml
@@ -1,9 +1,6 @@
 - job:
     name: zuul-jobs-test-ensure-pip
     description: Test the ensure-pip role
-    # dummy project for wheel build test
-    required-projects:
-      - zuul/zuul-client
     files:
       - roles/ensure-pip/.*
       - roles/ensure-virtualenv/.*