melg8 / cit

Control your c++ code using this ci template and development environment powered by nix and docker.
Other
14 stars 3 forks source link
analysis ci ci-template cit clean-code cpp cpp17 docker docker-image linter linters nix nixos starter-project static-analysis template-project

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

Features

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:

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.