File: test.sh

package info (click to toggle)
python-hacking 4.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 380 kB
  • sloc: python: 1,503; sh: 38; makefile: 23
file content (58 lines) | stat: -rwxr-xr-x 1,135 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

# Usage: test.sh openstack keystone path-to-repo
# path-to-repo is an optional parameter, if it exists
# no cloning will happen and the local directory will be used,
# the first two parameter get ignored.
# Note: you can clone from a local file with REPO_ROOT=file:////~/path/to/repo

set -x
set -e

REPO_ROOT=${REPO_ROOT:-https://git.openstack.org}
HACKING="$(pwd)"

if [[ $# -lt 2 ]] ; then
    echo "Script needs at least two arguments:"
    echo "$0 organization name [path-to-repo]"
    exit 1
fi
org=$1
project=$2

if [[ $# -eq 3 ]] ; then
    projectdir=$3
    clone=0
else
    projectdir=$project
    clone=1
fi

if [ "$clone" = "1" ] ; then

    tempdir="$(mktemp -d)"

    trap "rm -rf $tempdir" EXIT
    pushd $tempdir
    git clone $REPO_ROOT/$org/$project --depth=1
fi

pushd $projectdir
set +e

# Install project with test-requirements so that hacking's
# local-check-factory works
pip install -r test-requirements.txt
pip install .
# Reinstall hacking, the above might have uninstalled it
pip install $HACKING

flake8 --select H --statistics
RET=$?
popd

if [ "$clone" = "1" ] ; then
    popd
fi

exit $RET