CI: Add pip-upgrade tests

Related: rhbz#1932713
This commit is contained in:
Miro Hrončok 2021-08-16 13:00:49 +02:00 committed by Charalampos Stratakis
parent e9e8996aeb
commit 75ed7533ad
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,40 @@
#!/bin/sh -eux
# This script requires root privileges and you should never run it on your own machine
test $EUID -eq 0
PYTHON_VERSION=$(/usr/bin/python3 -c 'import sys; print("{}.{}".format(*sys.version_info))')
RPM_SITELIB="/usr/lib/python${PYTHON_VERSION}/site-packages"
LOCAL_SITELIB="/usr/local/lib/python${PYTHON_VERSION}/site-packages"
USER_SITELIB="/home/fedora-test-user/.local/lib/python${PYTHON_VERSION}/site-packages"
# First, let's install older Pello with pip as if it was installed by RPM
# This is an approximation, but it usually works
RPM_BUILD_ROOT=/ /usr/bin/pip install 'Pello==1.0.1'
# Now, we'll upgrade it with regular pip
/usr/bin/pip install --upgrade 'Pello==1.0.2'
# pip should see it
/usr/bin/pip freeze | grep '^Pello==1\.0\.2$'
# Both installations should still exist
test -d "${RPM_SITELIB}/Pello-1.0.1-py${PYTHON_VERSION}.egg-info" || test -d "${RPM_SITELIB}/Pello-1.0.1.dist-info"
test -d "${LOCAL_SITELIB}/Pello-1.0.2.dist-info"
# Let's ditch the local one
/usr/bin/pip uninstall --yes Pello
# It should only remove one of them
test -d "${RPM_SITELIB}/Pello-1.0.1-py${PYTHON_VERSION}.egg-info" || test -d "${RPM_SITELIB}/Pello-1.0.1.dist-info"
! test -d "${LOCAL_SITELIB}/Pello-1.0.2.dist-info"
# And pip should still see the RPM-installed one
/usr/bin/pip freeze | grep '^Pello==1\.0\.1$'
# Again, but as regular user
useradd fedora-test-user
su fedora-test-user -c '/usr/bin/pip install "Pello==1.0.2"'
test -d "${USER_SITELIB}/Pello-1.0.2.dist-info"
su fedora-test-user -c '/usr/bin/pip freeze' | grep '^Pello==1\.0\.2$'
su fedora-test-user -c '/usr/bin/pip uninstall --yes Pello'
su fedora-test-user -c '/usr/bin/pip freeze' | grep '^Pello==1\.0\.1$'

View File

@ -69,6 +69,7 @@
- pyproject_clikit: - pyproject_clikit:
dir: pyproject-rpm-macros/tests dir: pyproject-rpm-macros/tests
run: ./mocktest.sh python-clikit run: ./mocktest.sh python-clikit
- pip_install_upgrade
required_packages: required_packages:
- gcc - gcc
- virtualenv - virtualenv
@ -86,3 +87,6 @@
- mock - mock
- rpmdevtools - rpmdevtools
- rpm-build - rpm-build
- grep
- util-linux
- shadow-utils