aboutsummaryrefslogtreecommitdiff
path: root/dev/ci.py
blob: 59dd0738716b502bf69ad77b26cfdbf8927f0871 (plain)
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
# coding: utf-8
from __future__ import unicode_literals, division, absolute_import, print_function

import os
import site
import sys

from . import build_root, requires_oscrypto
from ._import import _preload


deps_dir = os.path.join(build_root, 'modularcrypto-deps')
if os.path.exists(deps_dir):
    site.addsitedir(deps_dir)

if sys.version_info[0:2] not in [(2, 6), (3, 2)]:
    from .lint import run as run_lint
else:
    run_lint = None

if sys.version_info[0:2] != (3, 2):
    from .coverage import run as run_coverage
    run_tests = None

else:
    from .tests import run as run_tests
    run_coverage = None


def run():
    """
    Runs the linter and tests

    :return:
        A bool - if the linter and tests ran successfully
    """

    _preload(requires_oscrypto, True)

    if run_lint:
        print('')
        lint_result = run_lint()
    else:
        lint_result = True

    if run_coverage:
        print('\nRunning tests (via coverage.py)')
        sys.stdout.flush()
        tests_result = run_coverage(ci=True)
    else:
        print('\nRunning tests')
        sys.stdout.flush()
        tests_result = run_tests(ci=True)
    sys.stdout.flush()

    return lint_result and tests_result