Skip to content
This repository has been archived by the owner on Jan 21, 2024. It is now read-only.

Contributing

Bartłomiej Jaszczak edited this page Nov 11, 2023 · 5 revisions

Development (and future)

Rito is very simple and probably won't get a lot of new features, although I've got some plans on refactoring:

  • Classes decoupling (as they're difficult to test right now) + improving test coverage
  • Move from POCO to some other REST/Websocket library (Boost.Beast maybe?)
  • Improving docs

I will happily accept code reviews, comments, pull requests and/or any form of critique.

Even though this project is very small and it doesn't really make sense to set up extensive code quality checks, I plan to do it anyway. For learning purposes. Eventually I want the below to be implemented:

  • Unit tests
    • tests for common code
    • tests for Windows code
    • tests for Linux code
  • Integration tests for testing of underlying library (currently POCO)
  • Coverage check
    • Coverage report (lcov)
    • Coverage limit increased to 50%
    • Coverage limit increased to 70%
    • Coverage limit increased to 90%
  • Static analysis
  • Sanitizers (Address, memory and UB)

Contributing

There are no real rules for contributions, just make sure that all builds/tests/analysis run fine. In the next chapter you can find some tips on what targets are available for testing and code quality tools and how to build/run them. CI can help as well.

Code quality/CI setup

CI setup

There are two jobs (GitHub Actions) which run on every delivery:

  • Linux build,
  • Windows build.

Linux uses gcc and clang-16 and Windows uses cl (msvc). Both builds run tests (although there aren't many, yet). On top of that, Linux build runs coverage check as well, although the coverage limit is not very high.

Tests

Test environment is there, but for now not a lot of tests have been implemented. Testing introduces new dependency: gtest, at least 1.10. All build dependencies (Linux or Windows) have to be met as well.

Getting dependencies

Linux

It's easiest to get gtest as system package. For example:

Ubuntu/Debian:

$ sudo apt install libgtest-dev

Arch/Manjaro:

$ sudo pacman -S gtest

Alternatively, you can use vcpkg to get the gtest package. Clone the repo recursively and use vcpkg to get the gtest package:

$ cd tools/vcpkg
$ ./bootstrap-vcpkg.sh
$ ./vcpkg install gtest

Windows

On Windows, using vcpkg is the simplest way to get gtest installed. Clone the repo recursively and use vcpkg to get the gtest package:

> cd tools/vcpkg
> .bootstrap-vcpkg.bat
> .\vcpkg.exe install gtest

Building and running tests

Linux

If you've got gtest (and POCO) installed as system package, simply do (from main rito directory):

# Building tests
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On
$ cmake --build build

# Running tests
$ ctest -VV --test-dir build

If you've used vcpkg for any dependency (either gtest, POCO, or both), do the same, but make sure CMAKE_TOOLCHAIN_FILE points to vcpkg toolchain:

# Building tests
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=On "-DCMAKE_TOOLCHAIN_FILE=tools/vcpkg/scripts/buildsystems/vcpkg.cmake"
$ cmake --build build

# Running tests
$ ctest -VV --test-dir build

Windows

Assuming you've used vcpkg to get dependencies:

# Building tests
> cmake -S . -B build -DBUILD_TESTING=On "-DCMAKE_TOOLCHAIN_FILE=.\tools\vcpkg\scripts\buildsystems\vcpkg.cmake"
> cmake --build build --config Debug

# running tests
> ctest -VV --test-dir build

Coverage

Coverage report can be generated only on linux. New dependency is introduced here: lcov. Test dependencies have to be met as well. It can be easily installed via system package manager:

Ubuntu/Debian:

$ sudo apt install lcov

Arch/Manjaro:

$ sudo pacman -S lcov

Generating coverage report can be done with:

# Configure rito (if all dependencies are installed as system packages):
$ cmake -S . -B build -DBUILD_TESTING=On -DCMAKE_BUILD_TYPE=Debug

# Configure rito (if some dependencies are managed with vcpkg):
$ cmake -S . -B build -DBUILD_TESTING=On -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_TOOLCHAIN_FILE=tools/vcpkg/scripts/buildsystems/vcpkg.cmake"

# Build and run coverage check
$ cmake --build build -t Rito-coverage

# View coverage report
$ firefox build/Rito-coverage/index.html

Static analysis

Static analysis is implemented with clang-tidy (version 16 or above). It runs when STATIC_ANALYSIS option is set to On. You can run it with below commands:

# Configure rito (if all dependencies are installed as system packages):
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -DSTATIC_ANALYSIS=On

# Configure rito (if some dependencies are managed with vcpkg):
$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_TOOLCHAIN_FILE=tools/vcpkg/scripts/buildsystems/vcpkg.cmake" -DSTATIC_ANALYSIS=On

# Build and analyse
$ cmake --build build

Sanitizers

Sanitizers (address, memory and undefined behaviour) are run automatically with tests