diff --git a/.travis.yml b/.travis.yml index 91cc8c8a60f..e781533ca0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,34 @@ language: generic +dist: xenial sudo: false + branches: except: - ___TGS3TempBranch - ___TGSTempBranch + matrix: include: - - env: - - BUILD_TOOLS=true - name: "Build Tools" + - name: "Run Linters" addons: apt: packages: - python3 - python3-pip - cache: - directories: - - tgui/node_modules - - env: - - BUILD_TESTING=true - - BUILD_TOOLS=false - name: "Build All Maps" + - python3-setuptools + install: + - tools/travis/install_build_tools.sh + - tools/travis/install_spaceman_dmm.sh dreamchecker + script: + - tools/travis/check_filedirs.sh tgstation.dme + - tools/travis/check_changelogs.sh + - find . -name "*.php" -print0 | xargs -0 -n1 php -l + - find . -name "*.json" -not -path "./tgui/node_modules/*" -print0 | xargs -0 python3 ./tools/json_verifier.py + - tools/travis/build_tgui.sh + - tools/travis/check_grep.sh + - ~/dreamchecker + + - name: "Compile All Maps" addons: apt: packages: @@ -28,10 +36,15 @@ matrix: cache: directories: - $HOME/BYOND - - env: - - BUILD_TESTING=false - - BUILD_TOOLS=false - name: "Build and Run Unit Tests" + install: + - tools/travis/install_byond.sh + - source $HOME/BYOND/byond/bin/byondsetup + before_script: + - tools/travis/template_dm_generator.py + script: + - tools/travis/dm.sh -DTRAVISBUILDING -DTRAVISTESTING -DALL_MAPS tgstation.dme + + - name: "Compile and Run Tests" addons: mariadb: '10.2' apt: @@ -39,32 +52,42 @@ matrix: - ubuntu-toolchain-r-test packages: - libstdc++6:i386 - - libssl-dev:i386 - gcc-multilib - g++-7 - g++-7-multilib - - libmariadbclient-dev:i386 + - libmariadb-client-lgpl-dev:i386 + - libmariadbd-dev cache: directories: - - $HOME/.cargo - $HOME/BYOND - - $HOME/MariaDB - - $HOME/.rustup - -install: - - tools/travis/install_build_tools.sh - - if [ $BUILD_TOOLS = false ] && [ $BUILD_TESTING = false ]; then mysql -u root -e 'CREATE DATABASE tg_travis;'; fi - - if [ $BUILD_TOOLS = false ] && [ $BUILD_TESTING = false ]; then mysql -u root tg_travis < SQL/tgstation_schema.sql; fi - - if [ $BUILD_TOOLS = false ] && [ $BUILD_TESTING = false ]; then mysql -u root -e 'CREATE DATABASE tg_travis_prefixed;'; fi - - if [ $BUILD_TOOLS = false ] && [ $BUILD_TESTING = false ]; then mysql -u root tg_travis_prefixed < SQL/tgstation_schema_prefixed.sql; fi - -before_script: - - tools/travis/before_build_tools.sh - - tools/travis/before_build_byond.sh - -script: - - tools/travis/check_filedirs.sh DeepSpace13.dme - - tools/travis/build_tools.sh || travis_terminate 1 - - tools/travis/build_dependencies.sh || travis_terminate 1 - - tools/travis/build_byond.sh + - $HOME/libmariadb + install: + - tools/travis/install_byond.sh + - source $HOME/BYOND/byond/bin/byondsetup + - tools/travis/install_libmariadb.sh + - tools/travis/install_rust_g.sh + before_script: + - mysql -u root -e 'CREATE DATABASE tg_travis;' + - mysql -u root tg_travis < SQL/tgstation_schema.sql + - mysql -u root -e 'CREATE DATABASE tg_travis_prefixed;' + - mysql -u root tg_travis_prefixed < SQL/tgstation_schema_prefixed.sql + - tools/travis/build_bsql.sh + script: + - tools/travis/dm.sh -DTRAVISBUILDING tgstation.dme || travis_terminate 1 + - tools/travis/run_server.sh + - name: "Generate Documentation" + # Only run for non-PR commits to the real master branch. + if: branch = master AND head_branch IS blank + install: + - tools/travis/install_spaceman_dmm.sh dmdoc + before_script: + # Travis checks out a hash, try to get back on a branch. + - git checkout $TRAVIS_BRANCH || true + script: + - ~/dmdoc + deploy: + provider: pages + skip_cleanup: true + local_dir: dmdoc + github_token: $DMDOC_GITHUB_TOKEN diff --git a/tools/travis/before_build_tools.sh b/tools/travis/before_build_tools.sh deleted file mode 100755 index 2329de82b2c..00000000000 --- a/tools/travis/before_build_tools.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash -set -e - -if [ "$BUILD_TOOLS" = true ]; then - cd tgui && source ~/.nvm/nvm.sh && npm install && cd .. -fi; - diff --git a/tools/travis/build_bsql.sh b/tools/travis/build_bsql.sh new file mode 100644 index 00000000000..e2b281efc64 --- /dev/null +++ b/tools/travis/build_bsql.sh @@ -0,0 +1,21 @@ +#!/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 diff --git a/tools/travis/build_byond.sh b/tools/travis/build_byond.sh deleted file mode 100755 index 60c4b2bbc6d..00000000000 --- a/tools/travis/build_byond.sh +++ /dev/null @@ -1,80 +0,0 @@ -#!/bin/bash - -#nb: must be bash to support shopt globstar -set -e -shopt -s globstar - -if [ "$BUILD_TOOLS" = false ]; then - if grep -E '^\".+\" = \(.+\)' _maps/**/*.dmm; then - echo "Non-TGM formatted map detected. Please convert it using Map Merger!" - exit 1 - fi; - if grep -P '^\ttag = \"icon' _maps/**/*.dmm; then - echo "tag vars from icon state generation detected in maps, please remove them." - exit 1 - fi; - if grep 'step_[xy]' _maps/**/*.dmm; then - echo "step_x/step_y variables detected in maps, please remove them." - exit 1 - fi; - if grep '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; - if grep -P '\td[1-2] =' _maps/**/*.dmm; then - echo "d1/d2 cable variables detected in maps, please remove them." - exit 1 - fi; - if grep '^/area/.+[\{]' _maps/**/*.dmm; then - echo "Vareditted /area path use detected in maps, please replace with proper paths." - exit 1 - fi; - if grep '\W\/turf\s*[,\){]' _maps/**/*.dmm; then - echo "base /turf path use detected in maps, please replace with proper paths." - exit 1 - fi; - if grep '^/*var/' code/**/*.dm; then - echo "Unmanaged global var use detected in code, please use the helpers." - exit 1 - fi; - if grep -i 'centcomm' code/**/*.dm; then - echo "Misspelling(s) of CENTCOM detected in code, please remove the extra M(s)." - exit 1 - fi; - if grep -i 'centcomm' _maps/**/*.dmm; then - echo "Misspelling(s) of CENTCOM detected in maps, please remove the extra M(s)." - exit 1 - fi; - - source $HOME/BYOND/byond/bin/byondsetup - if [ "$BUILD_TESTING" = true ]; then - tools/travis/dm.sh -DTRAVISBUILDING -DTRAVISTESTING -DALL_MAPS DeepSpace13.dme - else - tools/travis/dm.sh -DTRAVISBUILDING DeepSpace13.dme - - tools/deploy.sh travis_test - mkdir travis_test/config - - #test config - cp tools/travis/travis_config.txt travis_test/config/config.txt - - # 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 - - cd travis_test - ln -s $HOME/libmariadb/libmariadb.so libmariadb.so - DreamDaemon DeepSpace13.dmb -close -trusted -verbose -params "test-run&log-directory=travis" - cd .. - cat travis_test/data/logs/travis/clean_run.lk - - fi; -fi; diff --git a/tools/travis/build_dependencies.sh b/tools/travis/build_dependencies.sh deleted file mode 100755 index 9e594733ea7..00000000000 --- a/tools/travis/build_dependencies.sh +++ /dev/null @@ -1,64 +0,0 @@ -#!/usr/bin/env bash - -set -e - -source dependencies.sh - -#ensure the Dockerfile version matches the dependencies.sh version -line=$(head -n 1 Dockerfile) -if [[ $line != *"$BYOND_MAJOR.$BYOND_MINOR"* ]]; then - echo "Dockerfile BYOND version in FROM command does not match dependencies.sh (Or it's not on line 1)!" - exit 1 -fi - -if [ $BUILD_TOOLS = false ] && [ $BUILD_TESTING = false ]; then - curl https://sh.rustup.rs -sSf | sh -s -- -y --default-host i686-unknown-linux-gnu - source ~/.profile - - mkdir rust-g - cd rust-g - git init - git remote add origin https://github.com/tgstation/rust-g - git fetch --depth 1 origin $RUST_G_VERSION - git checkout FETCH_HEAD - cargo build --release - cmp target/rust_g.dm ../code/__DEFINES/rust_g.dm - - mkdir -p ~/.byond/bin - ln -s $PWD/target/release/librust_g.so ~/.byond/bin/rust_g - - mkdir -p ../BSQL/artifacts - cd ../BSQL - git init - git remote add origin https://github.com/tgstation/BSQL - git fetch --depth 1 origin $BSQL_VERSION - git checkout FETCH_HEAD - - if [ -f "$HOME/MariaDB/libmariadb.so.2" ] && [ -f "$HOME/MariaDB/libmariadb.so" ] && [ -d "$HOME/MariaDB/include" ]; - then - echo "Using cached MariaDB library." - else - echo "Setting up MariaDB." - rm -rf "$HOME/MariaDB" - mkdir -p "$HOME/MariaDB" - wget http://mirrors.kernel.org/ubuntu/pool/universe/m/mariadb-client-lgpl/libmariadb2_2.0.0-1_i386.deb - dpkg -x libmariadb2_2.0.0-1_i386.deb /tmp/extract - rm libmariadb2_2.0.0-1_i386.deb - mv /tmp/extract/usr/lib/i386-linux-gnu/libmariadb.so.2 $HOME/MariaDB/ - ln -s $HOME/MariaDB/libmariadb.so.2 $HOME/MariaDB/libmariadb.so - rm -rf /tmp/extract - - wget http://mirrors.kernel.org/ubuntu/pool/universe/m/mariadb-connector-c/libmariadb-dev_2.3.3-1_i386.deb - dpkg -x libmariadb-dev_2.3.3-1_i386.deb /tmp/extract - rm libmariadb-dev_2.3.3-1_i386.deb - mv /tmp/extract/usr/include $HOME/MariaDB/ - #fuck what is this even? - mv $HOME/MariaDB/include/mariadb $HOME/MariaDB/include/mysql - fi - - cd artifacts - export CXX=g++-7 - cmake .. -DMARIA_INCLUDE_DIR=$HOME/MariaDB/include - make - mv src/BSQL/libBSQL.so ../../ -fi diff --git a/tools/travis/build_tgui.sh b/tools/travis/build_tgui.sh new file mode 100644 index 00000000000..0141f3e117b --- /dev/null +++ b/tools/travis/build_tgui.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -euo pipefail + +cd tgui +source ~/.nvm/nvm.sh +npm ci +node node_modules/gulp/bin/gulp.js --min diff --git a/tools/travis/build_tools.sh b/tools/travis/build_tools.sh deleted file mode 100755 index eaccd64c8c1..00000000000 --- a/tools/travis/build_tools.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -#must also be bash for the md5sum commands -set -e - -if [ "$BUILD_TOOLS" = true ]; -then - md5sum -c - <<< "49bc6b1b9ed56c83cceb6674bd97cb34 *html/changelogs/example.yml"; - (cd tgui && source ~/.nvm/nvm.sh && npm ci && node node_modules/gulp/bin/gulp.js --min) - phpenv global 5.6 - php -l tools/WebhookProcessor/github_webhook_processor.php; - php -l tools/TGUICompiler.php; - echo "Checking for JSON errors"; - find . -name "*.json" -not -path "./tgui/node_modules/*" | xargs -0 python3 ./tools/json_verifier.py; - python3 tools/ss13_genchangelog.py html/changelog.html html/changelogs; -fi; diff --git a/tools/travis/check_changelogs.sh b/tools/travis/check_changelogs.sh new file mode 100644 index 00000000000..e33c0e6df39 --- /dev/null +++ b/tools/travis/check_changelogs.sh @@ -0,0 +1,5 @@ +#!/bin/bash +set -euo pipefail + +md5sum -c - <<< "49bc6b1b9ed56c83cceb6674bd97cb34 *html/changelogs/example.yml" +python3 tools/ss13_genchangelog.py html/changelog.html html/changelogs diff --git a/tools/travis/check_grep.sh b/tools/travis/check_grep.sh new file mode 100644 index 00000000000..2117b570eb4 --- /dev/null +++ b/tools/travis/check_grep.sh @@ -0,0 +1,49 @@ +#!/bin/bash +set -euo pipefail + +#nb: must be bash to support shopt globstar +shopt -s globstar + +st=0 + +if grep -El '^\".+\" = \(.+\)' _maps/**/*.dmm; then + echo "Non-TGM formatted map detected. Please convert it using Map Merger!" + st=1 +fi; +if grep -P '^\ttag = \"icon' _maps/**/*.dmm; then + echo "tag vars from icon state generation detected in maps, please remove them." + st=1 +fi; +if grep 'step_[xy]' _maps/**/*.dmm; then + echo "step_x/step_y variables detected in maps, please remove them." + st=1 +fi; +if grep '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; +if grep -P '\td[1-2] =' _maps/**/*.dmm; then + echo "d1/d2 cable variables detected in maps, please remove them." + st=1 +fi; +if grep '^/area/.+[\{]' _maps/**/*.dmm; then + echo "Vareditted /area path use detected in maps, please replace with proper paths." + st=1 +fi; +if grep '\W\/turf\s*[,\){]' _maps/**/*.dmm; then + echo "base /turf path use detected in maps, please replace with proper paths." + st=1 +fi; +if grep '^/*var/' code/**/*.dm; then + echo "Unmanaged global var use detected in code, please use the helpers." + st=1 +fi; +if grep -i 'centcomm' code/**/*.dm; then + echo "Misspelling(s) of CENTCOM detected in code, please remove the extra M(s)." + st=1 +fi; +if grep -i 'centcomm' _maps/**/*.dmm; then + echo "Misspelling(s) of CENTCOM detected in maps, please remove the extra M(s)." + st=1 +fi; + +exit $st diff --git a/tools/travis/install_build_tools.sh b/tools/travis/install_build_tools.sh index 9dd73f854cc..224687f0882 100755 --- a/tools/travis/install_build_tools.sh +++ b/tools/travis/install_build_tools.sh @@ -1,12 +1,12 @@ #!/bin/bash -set -e +set -euo pipefail source dependencies.sh -if [ "$BUILD_TOOLS" = true ]; then - rm -rf ~/.nvm && git clone https://github.com/creationix/nvm.git ~/.nvm && (cd ~/.nvm && git checkout `git describe --abbrev=0 --tags`) && source ~/.nvm/nvm.sh && nvm install $NODE_VERSION - pip3 install --user PyYaml -q - pip3 install --user beautifulsoup4 -q -fi; +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/before_build_byond.sh b/tools/travis/install_byond.sh old mode 100755 new mode 100644 similarity index 67% rename from tools/travis/before_build_byond.sh rename to tools/travis/install_byond.sh index 55afb07ffe5..4a688755d3d --- a/tools/travis/before_build_byond.sh +++ b/tools/travis/install_byond.sh @@ -1,15 +1,5 @@ #!/bin/bash -set -e - -#If this is the build tools step, we do not bother to install/build byond -if [ "$BUILD_TOOLS" = true ]; then - exit 0 -fi - -echo "Combining maps for building" -if [ $BUILD_TESTING = true ]; then - python tools/travis/template_dm_generator.py -fi +set -euo pipefail source dependencies.sh diff --git a/tools/travis/install_libmariadb.sh b/tools/travis/install_libmariadb.sh new file mode 100644 index 00000000000..d0ce4adc145 --- /dev/null +++ b/tools/travis/install_libmariadb.sh @@ -0,0 +1,15 @@ +#!/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 diff --git a/tools/travis/install_rust_g.sh b/tools/travis/install_rust_g.sh new file mode 100644 index 00000000000..227034af66a --- /dev/null +++ b/tools/travis/install_rust_g.sh @@ -0,0 +1,8 @@ +#!/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 diff --git a/tools/travis/install_spaceman_dmm.sh b/tools/travis/install_spaceman_dmm.sh new file mode 100644 index 00000000000..39464193f88 --- /dev/null +++ b/tools/travis/install_spaceman_dmm.sh @@ -0,0 +1,8 @@ +#!/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 diff --git a/tools/travis/run_server.sh b/tools/travis/run_server.sh new file mode 100644 index 00000000000..975e8f68849 --- /dev/null +++ b/tools/travis/run_server.sh @@ -0,0 +1,14 @@ +#!/bin/bash +set -euo pipefail + +tools/deploy.sh travis_test +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 diff --git a/tools/travis/template_dm_generator.py b/tools/travis/template_dm_generator.py index 89e1d2647d9..970fba7db45 100755 --- a/tools/travis/template_dm_generator.py +++ b/tools/travis/template_dm_generator.py @@ -1,7 +1,6 @@ #!/usr/bin/env python import os -import os.path import sys folders = ["_maps/RandomRuins", "_maps/RandomZLevels", "_maps/shuttles",