code quality

This commit is contained in:
Letter N
2020-12-29 11:12:56 +08:00
parent 51143f89e5
commit f28363ae56
65 changed files with 950 additions and 347 deletions

6
tools/appveyor/build.ps1 → tools/ci/build.ps1 Normal file → Executable file
View File

@@ -1,10 +1,8 @@
if(!(Test-Path -Path "C:/byond")){
bash tools/appveyor/download_byond.sh
bash tools/ci/download_byond.sh
[System.IO.Compression.ZipFile]::ExtractToDirectory("C:/byond.zip", "C:/")
Remove-Item C:/byond.zip
}
Set-Location $env:APPVEYOR_BUILD_FOLDER
&"C:/byond/bin/dm.exe" -max_errors 0 tgstation.dme
exit $LASTEXITCODE
exit $LASTEXITCODE

19
tools/ci/build_spaceman_dmm.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
source dependencies.sh
cd $HOME/SpacemanDMM
if [ ! -d .git ]
then
git init
git remote add origin https://github.com/SpaceManiac/SpacemanDMM.git
fi
git fetch origin --depth=1 $SPACEMAN_DMM_COMMIT_HASH
git reset --hard FETCH_HEAD
cargo build --release --bin $1
cp target/release/$1 ~
~/$1 --version

View File

@@ -1,5 +1,5 @@
#!/bin/bash
set -euo pipefail
md5sum -c - <<< "49bc6b1b9ed56c83cceb6674bd97cb34 *html/changelogs/example.yml"
md5sum -c - <<< "364a16f858a957486eaeb1e12673c39c *html/changelogs/example.yml"
python3 tools/ss13_genchangelog.py html/changelog.html html/changelogs

View File

@@ -1,4 +1,3 @@
#!/bin/bash
if [ -n "$1" ]
then
@@ -13,3 +12,4 @@ then
echo "ERROR: File DIR was ticked, please untick it, see: https://tgstation13.org/phpBB/viewtopic.php?f=5&t=321 for more"
exit 1
fi

View File

@@ -22,13 +22,27 @@ if grep -P 'pixel_[^xy]' _maps/**/*.dmm; then
echo "ERROR: incorrect pixel offset variables detected in maps, please remove them."
st=1
fi;
echo "Checking for cable varedits"
if grep -P '/obj/structure/cable(/\w+)+\{' _maps/**/*.dmm; then
echo "ERROR: vareditted cables detected, please remove them."
st=1
fi;
if grep -P '\td[1-2] =' _maps/**/*.dmm; then
echo "ERROR: d1/d2 cable variables detected in maps, please remove them."
st=1
fi;
echo "Checking for pixel_[xy]"
if grep -P 'pixel_[xy] = 0' _maps/**/*.dmm; then
echo "pixel_x/pixel_y = 0 variables detected in maps, please review to ensure they are not dirty varedits."
fi;
echo "Checking for stacked cables"
if grep -P '"\w+" = \(\n([^)]+\n)*/obj/structure/cable,\n([^)]+\n)*/obj/structure/cable,\n([^)]+\n)*/area/.+\)' _maps/**/*.dmm; then
echo "found multiple cables on the same tile, please remove them."
st=1
fi;
if grep -P '^/area/.+[\{]' _maps/**/*.dmm; then
echo "WARNING: Vareditted /area path use detected in maps, please replace with proper paths."
#st=1
echo "ERROR: Vareditted /area path use detected in maps, please replace with proper paths."
st=1
fi;
if grep -P '\W\/turf\s*[,\){]' _maps/**/*.dmm; then
echo "ERROR: base /turf path use detected in maps, please replace with proper paths."
@@ -38,6 +52,16 @@ if grep -P '^/*var/' code/**/*.dm; then
echo "ERROR: Unmanaged global var use detected in code, please use the helpers."
st=1
fi;
echo "Checking for space indentation"
if grep -P '(^ {2})|(^ [^ * ])|(^ +)' code/**/*.dm; then
echo "space indentation detected"
st=1
fi;
echo "Checking for mixed indentation"
if grep -P '^\t+ [^ *]' code/**/*.dm; then
echo "mixed <tab><space> indentation detected"
st=1
fi;
nl='
'
nl=$'\n'
@@ -45,9 +69,13 @@ while read f; do
t=$(tail -c2 "$f"; printf x); r1="${nl}$"; r2="${nl}${r1}"
if [[ ! ${t%x} =~ $r1 ]]; then
echo "file $f is missing a trailing newline"
#st=1
st=1
fi;
done < <(find . -type f -name '*.dm')
if grep -P '^/[\w/]\S+\(.*(var/|, ?var/.*).*\)' code/**/*.dm; then
echo "changed files contains proc argument starting with 'var'"
st=1
fi;
if grep -i 'centcomm' code/**/*.dm; then
echo "ERROR: Misspelling(s) of CENTCOM detected in code, please remove the extra M(s)."
st=1
@@ -56,6 +84,14 @@ if grep -i 'centcomm' _maps/**/*.dmm; then
echo "ERROR: Misspelling(s) of CENTCOM detected in maps, please remove the extra M(s)."
st=1
fi;
if grep -ni 'nanotransen' code/**/*.dm; then
echo "Misspelling(s) of nanotrasen detected in code, please remove the extra N(s)."
st=1
fi;
if grep -ni 'nanotransen' _maps/**/*.dmm; then
echo "Misspelling(s) of nanotrasen detected in maps, please remove the extra N(s)."
st=1
fi;
if ls _maps/*.json | grep -P "[A-Z]"; then
echo "Uppercase in a map json detected, these must be all lowercase."
st=1

View File

@@ -1,7 +1,7 @@
SQL_ENABLED
ADDRESS 127.0.0.1
PORT 3306
FEEDBACK_DATABASE tg_travis
FEEDBACK_DATABASE tg_ci
FEEDBACK_TABLEPREFIX
FEEDBACK_LOGIN root
FEEDBACK_PASSWORD

View File

View File

@@ -10,5 +10,3 @@ npm install --global yarn
pip3 install --user PyYaml
pip3 install --user beautifulsoup4
phpenv global $PHP_VERSION

9
tools/ci/install_rust_g.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
source dependencies.sh
mkdir -p ~/.byond/bin
wget -O ~/.byond/bin/librust_g.so "https://github.com/tgstation/rust-g/releases/download/$RUST_G_VERSION/librust_g.so"
chmod +x ~/.byond/bin/librust_g.so
ldd ~/.byond/bin/librust_g.so

View File

@@ -0,0 +1,19 @@
#!/bin/bash
set -euo pipefail
source dependencies.sh
if [ ! -f ~/$1 ]; then
mkdir -p "$HOME/SpacemanDMM"
CACHEFILE="$HOME/SpacemanDMM/$1"
if ! [ -f "$CACHEFILE.version" ] || ! grep -Fxq "$SPACEMAN_DMM_VERSION" "$CACHEFILE.version"; then
wget -O "$CACHEFILE" "https://github.com/SpaceManiac/SpacemanDMM/releases/download/$SPACEMAN_DMM_VERSION/$1"
chmod +x "$CACHEFILE"
echo "$SPACEMAN_DMM_VERSION" >"$CACHEFILE.version"
fi
ln -s "$CACHEFILE" ~/$1
fi
~/$1 --version

14
tools/ci/run_server.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -euo pipefail
tools/deploy.sh ci_test
rm ci_test/*.dll
mkdir ci_test/config
#test config
cp tools/ci/ci_config.txt ci_test/config/config.txt
cd ci_test
DreamDaemon tgstation.dmb -close -trusted -verbose -params "log-directory=ci"
cd ..
cat ci_test/data/logs/ci/clean_run.lk

View File

@@ -1,21 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source dependencies.sh
mkdir -p BSQL
cd BSQL
git init
git remote add origin https://github.com/tgstation/BSQL
git fetch --depth 1 origin $BSQL_VERSION
git checkout FETCH_HEAD
mkdir -p artifacts
cd artifacts
export CXX=g++-7
# The -D will be unnecessary past BSQL v1.4.0.0
cmake .. -DMARIA_LIBRARY=/usr/lib/i386-linux-gnu/libmariadb.so
make
mkdir -p ~/.byond/bin
ln -s $PWD/src/BSQL/libBSQL.so ../../libBSQL.so

View File

@@ -1,47 +0,0 @@
#!/usr/bin/env python
import os
import sys
import glob
WINDOWS_NEWLINE = b'\r\n'
FILES_TO_READ = []
FILES_TO_READ.extend(glob.glob(r"**/*.dm", recursive=True))
FILES_TO_READ.extend(glob.glob(r"**/*.dmm", recursive=True))
FILES_TO_READ.extend(glob.glob(r"*.dme"))
#for i in FILES_TO_READ:
# if os.path.isdir(i):
# FILES_TO_READ.remove(i)
def _reader(filepath):
data = open(filepath, "rb")
return data
def main():
filelist = []
foundfiles = False
for file in FILES_TO_READ:
data = _reader(file)
lines = data.readlines()
for line in lines:
if line.endswith(WINDOWS_NEWLINE):
filelist.append(file)
foundfiles = True
break
data.close()
if not foundfiles:
print("No CRLF files found.")
sys.exit(0)
else:
print("Found files with suspected CRLF type.")
for i in filelist:
print(i)
sys.exit(1)
if __name__ == "__main__":
main()

View File

@@ -1,15 +0,0 @@
#!/bin/bash
set -euo pipefail
# get libmariadb, cache it so limmex doesn't get angery
if [ -f $HOME/libmariadb ]; then
#travis likes to interpret the cache command as it being a file for some reason
rm $HOME/libmariadb
fi
mkdir -p $HOME/libmariadb
if [ ! -f $HOME/libmariadb/libmariadb.so ]; then
wget http://www.byond.com/download/db/mariadb_client-2.0.0-linux.tgz
tar -xvf mariadb_client-2.0.0-linux.tgz
mv mariadb_client-2.0.0-linux/libmariadb.so $HOME/libmariadb/libmariadb.so
rm -rf mariadb_client-2.0.0-linux.tgz mariadb_client-2.0.0-linux
fi

View File

@@ -1,8 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
source dependencies.sh
mkdir -p ~/.byond/bin
wget -O ~/.byond/bin/rust_g "https://github.com/tgstation/rust-g/releases/download/$RUST_G_VERSION/librust_g.so"
chmod +x ~/.byond/bin/rust_g

View File

@@ -1,8 +0,0 @@
#!/bin/bash
set -euo pipefail
source dependencies.sh
wget -O ~/$1 "https://github.com/SpaceManiac/SpacemanDMM/releases/download/$SPACEMAN_DMM_VERSION/$1"
chmod +x ~/$1
~/$1 --version

View File

@@ -1,15 +0,0 @@
#!/bin/bash
set -euo pipefail
tools/deploy.sh travis_test
rm travis_test/*.dll
mkdir travis_test/config
#test config
cp tools/travis/travis_config.txt travis_test/config/config.txt
cd travis_test
ln -s $HOME/libmariadb/libmariadb.so libmariadb.so
DreamDaemon tgstation.dmb -close -trusted -verbose -params "test-run&log-directory=travis"
cd ..
cat travis_test/data/logs/travis/clean_run.lk