Skip to content

Commit 765ab9a

Browse files
[qa] Add shell scripts checking and formatting
Closes #55
1 parent ceb53c2 commit 765ab9a

9 files changed

Lines changed: 363 additions & 291 deletions

File tree

.editorconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# config file for shell formatter
2+
3+
[*]
4+
binary_next_line = true # like -bn
5+
switch_case_indent = true # like -ci

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ jobs:
3434

3535
- name: QA-Checks
3636
run: ./run-qa-checks
37+
env:
38+
CI: 1
39+
40+
- name: Run sh-checker
41+
uses: luizm/action-sh-checker@master
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
with:
45+
sh_checker_comment: true
3746

3847
- name: Tests
3948
run: ./runtests
@@ -43,7 +52,7 @@ jobs:
4352
cd openwrt-openwisp-monitoring/tests
4453
luacov-coveralls -v
4554
env:
46-
COVERALLS_REPO_TOKEN: ${{ github.token }}
55+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4756

4857
build:
4958
name: Build and upload package as artifacts

README.rst

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -175,30 +175,30 @@ You can inspect the version of openwisp-monitoring currently installed with::
175175
Quality Assurance Checks
176176
------------------------
177177

178-
We use `LuaFormatter <https://luarocks.org/modules/tammela/luaformatter>`_ to format lua files.
179-
Once it is installed, you can format all files by::
178+
We use `LuaFormatter <https://luarocks.org/modules/tammela/luaformatter>`_ and `shfmt <https://github.com/mvdan/sh#shfmt>`_ to format lua files and shell scripts respectively.
179+
180+
Once they are installed, you can format all files by::
180181

181182
./qa-format
182183

184+
Run quality assurance tests with::
185+
186+
#install openwisp-utils QA tools first
187+
pip install openwisp-utils[qa]
188+
189+
#run QA checks before committing code
190+
./run-qa-checks
191+
183192
Run tests
184193
---------
185194

186195
To run the unit tests, you must install the required dependencies first; to do this, you can take
187196
a look at the `install-dev.sh <https://github.com/openwisp/openwisp-config/blob/master/install-dev.sh>`_ script.
188197

189-
190198
Install test requirements::
191199

192200
sudo ./install-dev.sh
193201

194-
Run quality assurance tests with::
195-
196-
#install openwisp-utils QA tools first
197-
pip install openwisp-utils[qa]
198-
199-
#run QA checks before committing code
200-
./run-qa-checks
201-
202202
You can run all unit tests by launching the dedicated script::
203203

204204
./runtests

install-dev.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
#!/bin/sh
22
set -e
33
apt-get update
4-
#install cmake and git
4+
# install cmake and git
55
apt-get install -y cmake git
6-
#install lua
6+
# install shellcheck
7+
apt-get install shellcheck
8+
# install lua
79
apt-get install -y lua5.1 liblua5.1-0-dev luarocks
8-
#install json-c
10+
# install json-c
911
git clone https://github.com/json-c/json-c.git --depth=1
10-
cd json-c && cmake . && make install && cd .. || { echo 'Installing json-c failed!' ; exit 1; }
12+
{ cd json-c && cmake . && make install && cd ..; } || { echo 'Installing json-c failed!' && exit 1; }
1113
# install openwrt libubox and uci
1214
git clone https://git.openwrt.org/project/libubox.git --depth=1
13-
cd libubox && cmake . && make install && cd .. || { echo 'Installing libubox failed!' ; exit 1; }
15+
{ cd libubox && cmake . && make install && cd ..; } || { echo 'Installing libubox failed!' && exit 1; }
1416
git clone https://git.openwrt.org/project/uci.git --depth=1
15-
cd uci && cmake . && make install && cd .. || { echo 'Installing uci failed!' ; exit 1; }
16-
#install nixio
17+
{ cd uci && cmake . && make install && cd ..; } || { echo 'Installing uci failed!' && exit 1; }
18+
# install nixio
1719
luarocks install https://raw.githubusercontent.com/Neopallium/nixio/master/nixio-scm-0.rockspec
1820
# install luaformatter
1921
git clone --recurse-submodules https://github.com/Koihik/LuaFormatter.git
20-
cd LuaFormatter && cmake . && make install && cd .. || { echo 'Installing LuaFormatter failed'; exit 1; }
22+
{ cd LuaFormatter && cmake . && make install && cd ..; } || { echo 'Installing LuaFormatter failed' && exit 1; }
2123
# update links to shared libraries
2224
ldconfig -v
2325
# install luaunit
@@ -26,7 +28,7 @@ luarocks install luaunit
2628
luarocks install luacheck
2729
# install lua-cjson
2830
luarocks install lua-cjson
29-
#install luacov-coveralls
31+
# install luacov-coveralls
3032
luarocks install luacov-coveralls
31-
#clean
33+
# clean
3234
rm -rf json-c libubox uci LuaFormatter

0 commit comments

Comments
 (0)