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
38 changes: 38 additions & 0 deletions .github/workflows/format-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Lint and Format

on: [push, pull_request]

jobs:
python-format-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Ruff
run: pip install ruff
- name: Find Python Packages, and then Format and Lint
run: |
for pkg in $(find . -name pyproject.toml -exec dirname {} \;); do
echo "Processing Python package in $pkg"
ruff format "$pkg"
ruff check "$pkg"
done
cpp-format-lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install clang-tidy and clang-format
run: sudo apt-get update && sudo apt-get install -y cmake clang
- name: Find C++ Packages, and then Format and Lint
run: |
for pkg in $(find . -name CMakeLists.txt -exec dirname {} \;); do
echo "Processing C++ package in $pkg"
clang-format -i $(find "$pkg" -name '*.cpp' -o -name '*.hpp')
cmake -S "$pkg" -B "$pkg/build" \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=*"
cmake --build "$pkg/build" -j"$(nproc)"
done
84 changes: 0 additions & 84 deletions .github/workflows/lint-format.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# C++/Python Project Template

This is a standardized C++/Python project template for DALSA projects that will be hosted on GitHub, designed to help project owners quickly set up new projects with a consistent structure and DevOps features. Its goal is to ensure maintainability and collaboration by enforcing standards that make future contributions and usage seamless. The template integrates **Sphinx** + **Doxygen** for unified documentation of both C++ and Python packages, and uses GitHub Actions to automate the generation of web-based documentation, code analysis (linting), code rewrites to follow a consistent style (formatting), and execution of tests.
This is a standardized C++/Python project template for DALSA projects that will be hosted on GitHub, designed to help project owners quickly set up new projects with a consistent structure and DevOps features. Its goal is to ensure maintainability and collaboration by enforcing standards that make future contributions and usage seamless. The template integrates **Sphinx** + **Doxygen** for unified documentation of both C++ and Python packages, and uses GitHub Actions to automate the generation of web-based documentation, code rewrites to follow a consistent style (formatting), code analysis (linting), and execution of tests.
This template introduces a certain structure so that users and contributors can quickly understand your project.

---
Expand Down
18 changes: 9 additions & 9 deletions lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@ Together, being **modular** and **self-contained** ensures that each package can
- **Build System**: CMake
- **Compiler**: Clang (installed via LLVM)
- **Build Tool**: Ninja
- **Linting**: `clang-tidy`
- **Formatting**: `clang-format`
- **Linting**: `clang-tidy`

> If you want to use the same tools (CMake, Clang and Ninja), make sure to install them in your machine.

Assuming you are in the root directory of the package:

To build (with liniting):
To format:
```bash
cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=*;"
cmake --build build
clang-format -i src/*.cpp include/*.hpp
```

To format:
To build (with linting):
```bash
clang-format -i src/*.cpp include/*.hpp
cmake -S . -B build -G "Ninja" -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-header-filter=.;-checks=*;"
cmake --build build
```

### Python (`py_pkg`)
- **Packaging and Dependency Management Tool**: Poetry
- **Configuration Tool**: pyproject.toml
- **Linting & Formatting**: Ruff
- **Formatting & Linting**: Ruff

> Remember that with Python no build step is required.

Expand All @@ -124,10 +124,10 @@ And then activate it (on Windows via CMD):
"myenv/Scripts/activate.bat"
```

To lint and format:
To format and lint:
```bash
ruff format .
ruff check .
ruff check . --fix
```

You can also build your project into a distributable format (wheel and source tarball):
Expand Down