diff options
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/run-tests.yml | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..dfa637c --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,130 @@ +name: Run tests + +on: + workflow_dispatch: + pull_request: + push: + branches: + - master + +jobs: + Build-and-Test: + #if: ${{ false }} # disable for now + strategy: + fail-fast: false + matrix: + distro: ["ubuntu-22.04", "ubuntu-20.04"] + + runs-on: ${{ matrix.distro }} + steps: + - name: Install build tools (using apt) + run: > + sudo apt update && + sudo apt -y install git build-essential cmake gcc linux-headers-`uname -r` + libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + iproute2 ppp pppoe isc-dhcp-client + + - name: Install testing tools (using pip) + run: > + sudo pip3 install pytest pytest-dependency gcovr + + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: mkdir build + run: mkdir build + + - name: cmake (with coverage) + working-directory: ./build + run: > + cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr + -DKDIR=/usr/src/linux-headers-`uname -r` + -DLUA=TRUE -DSHAPER=TRUE -DRADIUS=TRUE .. + + - name: make && make install + working-directory: ./build + run: make && sudo make install + + - name: Insert and check kernel modules (ipoe and vlan-mon) + # if: ${{ false }} + run: | + sudo insmod build/drivers/vlan_mon/driver/vlan_mon.ko + sudo insmod build/drivers/ipoe/driver/ipoe.ko + lsmod | grep ipoe + lsmod | grep vlan_mon + + - name: Run tests + working-directory: ./tests + run: sudo python3 -m pytest -Wall -v + + Build-and-Test-With-Coverage: + #if: ${{ false }} # disable for now + strategy: + fail-fast: false + matrix: + distro: ["ubuntu-22.04", "ubuntu-20.04"] + + runs-on: ${{ matrix.distro }} + steps: + - name: Install build tools (using apt) + run: > + sudo apt update && + sudo apt -y install git build-essential cmake gcc linux-headers-`uname -r` + libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + iproute2 ppp pppoe isc-dhcp-client + + - name: Install testing tools (using pip) + run: > + sudo pip3 install pytest pytest-dependency gcovr + + - name: Check out repository code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: mkdir build + run: mkdir build + + - name: cmake (with coverage) + working-directory: ./build + run: > + cmake -DBUILD_IPOE_DRIVER=TRUE -DBUILD_VLAN_MON_DRIVER=TRUE -DCMAKE_INSTALL_PREFIX=/usr + -DKDIR=/usr/src/linux-headers-`uname -r` + -DLUA=TRUE -DSHAPER=TRUE -DRADIUS=TRUE + -DCMAKE_C_FLAGS="--coverage -O0" .. + + - name: make && make install + working-directory: ./build + run: make && sudo make install + + - name: Insert and check kernel modules (ipoe and vlan-mon) + # if: ${{ false }} + run: | + sudo insmod build/drivers/vlan_mon/driver/vlan_mon.ko + sudo insmod build/drivers/ipoe/driver/ipoe.ko + lsmod | grep ipoe + lsmod | grep vlan_mon + + - name: Run tests (for coverage report) (fail is ok) + working-directory: ./tests + run: sudo python3 -m pytest -Wall -v || exit 0 + + - name: Generate coverage reports (default(txt), csv, html) + run: | + mkdir -p tests/report + gcovr --config=tests/gcovr.conf --output=tests/report/accel-ppp.txt + gcovr --config=tests/gcovr.conf --csv --output=tests/report/accel-ppp.csv + gcovr --config=tests/gcovr.conf --html --html-details --output=tests/report/accel-ppp.html + + - name: Show default coverage report + run: cat tests/report/accel-ppp.txt + + - name: Upload coverage report + # if: ${{ false }} + uses: actions/upload-artifact@v3 + with: + name: coverage-report-on-${{ matrix.distro }} + path: tests/report/ + if-no-files-found: error |