~canonical-platform-qa/snappy-ecosystem-tests/fixing_ci

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
59
60
61
62
63
64
65
66
67
68
69
#!/bin/bash
RED='\033[0;31m'
GREEN='\033[0;32m'

case "${1:-all}" in
    --all)
        STATIC=1
        UNIT=1
        ;;
    --static)
        STATIC=1
        ;;
    --unit)
        UNIT=1
        ;;
    *)
        echo "Wrong flag ${1}. To run a single suite use --static, --unit"
        exit 1
esac

if [ "$STATIC" = 1 ]; then 
    virtualenv -p python3 ve_pylint
    . ve_pylint/bin/activate

    proxy=$2
    if [ "$proxy" ]; then
        echo "Using proxy: $proxy to install dependencies"
        pip install --proxy $proxy pylint
        pip install --proxy $proxy -r requirements.txt
    else
        pip install pylint
        pip install -r requirements.txt
    fi

    ve_pylint/bin/python3 -m pylint snappy_ecosystem_tests --reports=n --rcfile=pylint.cfg > pylint-results.txt

    result=$?
    if [ $result != 0 ]; then
        echo -e -n "${RED}Pylint errors. Check pylint output for more information\n"
        exit 1; 
    else
        echo -e -n "${GREEN}Congratulations!!! Static check PASSED\n"
    fi
    deactivate
fi

if [ "$UNIT" = 1 ]; then
    virtualenv -p python3 ve_unit_tests
    . ve_unit_tests/bin/activate

    if [ "$proxy" ]; then
        echo "Using proxy: $proxy to install dependencies"
        pip install --proxy $proxy -r requirements-unit-tests.txt
    else
        pip install -r requirements-unit-tests.txt
    fi

    ve_unit_tests/bin/python3 -m unittest discover snappy_ecosystem_tests.unittests 

    result=$?
    deactivate

    if [ $result != 0 ]; then
        echo -e -n "${RED}Unit tests failed.\n"
        exit 1;
    else
        echo -e -n "${GREEN}Congratulations!!! Unit tests PASSED\n"
    fi
fi