-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathdevtools.cmd
More file actions
98 lines (84 loc) · 2.38 KB
/
devtools.cmd
File metadata and controls
98 lines (84 loc) · 2.38 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
@echo off
set option=%1
if "%option%"=="-h" goto usage
if "%option%"=="--help" goto usage
REM Support single-letter options
if "%option%"=="-s" set option=--score
if "%option%"=="-c" set option=--check
if "%option%"=="-r" set option=--reformat
if "%option%"=="-t" set option=--test
if "%option%"=="-a" set option=--all
set poetry_cmd=poetry run
if "%option%"=="--score" (
echo Scoring code...
call :check_maintainability_and_complexity
goto :eof
)
if "%option%"=="--check" (
echo Checking code...
call :check_types_and_conventions
goto :eof
)
if "%option%"=="--reformat" (
echo Reformatting code...
call :reformat
goto :eof
)
if "%option%"=="--test" (
echo Running all unit tests...
call :run_tests
goto :eof
)
if "%option%"=="--all" (
echo Reformatting code...
call :reformat
echo Checking code...
call :check_types_and_conventions
call :check_maintainability_and_complexity
echo Testing code...
call :run_tests
goto :eof
)
echo Done, I'm signing off now!
call :usage
goto :eof
:reformat
echo isort sorting your imports (does not remove non-required ones):
%poetry_cmd% isort .\src\
echo reformatting your code with black:
%poetry_cmd% black .\src\
goto :eof
:check_types_and_conventions
echo mypy results (type checking):
%poetry_cmd% mypy .\src\
echo pylint results (are there any violated conventions):
%poetry_cmd% pylint .\src\
goto :eof
:check_maintainability_and_complexity
echo maintainability as given by radon (score as number and Rank as letter)
%poetry_cmd% radon mi .
echo cyclomatic complexity as given by radon (score as number and Rank as letter)
%poetry_cmd% radon cc .
goto :eof
:run_tests
echo Running all unit tests...
set PYTHONPATH=.\src
%poetry_cmd% python -m unittest discover -s hackthetrack_tests
goto :eof
:usage
echo.
echo POOR MANS BUILD PIPELINE
echo "for python>=3.10 projects where Poetry is available"
echo your code should reside in .\src
echo .
echo Usage: script.cmd [OPTION]
echo.
echo Options:
echo --check, -c Check code
echo --reformat, -r Reformat code
echo --score, -s Score code
echo --test, -t Run tests
echo --all, -a Execute --reformat, --check, --score, and --test
echo -h, --help Display this help message
echo.
goto :eof