Skip to content

Commit 6471232

Browse files
authored
Add pre-commit Checks (#77)
* add pre commit configuration * Updated clang-format * Added corrected files * Revert to master * Starting new CI configuration with pre-commit-hooks * Add clang format config - copied from ament-clang-format * Update action setup * Update version of hooks * Remove double pre-commit configuration * Update deprecated hook. * Update linters and formating configuration * Braces are allways in the new line * Updatd all line lengths to 100 * Add cpp lint option to ignore braces after else * Put clang-format first to reduce cpplint and cppcheck errors * Update build times and small error in setup
1 parent 9f09c40 commit 6471232

File tree

9 files changed

+161
-61
lines changed

9 files changed

+161
-61
lines changed

.clang-format

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
---
22
Language: Cpp
33
BasedOnStyle: Google
4+
5+
ColumnLimit: 100
6+
AccessModifierOffset: -2
7+
AlignAfterOpenBracket: AlwaysBreak
8+
BreakBeforeBraces: Allman
9+
ConstructorInitializerIndentWidth: 0
10+
ContinuationIndentWidth: 2
11+
DerivePointerAlignment: false
12+
PointerAlignment: Middle
13+
ReflowComments: false
14+
IncludeBlocks: Preserve
415
...
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Binary Build
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- master
7+
schedule:
8+
# Run every day to detect flakiness and broken dependencies
9+
- cron: '23 1 * * *'
10+
11+
jobs:
12+
binary:
13+
name: binary build
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
env:
18+
- {ROS_DISTRO: foxy, ROS_REPO: main}
19+
- {ROS_DISTRO: foxy, ROS_REPO: testing}
20+
env:
21+
UPSTREAM_WORKSPACE: ros2_control_demos.repos
22+
steps:
23+
- uses: actions/checkout@v1
24+
- uses: 'ros-industrial/industrial_ci@master'
25+
env: ${{matrix.env}}

.github/workflows/ci.yml renamed to .github/workflows/ci-build-coverage.yml

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,39 @@
1-
name: CI
1+
name: Coverage Build
22
on:
33
pull_request:
44
push:
55
branches:
66
- master
77
schedule:
8-
# Run every morning to detect flakiness and broken dependencies
9-
- cron: '28 6 * * *'
8+
# Run every day to detect flakiness and broken dependencies
9+
- cron: '54 1 * * *'
1010

1111
jobs:
12-
ci_binary:
13-
name: Foxy binary job
14-
runs-on: ubuntu-latest
15-
strategy:
16-
matrix:
17-
env:
18-
- {ROS_DISTRO: foxy, ROS_REPO: main}
19-
- {ROS_DISTRO: foxy, ROS_REPO: testing}
20-
env:
21-
UPSTREAM_WORKSPACE: ros2_control_demos/ros2_control_demos.repos
22-
steps:
23-
- uses: actions/checkout@v1
24-
- uses: 'ros-industrial/industrial_ci@master'
25-
env: ${{matrix.env}}
26-
27-
ci_source:
28-
name: Foxy source job
12+
coverage:
13+
name: coverage build
2914
runs-on: ubuntu-20.04
3015
strategy:
3116
fail-fast: false
3217
steps:
3318
- uses: ros-tooling/[email protected]
3419
with:
3520
required-ros-distributions: foxy
36-
- uses: ros-tooling/action-ros-ci@0.1.0
21+
- uses: ros-tooling/action-ros-ci@v0.2
3722
with:
3823
target-ros2-distro: foxy
3924
# build all packages listed in the meta package
4025
package-name:
41-
ros2_control_demo_hardware
26+
ros2_control_demo_hardware
4227
ros2_control_demo_robot
4328
ros2_control_demos
44-
ros2_control_test_nodes
4529
vcs-repo-file-url: |
46-
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control_demos/ros2_control_demos.repos
47-
colcon-mixin-name: coverage-gcc
30+
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control_demos.repos
31+
colcon-defaults: |
32+
{
33+
"build": {
34+
"mixin": ["coverage-gcc"]
35+
}
36+
}
4837
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
4938
- uses: codecov/[email protected]
5039
with:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: Source Build
2+
on:
3+
push:
4+
branches:
5+
- master
6+
schedule:
7+
# Run every day to detect flakiness and broken dependencies
8+
- cron: '43 1 * * *'
9+
10+
jobs:
11+
source:
12+
name: source build
13+
runs-on: ubuntu-20.04
14+
strategy:
15+
fail-fast: false
16+
steps:
17+
- uses: ros-tooling/[email protected]
18+
- uses: ros-tooling/[email protected]
19+
with:
20+
target-ros2-distro: foxy
21+
# build all packages listed in the meta package
22+
package-name:
23+
ros2_control_demo_hardware
24+
ros2_control_demo_robot
25+
ros2_control_demos
26+
vcs-repo-file-url: |
27+
https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos
28+
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control_demos.repos
29+
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
30+
- uses: actions/upload-artifact@v1
31+
with:
32+
name: colcon-logs-${{ matrix.os }}
33+
path: ros_ws/log

.github/workflows/ci-format.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# This is a format job. Pre-commit has a first-party GitHub action, so we use
2+
# that: https://github.com/pre-commit/action
3+
4+
name: Format
5+
6+
on:
7+
workflow_dispatch:
8+
pull_request:
9+
push:
10+
branches:
11+
- master
12+
13+
jobs:
14+
pre-commit:
15+
name: Format
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v2
19+
- uses: actions/setup-python@v2
20+
- name: Install clang-format-10
21+
run: sudo apt-get install clang-format-10 cppcheck
22+
- uses: pre-commit/[email protected]
23+
with:
24+
extra_args: --all-files --hook-stage manual

.github/workflows/ci-ros-lint.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: ROS Lint
2+
on:
3+
pull_request:
4+
5+
jobs:
6+
ament_lint:
7+
name: ament_${{ matrix.linter }}
8+
runs-on: ubuntu-20.04
9+
strategy:
10+
fail-fast: false
11+
matrix:
12+
linter: [copyright, cppcheck, lint_cmake]
13+
steps:
14+
- uses: actions/checkout@v1
15+
- uses: ros-tooling/[email protected]
16+
- uses: ros-tooling/[email protected]
17+
with:
18+
distribution: foxy
19+
linter: ${{ matrix.linter }}
20+
package-name:
21+
ros2_control_demo_hardware
22+
ros2_control_demo_robot
23+
ros2_control_demos
24+
25+
ament_lint_cpplint:
26+
name: ament_${{ matrix.linter }}
27+
runs-on: ubuntu-20.04
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
linter: [cpplint]
32+
steps:
33+
- uses: actions/checkout@v1
34+
- uses: ros-tooling/[email protected]
35+
- uses: ros-tooling/[email protected]
36+
with:
37+
distribution: foxy
38+
linter: cpplint
39+
arguments: "--filter=-whitespace/newline"
40+
package-name:
41+
ros2_control_demo_hardware
42+
ros2_control_demo_robot
43+
ros2_control_demos

.github/workflows/linters.yaml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.pre-commit-config.yaml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repos:
2929
- id: end-of-file-fixer
3030
- id: mixed-line-ending
3131
- id: trailing-whitespace
32-
- id: check-byte-order-marker # Forbid UTF-8 byte-order markers
32+
- id: fix-byte-order-marker
3333

3434
# Python hooks
3535
- repo: https://github.com/asottile/pyupgrade
@@ -58,6 +58,15 @@ repos:
5858
args: ["--ignore=E501"]
5959

6060
# CPP hooks
61+
- repo: local
62+
hooks:
63+
- id: clang-format
64+
name: clang-format
65+
description: Format files with ClangFormat.
66+
entry: clang-format-10
67+
language: system
68+
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
69+
args: ['-fallback-style=none', '-i']
6170
# The same options as in ament_cppcheck are used, but its not working...
6271
#- repo: https://github.com/pocc/pre-commit-hooks
6372
#rev: v1.1.1
@@ -85,17 +94,7 @@ repos:
8594
entry: ament_cpplint
8695
language: system
8796
files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$
88-
args: ["--linelength=120"]
89-
90-
- repo: local
91-
hooks:
92-
- id: clang-format
93-
name: clang-format
94-
description: Format files with ClangFormat.
95-
entry: clang-format-10
96-
language: system
97-
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
98-
args: ['-fallback-style=none', '-i']
97+
args: ["--linelength=100", "--filter=-whitespace/newline"]
9998

10099
# Cmake hooks
101100
- repo: local
File renamed without changes.

0 commit comments

Comments
 (0)