Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitHub action #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: 'Run tests'

on:
push:
pull_request:

jobs:
build_test:
strategy:
matrix:
include:
- compiler: "-DCMAKE_C_COMPILER=clang"
- compiler: "-DCMAKE_C_COMPILER=gcc"

name: Build and run tests
runs-on: ubuntu-latest
container:
image: debian:bookworm

steps:

- name: Add Debian experimental
run: |
echo "deb http://deb.debian.org/debian/ experimental main" >> /etc/apt/sources.list

- name: Install compiler
run: |
apt update
apt install -y cmake build-essential lua5.1 pkgconf libjson-c-dev liblua5.1-0-dev python3.11-venv clang libc++abi-dev libc++-dev
apt -t experimental install -y valgrind
useradd -ms /bin/bash buildbot

- name: Checkout libubox
uses: actions/checkout@v3
with:
repository: openwrt/libubox
path: libubox

- name: Checkout uci
uses: actions/checkout@v3
with:
path: uci

- name: Create build directory
run: mkdir libubox-build

- name: Create build directory
run: mkdir uci-build

- name: Create install directory
run: mkdir install

- name: Fix permission
run: chown -R buildbot:buildbot libubox-build libubox uci uci-build install

- name: Run cmake (libubox)
shell: su buildbot -c "sh -e {0}"
working-directory: libubox-build
run: cmake ../libubox -DCMAKE_INSTALL_PREFIX=../install -DBUILD_LUA=false ${{ matrix.compiler }}

- name: Run build (libubox)
shell: su buildbot -c "sh -e {0}"
working-directory: libubox-build
run: make

- name: Run install (libubox)
shell: su buildbot -c "sh -e {0}"
working-directory: libubox-build
run: make install

- name: Run cmake (uci)
shell: su buildbot -c "sh -e {0}"
working-directory: uci-build
run: cmake ../uci -DUNIT_TESTING=true -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_PREFIX_PATH=../install ${{ matrix.compiler }}

- name: Run build (uci)
shell: su buildbot -c "sh -e {0}"
working-directory: uci-build
run: make

- name: Run tests (uci)
shell: su buildbot -c "sh -e {0}"
working-directory: uci-build
run: make test
2 changes: 1 addition & 1 deletion tests/fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MACRO(ADD_FUZZER_TEST name)
ADD_EXECUTABLE(${name} ${name}.c)
TARGET_COMPILE_OPTIONS(${name} PRIVATE -g -O1 -fno-omit-frame-pointer -fsanitize=fuzzer,address,leak,undefined)
TARGET_INCLUDE_DIRECTORIES(${name} PRIVATE ${PROJECT_SOURCE_DIR})
TARGET_LINK_OPTIONS(${name} PRIVATE -stdlib=libc++ -fsanitize=fuzzer,address,leak,undefined)
TARGET_LINK_OPTIONS(${name} PRIVATE -fsanitize=fuzzer,address,leak,undefined)
TARGET_LINK_LIBRARIES(${name} uci)
ADD_TEST(
NAME ${name}
Expand Down
Loading