Skip to content

Commit

Permalink
[ci] Add code coverage and upload to coveralls
Browse files Browse the repository at this point in the history
  • Loading branch information
devkapilbansal committed Jul 11, 2021
1 parent 88bbcd6 commit 70d360d
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 10 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ jobs:
- name: Tests
run: ./runtests

- name: Upload Coverage
run: luacov-coveralls -v -o openwrt-openwisp-monitoring/tests/luacov.report.out

build:
name: Build and upload package as artifacts
needs: tests
Expand Down
2 changes: 2 additions & 0 deletions install-dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@ luarocks install luaunit
luarocks install luacheck
# install lua-cjson
luarocks install lua-cjson
#install luacov-coveralls
luarocks install luacov-coveralls
#clean
rm -rf json-c libubox uci
5 changes: 5 additions & 0 deletions openwrt-openwisp-monitoring/tests/.luacov
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
return {
['exclude'] = {
'luaunit$'
},
}
File renamed without changes.
2 changes: 1 addition & 1 deletion openwrt-openwisp-monitoring/tests/test_dhcp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local luaunit = require('luaunit')

TestDhcp = {
setUp = function()
local env = require('env1')
local env = require('main_env')
package.loaded.uci = env.uci
package.loaded.io = env.io
end,
Expand Down
2 changes: 1 addition & 1 deletion openwrt-openwisp-monitoring/tests/test_interfaces.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local interface_data = require('test_files/interface_data')

TestInterface = {
setUp = function()
local env = require('env1')
local env = require('main_env')
package.loaded.uci = env.uci
package.loaded.ubus = env.ubus
package.loaded.io = env.io
Expand Down
2 changes: 1 addition & 1 deletion openwrt-openwisp-monitoring/tests/test_neighbors.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local neighbor_data = require('test_files/neighbors_data')

TestNeighbor = {
setUp = function()
local env = require('env1')
local env = require('main_env')
package.loaded.io = env.io
end,
tearDown = function()
Expand Down
2 changes: 1 addition & 1 deletion openwrt-openwisp-monitoring/tests/test_resources.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local resources_data = require('test_files/resources_data')

TestResources = {
setUp = function()
local env = require('env1')
local env = require('main_env')
package.loaded.io = env.io
end,
tearDown = function()
Expand Down
15 changes: 9 additions & 6 deletions runtests
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
set -e

cd openwrt-openwisp-monitoring/tests/
lua test_dhcp.lua -v
lua test_interfaces.lua -v
lua test_utils.lua -v
lua test_neighbors.lua -v
lua test_resources.lua -v
lua test_wifi.lua -v
# run tests
lua -lluacov test_dhcp.lua -v
lua -lluacov test_interfaces.lua -v
lua -lluacov test_utils.lua -v
lua -lluacov test_neighbors.lua -v
lua -lluacov test_resources.lua -v
lua -lluacov test_wifi.lua -v
# send stats file to root directory
mv luacov.stats.out ../../

0 comments on commit 70d360d

Please sign in to comment.