Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/clang-format.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: clang-format
on: [push, pull_request]
jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-format
run: sudo apt install -y cmake clang-format-19
- name: clang-format
# Create symbolic link to clang-format-19 and
# add it to PATH so that 'clang-format' can
# be used to run 'clang-format-19'.
run: |
ln -s $(which clang-format-19) clang-format
export PATH=$PWD:$PATH
cmake .
make lint
15 changes: 15 additions & 0 deletions .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: cppcheck
on: [push, pull_request]
jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install cppcheck
run: sudo apt-get install -y cmake cppcheck
- name: Run cppcheck
run: |
cmake .
make check
17 changes: 17 additions & 0 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: ruff
on: [push, pull_request]
jobs:
build:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install ruff
run: python3 -m pip install --upgrade pip ruff
- name: Run ruff
run: ruff check
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ repos:
pass_filenames: false
always_run: true
verbose: true
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.9
hooks:
- id: ruff-format
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,5 @@ add_custom_target(
add_custom_target(
test
COMMAND "./tests/test.sh"
DEPENDS cbxp
DEPENDS libcbxp cbxp
)
20 changes: 11 additions & 9 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The following are a set of guidelines to help you contribute.

* [Python Interface Testing](#python-interface-testing)

* [Shell Interface Testing](#shell-interface-testing)
* [CLI Interface Testing](#cli-interface-testing)

* [Style Guidelines](#style-guidelines)

Expand All @@ -48,7 +48,7 @@ There are many ways to contribute to the project. You can write code, work on th
If you want to write code, a good way to get started is by looking at the issues section of this repository. Look for the **Good First Issue** tag. Good First Issues are great as a first contribution.

### pre-commit Hooks
To ensure `clang-format` and `cppcheck` are always run against your code on **every commit**, set up the **pre-commit hooks**.
To ensure `clang-format`, `cppcheck`, and `ruff` are always run against your code on **every commit**, set up the **pre-commit hooks**.

* Install [`pre-commit`](https://pre-commit.com/).
* Setup **pre-commit Hooks**:
Expand Down Expand Up @@ -97,7 +97,7 @@ CBXP is tested using automated functional tests. Test cases for new functionalit
python3 ./tests/test.py
```

#### Shell Interface Testing
#### CLI Interface Testing
1. Add new tests cases to [`tests/test.sh`](tests/test.sh).
2. Run the test suite using `cmake` and `gmake`.

Expand All @@ -108,11 +108,11 @@ CBXP is tested using automated functional tests. Test cases for new functionalit

## Style Guidelines

:bulb: _`clang-format` can be setup to run automatically using the [pre-commit Hooks](#pre-commit-hooks)._
:bulb: _`clang-format` and `ruff` can be setup to run automatically using the [pre-commit Hooks](#pre-commit-hooks)._

The use of the `clang-format` code formatter is required.
All C/C++ code must be formatted using `clang-format`, and all Python code must be formatted using `ruff`.

The following code style conventions should be followed:
The following C/C++ code style conventions should be followed:
* Varible names should use snake case *(i.e., `my_variable`)*.
* Pointer variables should start with `p_` *(i.e., `p_my_pointer`)*.
* Class variables should end with an `_` to help differentiate between class variables and local function variables *(i.e., `my_class_variable_`)*.
Expand Down Expand Up @@ -145,10 +145,12 @@ When contributing to CBXP, make sure to complete all applicable tasks in the fol

* Make any necessary updates to `pyproject.toml`.
* Make any necessary updates to `README.md`.
* Ensure that you have **pre-commit Hooks** setup to ensure that `clang-format` and `cppcheck` are run against the code for every commit you make.
* Ensure that you have **pre-commit Hooks** setup to ensure that `clang-format`, `cppcheck`, and `ruff` are run against the code for every commit you make.
* Check for style violations in C/C++ code by running `gmake lint`.
* Check for style vilotations in Python code by running `ruff check`.
* Format C/C++ code by running `gmake format`.
* Format Python code by running `ruff format`.
* Run `cppcheck` static code analysis by running `gmake check`.
* Check for style violations using `clang-format` by running `gmake lint`.
* Format the CBXP code using `clang-format` by running `gmake format`.

## Found a bug?

Expand Down
Loading