This repository serves as a template for modern C++ projects, incorporating tools for code formatting, linting, and maintaining consistent coding standards.
To set up your local development environment, follow these steps:
-
Install pre-commit:
pre-commit
is used to run checks before each commit. Install it using pip:pip install pre-commit
-
Install clang-format:
clang-format
is used for formatting C++ code. Install it using apt:apt install clang-format
-
Install clang-tidy:
clang-tidy
performs linting and static analysis on C++ code. Install it using apt:apt install clang-tidy
-
Install cmake-format:
cmake-format
is used for formatting CMake files. Install it using pip:pip install cmakelang
-
Install Flake8 (optional):
- If your project includes Python scripts, install
Flake8
for linting Python code:pip install flake8
- If your project includes Python scripts, install
-
Initialize pre-commit in Your Repository:
- Run the following command in your repository to set up the pre-commit hooks:
pre-commit install
- Run the following command in your repository to set up the pre-commit hooks:
You can also run these tools manually:
-
clang-format: Format a single file:
clang-format -i path/to/your/file.cpp
-
clang-tidy: Check a single file:
clang-tidy path/to/your/file.cpp -- -Iinclude
-
cmake-format: Format a CMake file:
cmake-format -i path/to/your/CMakeLists.txt
-
Flake8: Lint a Python file:
flake8 path/to/your/script.py
This project uses GitHub Actions for Continuous Integration and Continuous Deployment (CI/CD). The following automated workflows are set up:
-
Code Formatting (
format.yml
): Checks if the code conforms to the defined formatting standards usingclang-format
. -
Linting (
lint.yml
): Performs static code analysis usingclang-tidy
to identify potential issues in the C++ source files. -
Building (
build.yml
): Compiles the project to ensure that the build process is successful. -
Testing (
test.yml
): TBD.
- Each workflow is triggered on push and pull requests to the
main
|master
branches. - Workflows are defined in the
.github/workflows
directory, with separate files for formatting, linting, building, and testing (soon). - These workflows ensure code quality and build integrity with every commit and pull request.
This project is configured to be used with GitHub Codespaces, providing a fully setup development environment with all the necessary tools pre-installed.
- Pre-configured C++ development environment.
- Integrated tools like
clang-format
,clang-tidy
, andcmake
. - Automatic setup for
pre-commit
and other dependencies.
To start using GitHub Codespaces:
- Go to the GitHub repository page.
- Click on the 'Code' button and select 'Open with Codespaces'.
- Choose to create a new codespace. This will set up the environment as per the configuration in
.devcontainer/devcontainer.json
.
- The development environment is defined in the
.devcontainer
folder. devcontainer.json
specifies the Docker image, installed extensions, and post-create commands.- You can modify these files to customize the Codespaces environment to better suit your project's needs.