Skip to content
/ cit Public template

Control your c++ code using this ci template and development environment powered by nix and docker.

License

Notifications You must be signed in to change notification settings

melg8/cit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cit - Control it

Checks codecov Language grade: C/C++ REUSE status MIT built with nix

Control your c++ code using this continuous integration template.

cit - is a project template for development of C++ codebase. It aggregates linters, static and dynamic analysis tools in single, ready to use template.

Main goals of project

  • Explore capabilities of automatic tools and their impact on development

  • Give users of project unified access to linters and analysis tools

  • Showcase techniques of testing different properties of codebase

  • Provide reproducible builds and environments through docker and nix

  • Encourage responsible attitude towards the development of quality software

Features

  • This repository provides reproducible development and testing environments with version pinning thanks to docker and nix

  • Support of major c++ compilers, with all compile time checks enabled

  • Familiar cross-platform build setup using cmake and conan

  • Runtime tests with doctest and sanitizers

  • Command-line tool to simplify usage of functionality

    Just

  • A lot of linters, formatters and static analysis tools integrated and setup for each aspect of project with informative reports thanks to integration with patched version of megalinter

    Local report

  • You don’t need to stare at raw logs of tools, thanks to CodeChecker you can check summary tables, statistics for project and reports in your browser HTML report

  • Even if you can’t run it locally - that’s not an issue. Ready to use GitHub ci setup with same checks and reports uploaded as artifacts

  • Pull requests won’t pass if linters found some issues

    Checks report

  • Reviewdog comments cpp linters output in pull request

    GitHub report

  • Linters suggestions and auto fixes are also displayed by reviewdog as suggestions in pull request

    GitHub diff

  • Pull requests feedback with linting results as comment: example. When there are no issues left with pr you will see updated message from bot

    Pr message

  • Code coverage with pull request Codecov reports

    Codecov

  • All artifacts with logs are available for download from ci

Current status

This project is under development, expect changes in api, setup and tools. It uses opinionated set of rules and conventions for project, feel free to change configuration files to best fit your personal needs. You can fork and play with it, contributions to the source code, issues and requests are welcome.

Getting Started

You can use this template in different levels of integration with user environment. From using text editor and running all checks in CI, up to using prepared docker image or nix-shell and running check locally.

  1. Fork this project, enable GitHub actions and edit it either with GitHub editor or with local text editor

  2. Project use cmake ninja and conan. If you have them installed on your system you can build and run tests as with any other cmake project. Or run this bash script from root of project to build project with gcc:

       ci/builders/gcc/build.sh
  3. To use this project locally to the full potential you have options:

  • Install docker than you can use prepared docker image. Call this script from root of project to run bash shell inside docker image

       ci/docker/run_shell.sh
  • Install nix package manager or use nixos. In that case call nix-shell

       nix-shell

Usage

Okay. You got your environment either with docker image or with nix-shell, let’s take a look what’s next. To ease usage of project we use just. So we can call it like that:

   just

You will see available recipes (actions) which you can do to use project:

Just

Let’s explore main functions. You can build project with gcc or clang compiler using commands:

   just build-gcc
   just build-clang

To run all linters on your project use:

   just lint-all

To run specific linter on your project use lint-with command with name of descriptor and linter all capital case split by underscores. So if we want to run clang-tidy from CPP descriptor we call:

   just lint-with CPP_CLANG_TIDY

And we will see report of single linter:

Single linter

After linting you can check report folder with all logs from linters.

From nix-shell or docker image you can also build docker image yourself. Nix used to reproducibly build tar archive with docker image containing all linters

   just docker-build

You can check that produced result has same hash sum as result produced by ci:

   sha256sum result

Docker image than loaded from result:

   just docker-load

Or you can run docker-update-locally to do image creation, sha256sum and load in single command:

   just docker-update-locally

Docker-update command will build image and upload it to docker-hub:

   just docker-update

To see all inner workings take a look in justfile for concrete bash scripts for each action. Check GitHub workflows file for GitHub ci setup.

Available tools

Planned

Credits

Big thanks to contributors. You can see contributors in credits.

License

cit template released under the terms of the MIT license. See license for more information.