|
| 1 | +# Using CuberitePluginChecker in a CI |
| 2 | + |
| 3 | +The main aim of this project is to be used in CI for other Cuberite plugins. This has been tested on the following CI providers: |
| 4 | + - CircleCI |
| 5 | + - Travis |
| 6 | + |
| 7 | +Typically, the plugins to be tested need to define scenario files (preferably in a subfolder so that they can use the .lua extension and Cuberite doesn't load them), and add a CI-specific configuration file. In the CI environment, it's necessary to install Lua, all the needed Lua libraries, download the Checker and any supporting code (such as InfoReg.lua) from Cuberite. |
| 8 | + |
| 9 | +The CI providers vary in the amount of freedom they provide for project builds, and the "build" times. The total time of the "build" consists of machine setup (installing all dependencies, downloading libraries etc.) and the atual Checker run time, which is usually negligible. Travis is winning here, with setup times being under a minute, while CircleCI takes about two minutes for the machine setup. |
| 10 | + |
| 11 | +The following sections provide an example of the config files for the CI providers: |
| 12 | + |
| 13 | + |
| 14 | +## CircleCI |
| 15 | +CircleCI provides a clean machine with sudo access. There are no problems getting everything to work. Typical times for a CricleCI check is 2 minutes machine setup and 3 seconds Checker run. |
| 16 | + |
| 17 | +The circle.yml file should look something like this: |
| 18 | +``` |
| 19 | +dependencies: |
| 20 | + pre: |
| 21 | + - sudo apt-get install lua5.1 luarocks libssl-dev |
| 22 | + - sudo luarocks install luafilesystem |
| 23 | + - sudo luarocks install lsqlite3 |
| 24 | + - sudo luarocks install luasocket |
| 25 | + - sudo luarocks install luasec OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu |
| 26 | + - git clone https://github.com/madmaxoft/CuberitePluginChecker ~/Checker |
| 27 | + - wget -O ~/InfoReg.lua https://raw.githubusercontent.com/cuberite/cuberite/master/Server/Plugins/InfoReg.lua |
| 28 | + - mkdir ~/AutoAPI |
| 29 | + - wget -O ~/AutoAPI.zip https://builds.cuberite.org/job/Cuberite%20Windows%20x64%20Master/lastSuccessfulBuild/artifact/AutoAPI.zip |
| 30 | + - unzip ~/AutoAPI.zip -d ~/AutoAPI |
| 31 | + - wget -O ~/ManualAPI.zip https://builds.cuberite.org/job/Cuberite%20Windows%20x64%20Master/lastSuccessfulBuild/artifact/ManualAPI.zip |
| 32 | + - unzip ~/ManualAPI.zip -d ~ |
| 33 | +
|
| 34 | +test: |
| 35 | + override: |
| 36 | + - cd ~/Checker && lua CuberitePluginChecker.lua -p ~/$CIRCLE_PROJECT_REPONAME -a ~/AutoAPI -e ~/ManualAPI.lua -i APIImpl/All.lua -s ~/$CIRCLE_PROJECT_REPONAME/tests/FuzzCommands.lua -g |
| 37 | +``` |
| 38 | + |
| 39 | +## Travis |
| 40 | +Travis can either use sudo, or have (much) faster builds. We decided to try for the faster builds, not requiring sudo. That means that luarocks need to be installed locally. Additionally, luarocks on Travis seems to have trouble cloning the `luasec` rock from git, so as a workaround we build the rock manually. |
| 41 | +Typical times for a Travis CI check is 45 seconds machine setup and 3 seconds Checker run. |
| 42 | + |
| 43 | +The .travis.yml file should look something like this: |
| 44 | +``` |
| 45 | +sudo: false |
| 46 | +
|
| 47 | +addons: |
| 48 | + apt: |
| 49 | + packages: |
| 50 | + - lua5.1 |
| 51 | + - luarocks |
| 52 | +
|
| 53 | +install: |
| 54 | + - luarocks --local install luafilesystem |
| 55 | + - luarocks --local install lsqlite3 |
| 56 | + - luarocks --local install luasocket |
| 57 | + - git clone --depth=1 --branch=luasec-0.6 git://github.com/brunoos/luasec.git |
| 58 | + - cd luasec && luarocks --local make OPENSSL_LIBDIR=/usr/lib/x86_64-linux-gnu/ |
| 59 | + - wget -O $TRAVIS_BUILD_DIR/../InfoReg.lua https://raw.githubusercontent.com/cuberite/cuberite/master/Server/Plugins/InfoReg.lua |
| 60 | + - mkdir ~/AutoAPI |
| 61 | + - wget -O ~/AutoAPI.zip --no-check-certificate https://builds.cuberite.org/job/Cuberite%20Windows%20x64%20Master/lastSuccessfulBuild/artifact/AutoAPI.zip |
| 62 | + - unzip ~/AutoAPI.zip -d ~/AutoAPI |
| 63 | + - wget -O ~/ManualAPI.zip --no-check-certificate https://builds.cuberite.org/job/Cuberite%20Windows%20x64%20Master/lastSuccessfulBuild/artifact/ManualAPI.zip |
| 64 | + - unzip ~/ManualAPI.zip -d ~ |
| 65 | + - git clone https://github.com/cuberite/CuberitePluginChecker ~/Checker |
| 66 | +
|
| 67 | +script: |
| 68 | + - eval `luarocks path --bin` && cd ~/Checker && lua CuberitePluginChecker.lua -p $TRAVIS_BUILD_DIR -a ~/AutoAPI -e ~/ManualAPI.lua -i APIImpl/All.lua -s $TRAVIS_BUILD_DIR/tests/FuzzCommands.lua -g |
| 69 | +``` |
0 commit comments