-
Notifications
You must be signed in to change notification settings - Fork 626
696 lines (652 loc) · 21.3 KB
/
build.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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
name: "build"
on:
pull_request:
types:
- opened
- synchronize
- reopened
push:
branches:
- base
- everything
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
jobs:
Sanity_Checks:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cppcheck luajit-5.1-dev luarocks mariadb-server-10.6 mariadb-client-10.6 libmariadb-dev-compat binutils-dev
pip install -r tools/requirements.txt
luarocks install luacheck --local
npm install -g diff-so-fancy
- id: changed-files
name: Get Changed Files
uses: Ana06/[email protected]
with:
filter: |
modules/**
src/**
scripts/**
sql/**
continue-on-error: true
- name: List Changed Files
if: always()
run: |
for changed_file in ${{ steps.changed-files.outputs.all }}; do
echo "${changed_file}"
done
- name: Git Formatting Checks
if: github.event_name == 'pull_request'
run: |
touch git_checks.txt
bash tools/ci/git.sh origin/${{ github.event.pull_request.base.ref }} >> git_checks.txt || true
cat git_checks.txt
if [ -s git_checks.txt ]
then
exit 1
fi
exit 0
- name: General File Checks
if: always()
run: |
touch general_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
bash tools/ci/general.sh ${changed_file} >> general_checks.txt || true
fi
done
cat general_checks.txt
if [ -s general_checks.txt ]
then
exit 1
fi
exit 0
- name: CPP Checks
if: always()
run: |
touch cpp_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
if [[ $changed_file == *.cpp ]]; then
bash tools/ci/cpp.sh ${changed_file} 2>> cpp_checks.txt >> cpp_checks.txt || true
fi
fi
done
cat cpp_checks.txt
if [ -s cpp_checks.txt ]
then
exit 1
fi
exit 0
- name: CPP Formatting Checks (clang-format-15)
if: always()
run: |
clang-format-15 -version
touch cpp_formatting_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
if [[ $changed_file == *.cpp || $changed_file == *.h ]]; then
clang-format-15 -style=file -i ${changed_file}
fi
fi
done
git diff --color >> cpp_formatting_checks.txt
git reset --hard
if [ -s cpp_formatting_checks.txt ]
then
echo ""
echo "You have errors in your C++ code formatting."
echo "Please see below in red for the incorrect formatting, and in green for the correct formatting."
echo "You can either fix the formatting by hand or use clang-format."
echo "(You can safely ignore warnings about \$TERM and tput)"
echo ""
cat cpp_formatting_checks.txt | diff-so-fancy || true
exit 1
fi
exit 0
- name: Upload CPP Formatting Diff
if: hashFiles('cpp_formatting_checks.txt') != ''
uses: actions/upload-artifact@v4
with:
name: clang_format_diff
path: |
cpp_formatting_checks.txt
- name: Lua Checks
if: always()
run: |
touch lua_checks.txt
python3 tools/ci/lua_stylecheck.py test >> lua_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
if [[ $changed_file == *.lua ]]; then
bash tools/ci/lua.sh ${changed_file} >> lua_checks.txt || true
fi
fi
done
python3 tools/ci/check_lua_binding_usage.py >> lua_checks.txt
cat lua_checks.txt
if [ -s lua_checks.txt ]
then
exit 1
fi
exit 0
- name: SQL Checks
if: always()
run: |
touch sql_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
if [[ $changed_file == *.sql ]]; then
bash tools/ci/sql.sh ${changed_file} >> sql_checks.txt || true
fi
fi
done
python3 tools/price_checker.py >> sql_checks.txt
cat sql_checks.txt
if [ -s sql_checks.txt ]
then
exit 1
fi
exit 0
- name: Python Checks
if: always()
run: |
touch python_checks.txt
for changed_file in ${{ steps.changed-files.outputs.all }}; do
if [[ -f $changed_file ]]; then
if [[ $changed_file == *.py ]]; then
bash tools/ci/python.sh ${changed_file} >> python_checks.txt || true
fi
fi
done
cat python_checks.txt
if [ -s python_checks.txt ]
then
exit 1
fi
exit 0
Linux_LuaLanguageServer:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Or else we don't get full blame information
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev binutils-dev
pip install -r tools/requirements.txt
- name: Run Lua Language Server
run: |
python3 tools/ci/lua_lang_server.py
- name: Upload Lua Language Server Output
if: hashFiles('lua_lang_errors.txt') != ''
uses: actions/upload-artifact@v4
with:
name: lua_lang_errors
path: lua_lang_errors.txt
- name: Check Output
run: |
if [ -f lua_lang_errors.txt ]; then
cat lua_lang_errors.txt
exit 1
fi
Linux_Clang15_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev binutils-dev
#- name: Cache 'build' folder
# uses: actions/cache@v4
# with:
# path: build
# key: ${{ runner.os }}-clang
- name: Configure CMake
run: |
export CC=/usr/bin/clang-15
export CXX=/usr/bin/clang++-15
mkdir -p build
cmake -S . -B build
- name: Build
run: |
cmake --build build -j4
- name: Archive Executables
uses: actions/upload-artifact@v4
with:
name: linux_executables
path: |
xi_connect
xi_map
xi_search
xi_world
Linux_ClangTidy15_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
# workaround for broken clang on ubuntu runner until fixed: https://github.com/actions/runner-images/issues/8659
- uses: claywar/workaround8649@4892524a133793c85e25513fae79fc968e63877c
with:
os: ubuntu-22.04
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev binutils-dev
#- name: Cache 'build' folder
# uses: actions/cache@v4
# with:
# path: build
# key: ${{ runner.os }}-clang
- name: Configure CMake
run: |
export CC=/usr/bin/clang-15
export CXX=/usr/bin/clang++-15
mkdir -p build
cmake -S . -B build -DENABLE_CLANG_TIDY=ON
- name: Build
run: |
touch clang-tidy.txt
cmake --build build -j4 >> clang-tidy.txt || true
cat clang-tidy.txt
if grep -q warning\|error clang-tidy.txt; then
exit 1
fi
Linux_GCC13_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev binutils-dev
# Required for 22.04 Image, remove on transition to 24.04
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -y
sudo apt-get install gcc-13 g++-13
#- name: Cache 'build' folder
# uses: actions/cache@v4
# with:
# path: build
# key: ${{ runner.os }}-gcc
- name: Configure CMake
run: |
export CC=/usr/bin/gcc-13
export CXX=/usr/bin/g++-13
mkdir -p build
CFLAGS=-m64 CXXFLAGS=-m64 LDFLAGS=-m64 cmake -S . -B build
- name: Build
run: |
cmake --build build -j4
Windows_64bit_Debug:
needs: Sanity_Checks
runs-on: windows-2022
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache 'build' folder
uses: actions/cache@v4
with:
path: build
key: ${{ runner.os }}-msvc64d
- name: Configure CMake
shell: cmd
run: |
mkdir -p build
cmake -S . -B build -A x64 -DCMAKE_BUILD_TYPE=Debug
- name: Build
shell: cmd
run: |
cmake --build build -j4
- name: Archive Executables
uses: actions/upload-artifact@v4
with:
name: windows_executables
path: |
xi_connect.exe
xi_map.exe
xi_search.exe
xi_world.exe
Windows_64bit_Release_Tracy_Modules:
needs: Sanity_Checks
runs-on: windows-2022
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Cache 'build' folder
uses: actions/cache@v4
with:
path: build
key: ${{ runner.os }}-msvc64-t
- name: Enable Modules
shell: bash
run: |
python3 << EOF
with open("modules/init.txt", "w") as f:
f.write("custom\n")
f.write("era\n")
f.write("renamer\n")
EOF
- name: Configure CMake
shell: cmd
run: |
mkdir -p build
cmake -S . -B build -A x64 -DCMAKE_BUILD_TYPE=Release -DENABLE_TRACY=ON
- name: Build
shell: cmd
run: |
cmake --build build -j4
MacOS_64bit:
needs: Sanity_Checks
# https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md
runs-on: macos-13
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Install Dependencies (Brew)
run: |
brew install mariadb zeromq zmq luajit
- name: Configure CMake
run: |
mkdir -p build
cmake -S . -B build
- name: Build
run: |
cmake --build build -j4
Full_Startup_Checks_Linux:
runs-on: ubuntu-22.04
needs: Linux_Clang15_64bit
services:
mysql:
image: mariadb:10.6
env:
MYSQL_DATABASE: xidb
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/download-artifact@v4
with:
name: linux_executables
path: .
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake mariadb-client-10.6 libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev luarocks binutils-dev
pip install bcrypt
- name: Verify MySQL connection from container
run: |
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES"
- name: Import SQL files
run: |
for f in sql/*.sql; do
echo -e "Importing $f into the database..."
mysql xidb -h 127.0.0.1 -uroot -proot < $f
done
mysql xidb -h 127.0.0.1 -uroot -proot -e "SHOW tables"
- name: Copy settings
run: |
cp settings/default/* settings/
- name: Enable Modules
shell: bash
run: |
python3 << EOF
with open("modules/init.txt", "w") as f:
f.write("custom\n")
f.write("era\n")
f.write("renamer\n")
EOF
- name: Startup and character login checks
uses: nick-invision/retry@v3
with:
timeout_minutes: 15
max_attempts: 3
retry_on: timeout
shell: bash
command: |
chmod +x xi_connect
chmod +x xi_map
chmod +x xi_search
chmod +x xi_world
ls -l
printf "\nStart server processes\n"
screen -d -m -S xi_connect ./xi_connect --log login-server.log
screen -d -m -S xi_search ./xi_search --log search-server.log
screen -d -m -S xi_map ./xi_map --log map-server.log
screen -d -m -S xi_world ./xi_world --log world-server.log
printf "\nWaiting 5m for servers to fully start up\n"
sleep 300s
# define bash helper function to help diagnose any sql errors
function mysqlcmd() { mysql xidb -h 127.0.0.1 -uroot -proot --verbose -e "$@"; }
printf "\nPopulating database\n"
# Clean out anything already there (just in case)
mysqlcmd "DELETE FROM accounts;"
mysqlcmd "DELETE FROM chars;"
mysqlcmd "DELETE FROM char_look;"
mysqlcmd "DELETE FROM char_stats;"
# Clean tables that are made from triggers on insert to char table
mysqlcmd "DELETE FROM char_equip;"
mysqlcmd "DELETE FROM char_exp;"
mysqlcmd "DELETE FROM char_history;"
mysqlcmd "DELETE FROM char_inventory;"
mysqlcmd "DELETE FROM char_jobs;"
mysqlcmd "DELETE FROM char_pet;"
mysqlcmd "DELETE FROM char_points;"
mysqlcmd "DELETE FROM char_profile;"
mysqlcmd "DELETE FROM char_storage;"
mysqlcmd "DELETE FROM char_unlocks;"
# Create an account
PASSWORD_HASH=\$2a\$12\$piFoDKvu80KK68xLgQFpt.ZCqVPTjPmhSUfA31.Yw9n404dTsrR6q
mysqlcmd "INSERT INTO accounts (id, login, password, timecreate, timelastmodify, status, priv)
VALUES(1000, 'admin1', '$PASSWORD_HASH', NOW(), NOW(), 1, 1);
SELECT id, login, content_ids FROM accounts;"
# Create a character
mysqlcmd "INSERT INTO chars (charid, accid, charname, pos_zone, nation, gmlevel)
VALUES(1, 1000, 'Test', 0, 0, 5);
SELECT charid, accid, charname, pos_zone FROM chars;"
# Set char_look (default is 0 and trips up scripting)
mysqlcmd "INSERT INTO char_look (charid, face, race, size, head, body, hands, legs, feet, main, sub, ranged)
VALUES (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1);
SELECT charid, face, race FROM char_look;"
# Populate more char tables with defaults
mysqlcmd "INSERT INTO char_stats (charid, mjob)
VALUES(1, 1);
SELECT charid, mjob FROM char_stats;"
# Update character information
# Place near some Robber Crabs in Kuftal Tunnel
mysqlcmd "UPDATE chars
SET
pos_zone = 174,
pos_prevzone = 174,
pos_x = 55,
pos_y = -9,
pos_z = -140
WHERE charid = 1;"
mysqlcmd "SELECT charid, accid, charname, pos_zone, pos_x, pos_y, pos_z FROM chars;"
# Set GodMode CharVar = 1
mysqlcmd "INSERT INTO char_vars(charid, varname, value)
VALUES(1, 'GodMode', 1);"
printf "\nRunning HeadlessXI for 60 seconds\n"
python3 << EOF
import time
try:
from tools.headlessxi.hxiclient import HXIClient
hxi_client = HXIClient('admin1', 'admin1', 'localhost')
hxi_client.login()
print('Sleeping 60s')
time.sleep(60)
hxi_client.logout()
exit(0)
except Exception as e:
exit(-1)
EOF
hxi_result=$?
pkill -SIGINT xi_map
pkill -SIGINT xi_search
pkill -SIGINT xi_connect
pkill -SIGINT xi_world
# fail if hxi had a non-zero exit code
if [[ "$hxi_result" -ne "0" ]]; then
echo "hxi exited with code $hxi_result"
exit $hxi_result
fi
- name: Check for errors and warnings
if: ${{ success() || failure() }}
run: |
cat login-server*.log
cat map-server*.log
cat search-server*.log
cat world-server*.log
if grep -qi "warning\|error\|crash" login-server*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" map-server*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" search-server*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" world-server*.log; then
exit -1
fi
MultiInstance_Startup_Checks_Linux:
runs-on: ubuntu-22.04
needs: Linux_Clang15_64bit
services:
mysql:
image: mariadb:10.6
env:
MYSQL_DATABASE: xidb
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=10s --health-retries=10
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/download-artifact@v4
with:
name: linux_executables
path: .
- name: Install Dependencies
run: |
sudo apt-get update
sudo apt-get install -y software-properties-common cmake mariadb-client-10.6 libmariadb-dev-compat libluajit-5.1-dev libzmq3-dev zlib1g-dev libssl-dev luarocks binutils-dev
- name: Verify MySQL connection from container
run: |
mysql -h 127.0.0.1 -uroot -proot -e "SHOW DATABASES"
- name: Import SQL files
run: |
for f in sql/*.sql; do
echo -e "Importing $f into the database..."
mysql xidb -h 127.0.0.1 -uroot -proot < $f
done
mysql xidb -h 127.0.0.1 -uroot -proot -e "SHOW tables"
- name: Assign odd zones a different port
run: |
mysql xidb -h 127.0.0.1 -uroot -proot -e "UPDATE xidb.zone_settings SET zoneport = 54231 WHERE zoneid % 2 = 0;"
- name: Copy settings
run: |
cp settings/default/* settings/
- name: Startup checks
env:
MYSQL_HOST: mysql
run: |
chmod +x xi_connect
chmod +x xi_map
chmod +x xi_search
chmod +x xi_world
ls -l
printf "\nStart server processes\n"
screen -d -m -S xi_connect ./xi_connect --log login-server.log
screen -d -m -S xi_search ./xi_search --log search-server.log
screen -d -m -S xi_map ./xi_map --log map-server-0.log --ip 127.0.0.1 --port 54230
screen -d -m -S xi_map ./xi_map --log map-server-1.log --ip 127.0.0.1 --port 54231
screen -d -m -S xi_world ./xi_world --log world-server.log
sleep 300s
killall screen
- name: Check for errors and warnings
if: ${{ success() || failure() }}
run: |
cat login-server*.log
cat search-server*.log
cat map-server-0*.log
cat map-server-1*.log
cat world-server*.log
if grep -qi "warning\|error\|crash" login-server*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" search-server*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" map-server-0*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" map-server-1*.log; then
exit -1
fi
if grep -qi "warning\|error\|crash" world-server*.log; then
exit -1
fi
Full_Startup_Checks_Windows:
runs-on: windows-2022
needs: Windows_64bit_Debug
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/download-artifact@v4
with:
name: windows_executables
path: .
- uses: zach2good/setup-mariadb@v1
with:
database: xidb
- name: Copy settings
run: |
cp settings/default/* settings/
- name: Install Python Dependencies
run: |
pip install -r tools/requirements.txt
- name: Import SQL files
shell: bash
run: |
for f in sql/*.sql; do
echo -e "Importing $f into the database..."
mysql xidb -h 127.0.0.1 -uroot -proot < $f
done
mysql xidb -h 127.0.0.1 -uroot -proot -e "SHOW tables"
- name: Startup checks
shell: bash
run: |
python3 ./tools/ci/startup_checks.py