Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pre-commit for automatic formatting #248

Closed
wants to merge 1 commit into from
Closed
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 .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
Language: Cpp
BasedOnStyle: Google

SortIncludes: false
AccessModifierOffset: -2
AlignAfterOpenBracket: AlwaysBreak
BraceWrapping:
AfterClass: true
AfterFunction: true
AfterNamespace: true
AfterStruct: true
BreakBeforeBraces: Custom
ColumnLimit: 100
ConstructorInitializerIndentWidth: 0
ContinuationIndentWidth: 2
DerivePointerAlignment: false
PointerAlignment: Middle
ReflowComments: false
...
28 changes: 28 additions & 0 deletions .github/workflows/format.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This is a format job. Pre-commit has a first-party GitHub action, so we use
# that: https://github.com/pre-commit/action

name: Format

on:
workflow_dispatch:
pull_request:
push:
branches:
- main

jobs:
pre-commit:
name: pre-commit
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- name: Install clang-format
run: sudo apt-get install clang-format
- uses: pre-commit/[email protected]
id: precommit
- name: Upload pre-commit changes
if: failure() && steps.precommit.outcome == 'failure'
uses: rhaschke/upload-git-patch-action@main
with:
name: pre-commit
2 changes: 1 addition & 1 deletion .github/workflows/foxy-devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches:
- foxy-devel

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/galactic-devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches:
- galactic-devel

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/humble-devel.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
push:
branches:
- humble-devel

jobs:
build-and-test:
runs-on: ${{ matrix.os }}
Expand Down
54 changes: 54 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# To use:
#
# pre-commit run -a
#
# Or:
#
# pre-commit install # (runs every time you commit in git)
#
# To update this file:
#
# pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

repos:
# Standard hooks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: destroyed-symlinks
- id: detect-private-key
- id: end-of-file-fixer
- id: mixed-line-ending
- id: pretty-format-json
- id: trailing-whitespace

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black

- repo: local
hooks:
- id: clang-format
name: clang-format
description: Format files with ClangFormat.
entry: clang-format-12
language: system
files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
args: ['-fallback-style=none', '-i']

- repo: https://github.com/codespell-project/codespell
rev: v2.0.0
hooks:
- id: codespell
exclude: CHANGELOG.rst
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ This project is the result of several years of experience in the development of

We hope that this software helps to include planning in more Robotics projects, offering simple and powerful software to generate intelligent behaviors for robots.

Please, cite us if you use PlanSys2 in your reseach:
Please, cite us if you use PlanSys2 in your research:

```
```
@INPROCEEDINGS
{PlanSys2,
author = "Francisco Mart{\'{\i}}n and Jonatan Gin{\'{e}}s and Francisco J. Rodr{\'{i}}guez and Vicente Matell{\'{a}}n",
Expand Down
1 change: 1 addition & 0 deletions plansys2_bringup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ target_compile_definitions(plansys2_node PUBLIC "PLUGINLIB__DISABLE_BOOST_FUNCTI

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
set(ament_cmake_uncrustify_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

Expand Down
158 changes: 91 additions & 67 deletions plansys2_bringup/launch/plansys2_bringup_launch_distributed.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# -*- coding: utf-8 -*-
# Copyright 2019 Intelligent Robotics Lab
#
# Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -24,51 +25,60 @@


def generate_launch_description():
bringup_dir = get_package_share_directory('plansys2_bringup')
bringup_dir = get_package_share_directory("plansys2_bringup")

# Create the launch configuration variables
model_file = LaunchConfiguration('model_file')
namespace = LaunchConfiguration('namespace')
params_file = LaunchConfiguration('params_file')
action_bt_file = LaunchConfiguration('action_bt_file')
start_action_bt_file = LaunchConfiguration('start_action_bt_file')
end_action_bt_file = LaunchConfiguration('end_action_bt_file')
model_file = LaunchConfiguration("model_file")
namespace = LaunchConfiguration("namespace")
params_file = LaunchConfiguration("params_file")
action_bt_file = LaunchConfiguration("action_bt_file")
start_action_bt_file = LaunchConfiguration("start_action_bt_file")
end_action_bt_file = LaunchConfiguration("end_action_bt_file")
bt_builder_plugin = LaunchConfiguration("bt_builder_plugin")

declare_model_file_cmd = DeclareLaunchArgument(
'model_file',
description='PDDL Model file')
"model_file", description="PDDL Model file"
)

declare_namespace_cmd = DeclareLaunchArgument(
'namespace',
default_value='',
description='Namespace')
"namespace", default_value="", description="Namespace"
)

declare_params_file_cmd = DeclareLaunchArgument(
'params_file',
default_value=os.path.join(bringup_dir, 'params', 'plansys2_params.yaml'),
description='Full path to the ROS2 parameters file to use for all launched nodes')
"params_file",
default_value=os.path.join(bringup_dir, "params", "plansys2_params.yaml"),
description="Full path to the ROS2 parameters file to use for all launched nodes",
)

declare_action_bt_file_cmd = DeclareLaunchArgument(
'action_bt_file',
"action_bt_file",
default_value=os.path.join(
get_package_share_directory('plansys2_executor'),
'behavior_trees', 'plansys2_action_bt.xml'),
description='BT representing a PDDL action')
get_package_share_directory("plansys2_executor"),
"behavior_trees",
"plansys2_action_bt.xml",
),
description="BT representing a PDDL action",
)

declare_start_action_bt_file_cmd = DeclareLaunchArgument(
'start_action_bt_file',
"start_action_bt_file",
default_value=os.path.join(
get_package_share_directory('plansys2_executor'),
'behavior_trees', 'plansys2_start_action_bt.xml'),
description='BT representing a PDDL start action')
get_package_share_directory("plansys2_executor"),
"behavior_trees",
"plansys2_start_action_bt.xml",
),
description="BT representing a PDDL start action",
)

declare_end_action_bt_file_cmd = DeclareLaunchArgument(
'end_action_bt_file',
"end_action_bt_file",
default_value=os.path.join(
get_package_share_directory('plansys2_executor'),
'behavior_trees', 'plansys2_end_action_bt.xml'),
description='BT representing a PDDL end action')
get_package_share_directory("plansys2_executor"),
"behavior_trees",
"plansys2_end_action_bt.xml",
),
description="BT representing a PDDL end action",
)

declare_bt_builder_plugin_cmd = DeclareLaunchArgument(
"bt_builder_plugin",
Expand All @@ -77,58 +87,72 @@ def generate_launch_description():
)

domain_expert_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(
get_package_share_directory('plansys2_domain_expert'),
'launch',
'domain_expert_launch.py')),
PythonLaunchDescriptionSource(
os.path.join(
get_package_share_directory("plansys2_domain_expert"),
"launch",
"domain_expert_launch.py",
)
),
launch_arguments={
'model_file': model_file,
'namespace': namespace,
'params_file': params_file
}.items())
"model_file": model_file,
"namespace": namespace,
"params_file": params_file,
}.items(),
)

problem_expert_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(
get_package_share_directory('plansys2_problem_expert'),
'launch',
'problem_expert_launch.py')),
PythonLaunchDescriptionSource(
os.path.join(
get_package_share_directory("plansys2_problem_expert"),
"launch",
"problem_expert_launch.py",
)
),
launch_arguments={
'model_file': model_file,
'namespace': namespace,
'params_file': params_file
}.items())
"model_file": model_file,
"namespace": namespace,
"params_file": params_file,
}.items(),
)

planner_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(
get_package_share_directory('plansys2_planner'),
'launch',
'planner_launch.py')),
launch_arguments={
'namespace': namespace,
'params_file': params_file
}.items())
PythonLaunchDescriptionSource(
os.path.join(
get_package_share_directory("plansys2_planner"),
"launch",
"planner_launch.py",
)
),
launch_arguments={"namespace": namespace, "params_file": params_file}.items(),
)

executor_cmd = IncludeLaunchDescription(
PythonLaunchDescriptionSource(os.path.join(
get_package_share_directory('plansys2_executor'),
'launch',
'executor_launch.py')),
PythonLaunchDescriptionSource(
os.path.join(
get_package_share_directory("plansys2_executor"),
"launch",
"executor_launch.py",
)
),
launch_arguments={
'namespace': namespace,
'params_file': params_file,
'default_action_bt_xml_filename': action_bt_file,
'default_start_action_bt_xml_filename': start_action_bt_file,
'default_end_action_bt_xml_filename': end_action_bt_file,
'bt_builder_plugin': bt_builder_plugin,
}.items())
"namespace": namespace,
"params_file": params_file,
"default_action_bt_xml_filename": action_bt_file,
"default_start_action_bt_xml_filename": start_action_bt_file,
"default_end_action_bt_xml_filename": end_action_bt_file,
"bt_builder_plugin": bt_builder_plugin,
}.items(),
)

lifecycle_manager_cmd = Node(
package='plansys2_lifecycle_manager',
executable='lifecycle_manager_node',
name='lifecycle_manager_node',
package="plansys2_lifecycle_manager",
executable="lifecycle_manager_node",
name="lifecycle_manager_node",
namespace=namespace,
output='screen',
parameters=[])
output="screen",
parameters=[],
)

# Create the launch description and populate
ld = LaunchDescription()
Expand Down
Loading