Skip to content

Commit

Permalink
Adding pre-commit actions (#172)
Browse files Browse the repository at this point in the history
* Add pre-commit config file

* test

* added documentation

* pre-commit docs

* added gitclang format instead

* fixed docs

* git clang format by path

* test commit

* removing test file

* Removes --force and simplify docs

---------

Co-authored-by: BlakeFreer <[email protected]>
  • Loading branch information
Micnasr and BlakeFreer authored Oct 11, 2024
1 parent f0128b5 commit bc36dd1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimum version of pre-commit
minimum_pre_commit_version: "2.9.0"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
# Prevent committing directly to the main branch
- id: no-commit-to-branch
args: [--branch, main]
stages: [commit]

- repo: local
hooks:
- id: clang-format
name: Run git-clang-format
entry: git clang-format --style=file --staged
language: python
stages: [commit]
additional_dependencies:
- clang-format~=19.0
20 changes: 20 additions & 0 deletions docs/docs/firmware/dev-setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,3 +234,23 @@ __Important:__ Create an empty file named `.clangd` in the `firmware/` directory
You will need a Unix development environment (Unix machine, WSL, or remote into the Raspberry Pi).

Go through the [gRPC C++ Quickstart Guide](https://grpc.io/docs/languages/cpp/quickstart/). Build the example project.

## Pre-Commit Setup

We use `pre-commit` hooks to run formatting and code checks before the code is pushed.

### Installing Pre-Commit

1. Install `pre-commit` via pip:

```bash
pip install pre-commit
```

2. Install the git hooks by running this command in the `racecar` directory:

```bash
pre-commit install
```

This will install the hooks so they run automatically when you use `git commit`.

0 comments on commit bc36dd1

Please sign in to comment.