aboutsummaryrefslogtreecommitdiff
path: root/src_doit/__init__.py
blob: e2999f2749d653a55396956f7dd5469c720289c8 (plain) (blame)
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
from pathlib import Path
import subprocess
import sys

from . import common

from .js import *  # NOQA
from .py import *  # NOQA
from . import js
from . import py


__all__ = ['task_clean_all',
           'task_build',
           'task_test',
           *js.__all__,
           *py.__all__]


build_dir = Path('build')
pytest_dir = Path('test_pytest')


def task_clean_all():
    """Clean all"""
    return {'actions': [(common.rm_rf, [build_dir,
                                        js.dst_dir,
                                        py.json_schema_repo_path])]}


def task_build():
    """Build"""

    def build():
        subprocess.run([sys.executable, 'setup.py', '-q', 'bdist_wheel'],
                       cwd=str(build_dir),
                       check=True)

    return {'actions': [build],
            'task_dep': ['py_build']}


def task_test():
    """Test"""

    def run(args):
        js.dst_dir.mkdir(parents=True, exist_ok=True)
        subprocess.run([sys.executable, '-m', 'pytest',
                        '-s', '-p', 'no:cacheprovider',
                        *(args or [])],
                       cwd=str(pytest_dir),
                       check=True)

    return {'actions': [run],
            'pos_arg': 'args',
            'task_dep': ['py_json_schema_repo']}