From d992ef50083da2867d2db938e82393ed6a6bf383 Mon Sep 17 00:00:00 2001 From: AffectedArc07 Date: Sun, 12 Apr 2020 14:23:37 +0100 Subject: [PATCH] Test of the travis cleanup --- .travis.yml | 79 +++++---------- _build_dependencies.sh | 5 + ...test_all_maps.dm => travis_map_testing.dm} | 0 install-byond.sh | 14 --- tools/travis/build_nanoui.sh | 7 ++ tools/travis/check_changelogs.sh | 5 + tools/travis/check_grep.sh | 0 tools/travis/dm.sh | 97 +++++++++++++++++++ tools/travis/install_build_deps.sh | 12 +++ tools/travis/install_byond.sh | 21 ++++ tools/travis/json_verifier.py | 20 ++++ 11 files changed, 191 insertions(+), 69 deletions(-) rename _maps/{test_all_maps.dm => travis_map_testing.dm} (100%) delete mode 100644 install-byond.sh create mode 100755 tools/travis/build_nanoui.sh create mode 100755 tools/travis/check_changelogs.sh mode change 100644 => 100755 tools/travis/check_grep.sh create mode 100755 tools/travis/dm.sh create mode 100755 tools/travis/install_build_deps.sh create mode 100755 tools/travis/install_byond.sh create mode 100644 tools/travis/json_verifier.py diff --git a/.travis.yml b/.travis.yml index 979e35f6aed..bf993566695 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,74 +1,43 @@ #pretending we're C because otherwise ruby will initialize, even with "language: dm". language: generic +dist: xenial sudo: false git: depth: 1 -cache: - directories: - - $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR} - -addons: - apt: - packages: - - libc6-i386 - - libgcc1:i386 - - libstdc++6:i386 - -env: - global: - - BYOND_MAJOR="513" - - BYOND_MINOR="1505" - - BYOND_MACRO_COUNT=4 - matrix: - - DM_MAPFILE="cyberiad" - - DM_MAPFILE="metastation" - - DM_MAPFILE="delta" - - DM_MAPFILE="test_all_maps" - -stages: - - File Checks - - test - -before_script: - - chmod +x ./install-byond.sh - - ./install-byond.sh -script: - - source $HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin/byondsetup - - bash dm.sh -M${DM_MAPFILE} paradise.dme - -jobs: +matrix: include: - # Basic styling/functionality checks - - stage: File Checks - env: + - name: "Run Linters" addons: + apt: + packages: + - python3 + - python3-pip + - python3-setuptools install: - - pip install --user PyYaml -q - - pip install --user beautifulsoup4 -q + - tools/travis/install_build_deps.sh - tools/travis/install_dreamchecker.sh - before_script: skip script: - shopt -s globstar + - find . -name "*.php" -print0 | xargs -0 -n1 php -l + - find . -name "*.json" -not -path "./nano/node_modules/*" -print0 | xargs -0 python3 ./tools/json_verifier.py + - tools/travis/build_nanoUI.sh + - tools/travis/check_grep.sh + - tools/travis/check_changelogs.sh - python3 tools/travis/check_line_endings.py - - (num=$(grep -Ern '\\(red|blue|green|black|italic|bold|b|i[^mc])' code/ | wc -l); echo "$num BYOND text macros (expecting ${BYOND_MACRO_COUNT} or fewer)"; [ $num -le ${BYOND_MACRO_COUNT} ]) - - md5sum -c - <<< "6dc1b6bf583f3bd4176b6df494caa5f1 *html/changelogs/example.yml" - - python tools/ss13_genchangelog.py html/changelog.html html/changelogs - ~/dreamchecker - # Compile NanoUI to make sure it works - - stage: NanoUI - language: node_js - node_js: - - "9" - env: + - name: "Compile All Maps" addons: - before_install: - - npm install -g gulp-cli - - cd ./nano/ + apt: + packages: + - libstdc++6:i386 + cache: + directories: + - $HOME/BYOND install: - - npm install --loglevel=error - before_script: + - tools/travis/install_byond.sh + - source $HOME/BYOND/byond/bin/byondsetup script: - - node node_modules/gulp/bin/gulp.js --require less-loader + - tools/travis/dm.sh -M travis_map_testing paradise.dme diff --git a/_build_dependencies.sh b/_build_dependencies.sh index f9bddd66134..d5d85c73df4 100644 --- a/_build_dependencies.sh +++ b/_build_dependencies.sh @@ -1,2 +1,7 @@ # This file has all the information on what versions of libraries are thrown into the code +# For dreamchecker export SPACEMANDMM_TAG=suite-1.2 +# For NanoUI +export NODEJS_VERSION=9 +# For the scripts in tools +export PHP_VERSION=5.6 diff --git a/_maps/test_all_maps.dm b/_maps/travis_map_testing.dm similarity index 100% rename from _maps/test_all_maps.dm rename to _maps/travis_map_testing.dm diff --git a/install-byond.sh b/install-byond.sh deleted file mode 100644 index cca44342c60..00000000000 --- a/install-byond.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -set -e -if [ -d "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}/byond/bin" ]; -then - echo "Using cached directory." -else - echo "Setting up BYOND." - mkdir -p "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}" - cd "$HOME/BYOND-${BYOND_MAJOR}.${BYOND_MINOR}" - curl "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip - unzip byond.zip - cd byond - make here -fi diff --git a/tools/travis/build_nanoui.sh b/tools/travis/build_nanoui.sh new file mode 100755 index 00000000000..84f38172607 --- /dev/null +++ b/tools/travis/build_nanoui.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -euo pipefail + +npm install -g gulp-cli +cd nano +npm install --loglevel=error +node node_modules/gulp/bin/gulp.js --require less-loader diff --git a/tools/travis/check_changelogs.sh b/tools/travis/check_changelogs.sh new file mode 100755 index 00000000000..0aab5e388ca --- /dev/null +++ b/tools/travis/check_changelogs.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -euo pipefail + +md5sum -c - <<< "6dc1b6bf583f3bd4176b6df494caa5f1 *html/changelogs/example.yml" +python tools/ss13_genchangelog.py html/changelog.html html/changelogs diff --git a/tools/travis/check_grep.sh b/tools/travis/check_grep.sh old mode 100644 new mode 100755 diff --git a/tools/travis/dm.sh b/tools/travis/dm.sh new file mode 100755 index 00000000000..6bb00a65d7f --- /dev/null +++ b/tools/travis/dm.sh @@ -0,0 +1,97 @@ +#!/bin/bash + +dmepath="" +retval=1 + +for var +do + if [[ $var != -* && $var == *.dme ]] + then + dmepath=`echo $var | sed -r 's/.{4}$//'` + break + fi +done + +if [[ $dmepath == "" ]] +then + echo "No .dme file specified, aborting." + exit 1 +fi + +if [[ -a $dmepath.mdme ]] +then + rm $dmepath.mdme +fi + +cp $dmepath.dme $dmepath.mdme +if [[ $? != 0 ]] +then + echo "Failed to make modified dme, aborting." + exit 2 +fi + +for var +do + arg=`echo $var | sed -r 's/^.{2}//'` + if [[ $var == -D* ]] + then + sed -i '1s/^/#define '$arg'\n/' $dmepath.mdme + continue + fi + if [[ $var == -M* ]] + then + sed -i '1s/^/#define MAP_OVERRIDE\n/' $dmepath.mdme + sed -i 's!// BEGIN_INCLUDE!// BEGIN_INCLUDE\n#include "_maps\\'$arg'.dm"!' $dmepath.mdme + continue + fi +done + +#windows +if [[ `uname` == MINGW* ]] +then + dm="" + + if hash dm.exe 2>/dev/null + then + dm='dm.exe' + elif [[ -a '/c/Program Files (x86)/BYOND/bin/dm.exe' ]] + then + dm='/c/Program Files (x86)/BYOND/bin/dm.exe' + elif [[ -a '/c/Program Files/BYOND/bin/dm.exe' ]] + then + dm='/c/Program Files/BYOND/bin/dm.exe' + fi + + if [[ $dm == "" ]] + then + echo "Couldn't find the DreamMaker executable, aborting." + exit 3 + fi + + "$dm" $dmepath.mdme 2>&1 | tee result.log + retval=$? + if ! grep '\- 0 errors, 0 warnings' result.log + then + retval=1 #hard fail, due to warnings or errors + fi +else + if hash DreamMaker 2>/dev/null + then + DreamMaker -max_errors 0 $dmepath.mdme 2>&1 | tee result.log + retval=$? + if ! grep '\- 0 errors, 0 warnings' result.log + then + retval=1 #hard fail, due to warnings or errors + fi + else + echo "Couldn't find the DreamMaker executable, aborting." + exit 3 + fi +fi + +mv $dmepath.mdme.dmb $dmepath.dmb +mv $dmepath.mdme.rsc $dmepath.rsc + +rm $dmepath.mdme + +exit $retval diff --git a/tools/travis/install_build_deps.sh b/tools/travis/install_build_deps.sh new file mode 100755 index 00000000000..224687f0882 --- /dev/null +++ b/tools/travis/install_build_deps.sh @@ -0,0 +1,12 @@ +#!/bin/bash +set -euo pipefail + +source dependencies.sh + +source ~/.nvm/nvm.sh +nvm install $NODE_VERSION + +pip3 install --user PyYaml +pip3 install --user beautifulsoup4 + +phpenv global $PHP_VERSION diff --git a/tools/travis/install_byond.sh b/tools/travis/install_byond.sh new file mode 100755 index 00000000000..4a688755d3d --- /dev/null +++ b/tools/travis/install_byond.sh @@ -0,0 +1,21 @@ +#!/bin/bash +set -euo pipefail + +source dependencies.sh + +if [ -d "$HOME/BYOND/byond/bin" ] && grep -Fxq "${BYOND_MAJOR}.${BYOND_MINOR}" $HOME/BYOND/version.txt; +then + echo "Using cached directory." +else + echo "Setting up BYOND." + rm -rf "$HOME/BYOND" + mkdir -p "$HOME/BYOND" + cd "$HOME/BYOND" + curl "http://www.byond.com/download/build/${BYOND_MAJOR}/${BYOND_MAJOR}.${BYOND_MINOR}_byond_linux.zip" -o byond.zip + unzip byond.zip + rm byond.zip + cd byond + make here + echo "$BYOND_MAJOR.$BYOND_MINOR" > "$HOME/BYOND/version.txt" + cd ~/ +fi diff --git a/tools/travis/json_verifier.py b/tools/travis/json_verifier.py new file mode 100644 index 00000000000..aa746206674 --- /dev/null +++ b/tools/travis/json_verifier.py @@ -0,0 +1,20 @@ +import sys +import json + +if len(sys.argv) <= 1: + exit(1) + +status = 0 + +for file in sys.argv[1:]: + with open(file, encoding="ISO-8859-1") as f: + try: + json.load(f) + except ValueError as exception: + print("JSON error in {}".format(file)) + print(exception) + status = 1 + else: + print("Valid {}".format(file)) + +exit(status)