-
-
Notifications
You must be signed in to change notification settings - Fork 12
258 lines (217 loc) · 11.2 KB
/
windows-latest-lua-unit-testing.yml
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
name: Windows Lua Unit Testing
on: [ push, pull_request ]
jobs:
lua-unit-testing-on-windows-latest:
name: "LuaUnit on Windows-latest (MSVC)"
runs-on: windows-latest
steps:
- uses: actions/[email protected]
- name: Build LuaJIT-2.0.4
shell: cmd
run: |
:: Build LuaJIT 2.0.4
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
cd ${{ github.workspace }}\.building\LuaJIT-2.0.4\src
msvcbuild
if exist luajit.exe (
echo "LuaJIT-2.0.4 built successfully"
) else (
echo "::error::LuaJIT-2.0.4 build failed"
exit 1
)
- name: Install LuaJIT-2.0.4
shell: pwsh
run: |
# Install binaries
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\luajit.exe" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\bin"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lua51.dll" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\bin"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lua51.lib" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\bin"
# 'Install' JIT modules
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\jit\*" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\lua\jit\" -Recurse
# 'Install' JIT includes
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\luaconf.h" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\include"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lua.h" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\include"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lualib.h" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\include"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lauxlib.h" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\include"
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lua.hpp" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\include"
# 'Install' JIT library
Copy-Item "${{ github.workspace }}\.building\LuaJIT-2.0.4\src\lua51.lib" -Destination "${{ github.workspace }}\LuaJIT-2.0.4\lib"
# Test luajit.exe
Start-Process -FilePath "${{ github.workspace }}\LuaJIT-2.0.4\bin\luajit.exe" -ArgumentList "-v" -Wait -NoNewWindow
Start-Process -FilePath "${{ github.workspace }}\LuaJIT-2.0.4\bin\luajit.exe" -ArgumentList "-e `"print(_VERSION)`"" -Wait -NoNewWindow
- name: Install and init luarocks
shell: cmd
run: |
cd ${{ github.workspace}}\mods\noita-mp\
set INIT_PATH=%CD%
REM // resolve absolute path
set REL_PATH=..\..\.building\luarocks-3.9.1-windows-32
set ABS_PATH=
rem // Save current directory and change to target directory
pushd %REL_PATH%
rem // Save value of CD variable (current directory)
set ABS_PATH=%CD%
rem // Restore original directory
popd
echo Relative path: %REL_PATH%
echo Maps to path: %ABS_PATH%
REM // init luarocks
%ABS_PATH%\luarocks --lua-dir="${{ github.workspace}}\LuaJIT-2.0.4" --lua-version="5.1" init noita-mp --output="${{ github.workspace}}\mods\noita-mp" --homepage="https://github.com/Ismoh/NoitaMP" --lua-versions="5.1" --license="GNU GPL v3"
REM // change luarocks projects config
%ABS_PATH%\luarocks config --scope="project" lua_interpreter luajit.exe
%ABS_PATH%\luarocks config --scope="project" lua_dir ${{ github.workspace}}\LuaJIT-2.0.4
%ABS_PATH%\luarocks config --scope="project" variables.LUA_BINDIR ${{ github.workspace}}\LuaJIT-2.0.4\bin
%ABS_PATH%\luarocks config --scope="project" variables.LUA_DIR ${{ github.workspace}}\LuaJIT-2.0.4
%ABS_PATH%\luarocks config --scope="project" variables.LUA_INCDIR ${{ github.workspace}}\LuaJIT-2.0.4\include
%ABS_PATH%\luarocks config --scope="project" variables.CFLAGS "GODDAMNIT"
%ABS_PATH%\luarocks config
if exist lua.bat (
echo "LuaRocks project init successfully"
) else (
echo "::error::LuaRocks project init failed. Unable to find lua.bat"
exit 1
)
if exist luarocks.bat (
echo "LuaRocks project init successfully"
) else (
echo "::error::LuaRocks project init failed. Unable to find luarocks.bat"
exit 1
)
- name: Fix LuaRocks bug
run: |
cd ${{ github.workspace}}\mods\noita-mp\.luarocks
sed -i 's/GODDAMNIT/\-v \-O2/g' config-5.1.lua
cat config-5.1.lua
#- name: luaExtensions changes?
#shell: pwsh
#id: lua_extensions_has_changed
#run: |
# https://www.meziantou.net/executing-github-actions-jobs-or-steps-only-when-specific-files-change.htm
# Diff HEAD with the previous commit
#$diff = git diff --name-only HEAD^ HEAD
# Check if luaExtensions.c has changed (added, modified, deleted)
#$SourceDiff = $diff | Where-Object { $_ -match 'luaExtensions.c' }
#$HasDiff = $SourceDiff.Length -gt 0
# Set the output named "changed"
#Write-Host "::set-output name=changed::$HasDiff"
- name: Build and install luaExtensions.dll
shell: cmd
# if: steps.lua_extensions_has_changed.outputs.changed == 'True'
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
cd ${{ github.workspace }}\
msbuild .\luaExtensions.vcxproj
- name: Install dependencies
shell: cmd
run: |
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
cd ${{ github.workspace}}\mods\noita-mp\
call luarocks.bat install luafilesystem
call luarocks.bat install luacov
call luarocks.bat install luacov-coveralls
call luarocks.bat install winapi
if exist ${{ github.workspace }}\mods\noita-mp\lua_modules\bin\luacov.bat (
echo "LuaCov install successfully"
) else (
echo "::error::LuaCov install failed"
exit 1
)
if exist ${{ github.workspace }}\mods\noita-mp\lua_modules\bin\luacov-coveralls.bat (
echo "LuaCov Coveralls install successfully"
) else (
echo "::error::LuaCov Coveralls install failed"
exit 1
)
- name: Run LuaUnit 3.4
shell: cmd
id: lua_unit_tests
run: |
cd ${{ github.workspace}}\mods\noita-mp\
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86 10.0.22000.0 -vcvars_ver=14
call luarocks.bat test > result.log
if exist result.log (
echo "LuaUnit tests successfully"
) else (
echo "::error::LuaUnit tests failed. Unable to find result.log"
exit 1
)
type result.log
- name: Failed unit tests?
shell: cmd
run: |
cd ${{ github.workspace}}/mods/noita-mp
for /F "tokens=9 delims= " %%a in ('findstr /I "Ran*" result.log') do set "failOrErrorCount=%%a"
echo "failOrErrorCount:%failOrErrorCount%"
if NOT %failOrErrorCount% == 0 (
echo "::error title=LuaUnit tests failed::%failOrErrorCount% failures or errors occurred!"
exit 1
)
- name: Write LuaRocks path into files
shell: cmd
run: |
cd ${{ github.workspace }}\mods\noita-mp\
call luarocks path --lr-path >> lpath.txt
call luarocks path --lr-cpath >> cpath.txt
call luarocks path --lr-bin >> path.txt
- name: Set LuaRocks path into GitHub action path
run: |
cd ${{ github.workspace }}\mods\noita-mp\
$lpath = Get-Content lpath.txt -Raw
echo "LUA_PATH=$lpath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "$lpath" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
$cpath = Get-Content cpath.txt -Raw
echo "LUA_CPATH=$cpath" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
echo "$cpath" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
$path = Get-Content path.txt -Raw
echo "$path" | Out-File -Append -FilePath $env:GITHUB_PATH -Encoding utf8
- name: Generate coverage report with luacov
shell: cmd
run: |
cd ${{ github.workspace }}\mods\noita-mp\
call lua.bat -lluacov ${{ github.workspace }}\mods\noita-mp\tests\_initializeUnitTests.lua -o text --verbose
call ${{ github.workspace }}\mods\noita-mp\lua_modules\bin\luacov.bat -c=${{ github.workspace }}\mods\noita-mp\.luacov
ls -R
if exist ${{ github.workspace }}\mods\noita-mp\luacov.stats.out (
echo "LuaCov report successfully"
) else (
echo "::error::LuaCov report failed. Unable to find luacov.stats.out"
exit 1
)
if exist ${{ github.workspace }}\mods\noita-mp\luacov.report.out (
echo "LuaCov report successfully"
) else (
echo "::error::LuaCov report failed. Unable to find luacov.report.out"
exit 1
)
- name: Fix wrong paths in luacov.report.out
run : |
cd ${{ github.workspace }}\mods\noita-mp\
cat luacov.report.out
sed -i 's/\.\.\noita\-mp/mods\\noita\-mp/g' luacov.report.out
cat luacov.report.out
sed -i 's/D\:\\a\\NoitaMP\\NoitaMP\\mods\\noita\-mp\\\.\.\\\.\.\\mods\\noita\-mp/mods\\noita\-mp/g' luacov.report.out
cat luacov.report.out
sed -i 's/D\:\\a\\NoitaMP\\NoitaMP\\mods\\noita\-mp/mods\\noita\-mp/g' luacov.report.out
cat luacov.report.out
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: mods/noita-mp/luacov.report.out
flags: unittesting
functionalities: network
name: Windows Lua Unit Testing
verbose: true
- name: Generate coverage report with luacov-coveralls
shell: cmd
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_DEBUG: true
run: |
cd ${{ github.workspace}}\mods\noita-mp\
call ${{ github.workspace }}\mods\noita-mp\lua_modules\bin\luacov-coveralls.bat --verbose --root=${{ github.workspace}}\mods\noita-mp\
if exist ${{ github.workspace }}\mods\noita-mp\luacov.report.out (
echo "LuaCov Coveralls report successfully"
) else (
echo "::error::LuaCov Coveralls report failed. Unable to find luacov.report.out"
exit 1
)