From addc51f0d663813da2cd2c9f019b3ca5034981f3 Mon Sep 17 00:00:00 2001 From: Kapil Bansal Date: Thu, 17 Jun 2021 18:06:49 +0530 Subject: [PATCH] [ci] Add Github CI Workflow #27 Closes #27 --- .github/workflows/ci.yml | 3 +++ README.rst | 8 ++++++++ install-dev.sh | 20 +++++++++++++++++++- openwrt-openwisp-monitoring/tests/env1.lua | 3 --- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 77ce0a6..3210044 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,9 @@ jobs: - name: QA-Checks run: ./run-qa-checks + - name: Tests + run: ./runtests + build: name: Build and upload package as artifacts needs: tests diff --git a/README.rst b/README.rst index 10df18f..1383269 100644 --- a/README.rst +++ b/README.rst @@ -136,6 +136,14 @@ Run quality assurance tests with:: ./run-qa-checks +You can run all unit tests by launching the dedicated script:: + + ./runtests + +Alternatively, you can run specific tests, e.g.:: + + cd openwrt-openwisp-monitoring/tests/ + lua test_utils.lua -v Contributing ------------ diff --git a/install-dev.sh b/install-dev.sh index 180012f..9a8f9c2 100755 --- a/install-dev.sh +++ b/install-dev.sh @@ -1,9 +1,27 @@ #!/bin/sh set -e apt-get update -# install lua +#install cmake and git +apt-get install -y cmake git +#install lua apt-get install -y lua5.1 liblua5.1-0-dev luarocks +#install json-c +git clone https://github.com/json-c/json-c.git --depth=1 +cd json-c && cmake . && make install && cd .. || { echo 'Installing json-c failed!' ; exit 1; } +# install openwrt libubox and uci +git clone https://git.openwrt.org/project/libubox.git --depth=1 +cd libubox && cmake . && make install && cd .. || { echo 'Installing libubox failed!' ; exit 1; } +git clone https://git.openwrt.org/project/uci.git --depth=1 +cd uci && cmake . && make install && cd .. || { echo 'Installing uci failed!' ; exit 1; } +#install nixio +luarocks install https://raw.githubusercontent.com/Neopallium/nixio/master/nixio-scm-0.rockspec # update links to shared libraries ldconfig -v +# install luaunit +luarocks install luaunit # install luacheck luarocks install luacheck +# install lua-cjson +luarocks install lua-cjson +#clean +rm -rf json-c libubox uci diff --git a/openwrt-openwisp-monitoring/tests/env1.lua b/openwrt-openwisp-monitoring/tests/env1.lua index ee9f1f9..72928f3 100644 --- a/openwrt-openwisp-monitoring/tests/env1.lua +++ b/openwrt-openwisp-monitoring/tests/env1.lua @@ -1,12 +1,9 @@ package.path = package.path .. ";../files/lib/?.lua" -local inspect = require('inspect') local env = {} local dhcp_data = require('test_files/dhcp_data') local test_file_dir = './test_files/' -env.inspect = inspect - env.uci = { cursor = function() return {