forked from artyl/mbplugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.bat
169 lines (148 loc) · 4.33 KB
/
build.bat
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
@echo OFF
@REM clean:
@REM git clean -fXd
set "ptime= "
where ptime >nul 2>&1
if %errorlevel%==0 set ptime=ptime
if NOT "%1"=="" goto %1
ECHO RUN build clean/test/build/fixup
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ test
:coverage
cd /D "%~dp0"
call python\python -m coverage run -m pytest tests %2 %3 %4 %5 %6 %7 %8 %9
echo coverage html
call python\python -m coverage html
@rem call start htmlcov\index.html
echo %errorlevel%
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ test
:test
cd /D "%~dp0"
call python\python -m pip install -r docker\requirements_pytest.txt
call python\python -m pytest tests %2 %3 %4 %5 %6 %7 %8 %9
echo %errorlevel%
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ fixup
:fixup
cd /D "%~dp0\plugin"
@REM Fix docker playwright container version by playwright in python lib
..\python\python -c "import util;util.mbplugin_dockerfile_version()"
@REM Fix mbplugin_ini.md by setting.py
..\python\python -c "import util;util.mbplugin_ini_md_gen()"
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ run
:run
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ clean
:clean
cd /D "%~dp0"
if NOT EXIST ..\mbplugin\store\git-clear-protected (git clean -fXd) ELSE echo git-clear-protected
if exist ..\mbplugin\dist rd ..\mbplugin\dist /S /Q
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ build
:build
cd /D "%~dp0"
if not exist dist mkdir dist
SET PACKET_MODE=ON
where 7z >nul 2>&1
if NOT "%errorlevel%"=="0" (
echo Not found 7z
goto :EOF
)
where curl >nul 2>&1
if NOT "%errorlevel%"=="0" (
echo Not found curl
goto :EOF
)
cd /D "%~dp0\.."
call mbplugin\tcc\get_tcc.bat
cd /D "%~dp0\.."
if NOT EXIST mbplugin\tcc\tcc.exe (
ECHO Error install tcc
GOTO :EOF
)
cd /D "%~dp0\.."
SET PYTHONDONTWRITEBYTECODE=1
call mbplugin\python\get_python.bat
cd /D "%~dp0\.."
if NOT EXIST mbplugin\python\Lib\site-packages\playwright\__init__.py (
ECHO Error install python
GOTO :EOF
)
cd /D "%~dp0\.."
call mbplugin\standalone\mbp
cd /D "%~dp0\.."
if NOT EXIST mbp.bat (
ECHO Error install mbp
GOTO :EOF
)
cd /D "%~dp0\..\mbplugin\plugin"
..\python\python -c "import util;util.mbplugin_ini_md_gen()"
..\python\python -c "import util;util.mbplugin_dockerfile_version()"
call git diff --exit-code
if NOT "%errorlevel%"=="0" (
ECHO Not all change will be commited
GOTO :EOF
)
cd /D "%~dp0\.."
call mbplugin\setup_and_check_full.bat
cd /D "%~dp0\.."
if NOT EXIST balance.html (
ECHO Error setup_and_check
GOTO :EOF
)
if NOT EXIST mbplugin\store\headless (
ECHO Error setup_and_check
GOTO :EOF
)
cd /D "%~dp0\.."
call mbp clear-browser-cache
cd /D "%~dp0\.."
if EXIST mbplugin\store\headless (
ECHO Error setup_and_check
GOTO :EOF
)
cd /D "%~dp0"
call python\python -m pip install -r docker\requirements_pytest.txt
call python\python -m pytest tests
call python\python -m pytest tests
if "%ERRORLEVEL%"==1 (
ECHO Error tests
GOTO :EOF
)
call python\python -m pip uninstall -y -r docker\requirements_pytest.txt
call python\python -m pip install -r docker\requirements_win.txt
cd /D "%~dp0\.."
call mbplugin\python\python mbplugin\python\remove__pycache__.py
cd /D "%~dp0\.."
if EXIST mbplugin\python\__pycache__ (
ECHO Error __pycache__
GOTO :EOF
)
cd /D "%~dp0\.."
call mbp web-server stop
timeout 5
cd /D "%~dp0\.."
if EXIST mbplugin\store\web-server.pid (
ECHO Error stop web-server
GOTO :EOF
)
cd /D "%~dp0\.."
del mbplugin\log\*.log
del mbplugin\log\*.png
del mbplugin\store\mbplugin.ini.bak.zip
del mbplugin\python\scripts\*.exe
cd /D "%~dp0"
for /F "tokens=1 delims=#" %%T IN ('git rev-parse HEAD') DO set mbpluginhead=%%T
for /F "tokens=3 delims= " %%T IN ('find "## mbplugin v1." changelist.md') DO set mbpluginversion=%%T
curl -Lk https://github.com/artyl/mbplugin/archive/%mbpluginhead%.zip -o pack\current.zip
7z rn pack\current.zip mbplugin-%mbpluginhead% mbplugin
copy pack\current.zip dist\mbplugin_bare.%mbpluginversion%.zip
call git-restore-mtime
cd /D "%~dp0\.."
7z a -tzip mbplugin\dist\mbplugin.%mbpluginversion%.zip mbplugin -xr0!mbplugin\.git -xr0!mbplugin\dist -xr!*.log
cd /D "%~dp0\plugin"
..\python\python -c "import updateengine;updateengine.create_signature()"
goto :EOF
@REM @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@