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
4 changes: 2 additions & 2 deletions copier.yml
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,8 @@ ci_type:
when: "{{ 'ci' in template }}"

add_pre_commit:
help: Add pre-commit hooks?
default: false
help: Add pre-commit hooks? [Recommended]
default: true
type: bool
when: "{{ 'ci' in template }}"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
rev: v20.1.4
hooks:
- id: clang-format
name: Clang Format
Expand All @@ -11,14 +11,37 @@ repos:
hooks:
- id: cppcheck
name: Cppcheck
entry: cppcheck --force --quiet --language=c++
entry: bash -c "cppcheck --force --quiet --inline-suppr --error-exitcode=1 --language=c++ $(find . -type d -name 'cmake-build-*' -prune -false -o -name '*.cpp' -o -name '*.hpp' -o -name '*.h' -o -name '*.c' -o -name '*.cc')"
language: system
types: [c, c++]
files: \.(cpp|hpp|h|c|cc)$
files: \.(cpp|cc|hpp|h)$
pass_filenames: false

- repo: https://github.com/psf/black
rev: 24.2.0
rev: 25.1.0
hooks:
- id: black
name: Black
language_version: python3

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: trailing-whitespace
- id: check-yaml
- id: check-xml
- id: check-merge-conflict


- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint


- repo: https://github.com/Joschi3/package_xml_validation.git
rev: v1.1.7
hooks:
- id: format-package-xml
name: Validate and Format package.xml

Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,21 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup
run: |
sudo apt-get update && sudo apt-get install -y black clang-format cppcheck libxml2-utils

{% if add_pre_commit %}
- name: Set up Python
uses: actions/setup-python@v4

- name: Install and Run pre-commit
uses: pre-commit/[email protected]
with:
extra_args: --all-files

{% else %}
- name: Lint C++ code
run: |
echo "Linting C++ code..."
Expand All @@ -40,6 +52,8 @@ jobs:
run: |
echo "Linting Python code..."
black --check .
{% endif %}



build-and-test:
Expand Down Expand Up @@ -78,4 +92,4 @@ jobs:
run: |
source /opt/ros/{{ '${{ matrix.setup.rosdistro }}' }}/setup.bash
colcon test
colcon test-result --verbose
colcon test-result --verbose
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,19 @@ variables:

linting:
stage: linting
{% if add_pre_commit %}
image: $CI_REGISTRY/hector/workspace/docker_workspace:dev-amd64
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH'
before_script:
- sudo apt-get update && sudo apt-get install -y clang-format cppcheck libxml2-utils black git pre-commit
- git config --global --add safe.directory "$CI_PROJECT_DIR"
- rosdep update --rosdistro ${ROS_DISTRO}
script:
- echo "Running pre-commit hooks..."
- pre-commit run --all-files
{% else %}
image: ubuntu:latest
rules:
- if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
Expand All @@ -22,6 +35,8 @@ linting:
- xmllint --noout --schema http://download.ros.org/schema/package_format3.xsd $(find . -name 'package.xml')
- echo "Linting Python files..."
- black --check .
{% endif %}


build-and-test:
stage: build_and_test
Expand Down