[PATCH] scripts/validate-minimum-dependency-versions: new maintainer script
Mads Kiilerich
mads at kiilerich.com
Tue Mar 26 02:33:25 UTC 2019
On 3/25/19 9:41 PM, Thomas De Schampheleire wrote:
> # HG changeset patch
> # User Thomas De Schampheleire <thomas.de_schampheleire at nokia.com>
> # Date 1553546343 -3600
> # Mon Mar 25 21:39:03 2019 +0100
> # Node ID 3dc609012611ce169b997c40ccad8f4e06fbb792
> # Parent a031ce26b19133ecd5c96e85121656bfd760a78b
> scripts/validate-minimum-dependency-versions: new maintainer script
(I guess it would be more release-note-tool-friendly to use "scripts:
new validate-minimum-dependency-versions maintainer script")
>
> Automate what we can.
>
> This script could be added later to an encompassing script
> 'prepare-for-release' (which would also do other release-related steps).
>
> diff --git a/scripts/validate-minimum-dependency-versions b/scripts/validate-minimum-dependency-versions
> new file mode 100755
> --- /dev/null
> +++ b/scripts/validate-minimum-dependency-versions
> @@ -0,0 +1,49 @@
> +#!/usr/bin/env bash
> +# Test that installation of all dependencies works fine if versions are set to
> +# the minimum ones.
> +
> +set -e
> +
> +if [ -n "$VIRTUAL_ENV" ]; then
> + echo "Please run this script from outside a virtualenv."
> + exit 1
> +fi
> +
> +if ! hg update --check -q .; then
> + echo "Working dir is not clean, please commit/revert changes first."
> + exit 1
> +fi
> +
> +venv=$(mktemp -d kallithea-minimum-dependency-versions-env-XXXXXX)
> +log=$(mktemp kallithea-minimum-dependency-versions-log-XXXXXX)
> +
> +cleanup()
> +{
> + echo "Cleaning up..."
> + rm -rf "$venv" "$log"
> + hg revert -a
> +}
> +trap cleanup EXIT
If there are any problems from a script like this, I would almost rather
just have it leave things as they are so I can debug it ...
> +
> +# Set minimum versions
> +sed -i 's/>=/==/' setup.py dev_requirements.txt
> +
> +virtualenv -p "$(command -v python2)" "$venv"
> +source "$venv/bin/activate"
> +pip install --upgrade pip setuptools
> +
> +pip install -e . -r dev_requirements.txt python-ldap python-pam 2>"$log"
That redirection can be very annoying. I experienced that it fail with a
"out of disk space" error ... which wasn't shown. But I guess that will
be rare ...
> +
> +# Treat any message on stderr as a problem, for the caller to interpret.
> +# This includes the Python 2.7 deprecation message.
We will have to skip that message. We are aware of that message, and we
don't want verification to fail because of that.
> +if [ -s "$log" ]; then
> + echo
> + echo "Error: pip detected following problems:"
> + cat "$log"
> + echo
> + exit 1
> +fi
> +
> +echo "Installation successful. Cleaning up..."
> +
> +cleanup
I would expect the tool to leave a virtualenv that can be used for
running the test suite and for manual testing, to verify that the
minimum versions actually work.
Anyway, if the script works for you, then fine with me.
/Mads
More information about the kallithea-general
mailing list