Developer Documentation

Note

This page is for developers who want to customize or extend OpenWISP Config, whether for bug fixes, new features, or contributions.

For user guides and general information, please see:

Compiling openwisp-config

The following procedure illustrates how to compile openwisp-config and its dependencies:

git clone https://github.com/openwrt/openwrt.git openwrt
cd openwrt
git checkout <openwrt-branch>

# configure feeds
echo "src-git openwisp https://github.com/openwisp/openwisp-config.git" > feeds.conf
cat feeds.conf.default >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
# any arch/target is fine because the package is architecture indipendent
arch="ar71xx"
echo "CONFIG_TARGET_$arch=y" > .config;
echo "CONFIG_PACKAGE_openwisp-config=y" >> .config
make defconfig
make tools/install
make toolchain/install
make package/openwisp-config/compile

Alternatively, you can configure your build interactively with make menuconfig, in this case you will need to select openwisp-config by going to Administration > openwisp:

git clone https://github.com/openwrt/openwrt.git openwrt
cd openwrt
git checkout <openwrt-branch>

# configure feeds
echo "src-git openwisp https://github.com/openwisp/openwisp-config.git" > feeds.conf
cat feeds.conf.default >> feeds.conf
./scripts/feeds update -a
./scripts/feeds install -a
make menuconfig
# go to Administration > openwisp and select the variant you need interactively
make -j1 V=s

Quality Assurance Checks

We use LuaFormatter and shfmt to format lua files and shell scripts respectively.

First of all, you will need install the lua packages mentioned above, then you can format all files with:

./qa-format

To run quality assurance checks you can use the run-qa-checks script:

# install openwisp-utils QA tools first
pip install openwisp-utils[qa]

# run QA checks before committing code
./run-qa-checks

Run tests

To run the unit tests, you must install the required dependencies first; to do this, you can take a look at the install-dev.sh script.

You can run all the unit tests by launching the dedicated script:

./runtests

Alternatively, you can run specific tests, e.g.:

cd openwisp-config/tests/
lua test_utils.lua -v