Skip to content

Merge pull request #4735 from LandSandBoat/vscode_updates #38

Merge pull request #4735 from LandSandBoat/vscode_updates

Merge pull request #4735 from LandSandBoat/vscode_updates #38

Workflow file for this run

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@v3
with:
fetch-depth: 0
- name: Install Dependencies
run: |
# https://mariadb.com/docs/connect/programming-languages/c/install/#connector-c-install-repo-configure-cs
# Ubuntu is using an old libmariadb but python3 pip expects it to be newer. Use the mariadb provided deb packages.
wget -P /tmp/ https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
# Note: there is a sha256sum command here according to the above link, but I am unsure if this file may change with time
chmod +x /tmp/mariadb_repo_setup
sudo /tmp/mariadb_repo_setup --mariadb-server-version="mariadb-10.6"
# Remove the above when it's no longer necessary
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 || true
fi
fi
done
cat cpp_checks.txt
if [ -s cpp_checks.txt ]
then
exit 1
fi
exit 0
- name: CPP Formatting Checks
if: always()
run: |
clang-format-14 -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-14 -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@v3
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_Clang14_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
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@v3
# with:
# path: build
# key: ${{ runner.os }}-clang
- name: Configure CMake
run: |
export CC=/usr/bin/clang-14
export CXX=/usr/bin/clang++-14
mkdir -p build
cmake -S . -B build
- name: Build
run: |
cmake --build build -j4
- name: Archive Executables
uses: actions/upload-artifact@v3
with:
name: linux_executables
path: |
xi_connect
xi_map
xi_search
xi_world
Linux_ClangTidy14_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
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@v3
# with:
# path: build
# key: ${{ runner.os }}-clang
- name: Configure CMake
run: |
export CC=/usr/bin/clang-14
export CXX=/usr/bin/clang++-14
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_GCC12_64bit:
needs: Sanity_Checks
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
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@v3
# with:
# path: build
# key: ${{ runner.os }}-gcc
- name: Configure CMake
run: |
export CC=/usr/bin/gcc-12
export CXX=/usr/bin/g++-12
mkdir -p build
CFLAGS=-m64 CXXFLAGS=-m64 LDFLAGS=-m64 cmake -S . -B build
- name: Build
run: |
cmake --build build -j4
Windows_32bit:
needs: Sanity_Checks
runs-on: windows-latest
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache 'build' folder
uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-msvc32
- name: Configure CMake
shell: cmd
run: |
mkdir -p build
cmake -S . -B build -A Win32
- name: Build
shell: cmd
run: |
cmake --build build -j4
Windows_64bit_Debug:
needs: Sanity_Checks
runs-on: windows-latest
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache 'build' folder
uses: actions/cache@v3
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@v3
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-latest
env:
MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Cache 'build' folder
uses: actions/cache@v3
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/virtual-environments/blob/main/images/macos/macos-11-Readme.md
runs-on: macos-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- name: Install Dependencies (Brew)
run: |
brew install mariadb zeromq zmq
- name: Install Dependencies (LuaJIT)
run: |
git clone https://github.com/LuaJIT/LuaJIT.git
cd LuaJIT
sudo make install MACOSX_DEPLOYMENT_TARGET=$(sw_vers -productVersion) -j $(sysctl -n hw.physicalcpu)
sudo ln -sf luajit-2.1.0-beta3 /usr/local/bin/luajit
- name: Cache 'build' folder
uses: actions/cache@v3
with:
path: build
key: ${{ runner.os }}-osx
- 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_Clang14_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@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
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: 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@v2
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
mysqlcmd "INSERT INTO accounts (id, login, password, timecreate, timelastmodify, status, priv)
VALUES(1000, 'admin', PASSWORD('admin'), 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('admin', 'admin', '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_Clang14_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@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
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-latest
needs: Windows_64bit_Debug
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 1
- uses: actions/download-artifact@v3
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