diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000000..9c21e1e17c --- /dev/null +++ b/.clang-format @@ -0,0 +1,15 @@ +--- +Language: Cpp +BasedOnStyle: Google + +ColumnLimit: 100 +AccessModifierOffset: -2 +AlignAfterOpenBracket: AlwaysBreak +BreakBeforeBraces: Allman +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 2 +DerivePointerAlignment: false +PointerAlignment: Middle +ReflowComments: false +IncludeBlocks: Preserve +... diff --git a/.github/workflows/binary.yml b/.github/workflows/ci-build-binary.yml similarity index 74% rename from .github/workflows/binary.yml rename to .github/workflows/ci-build-binary.yml index 7fde390eb8..f649cc8d28 100644 --- a/.github/workflows/binary.yml +++ b/.github/workflows/ci-build-binary.yml @@ -1,4 +1,4 @@ -name: Build & Test ros2_control with binary install +name: Binary Build on: pull_request: push: @@ -9,8 +9,8 @@ on: - cron: '17 8 * * *' jobs: - ci_binary: - name: Foxy binary job + binary: + name: Foxy binary build runs-on: ubuntu-latest strategy: matrix: @@ -19,5 +19,5 @@ jobs: - {ROS_DISTRO: foxy, ROS_REPO: testing} steps: - uses: actions/checkout@v1 - - uses: ros-industrial/industrial_ci@master + - uses: 'ros-industrial/industrial_ci@master' env: ${{matrix.env}} diff --git a/.github/workflows/source.yml b/.github/workflows/ci-build-coverage.yml similarity index 67% rename from .github/workflows/source.yml rename to .github/workflows/ci-build-coverage.yml index 22d396414a..1e0d46bef7 100644 --- a/.github/workflows/source.yml +++ b/.github/workflows/ci-build-coverage.yml @@ -1,21 +1,24 @@ -name: Build & Test ros2_control with source-based setup +name: Coverage Build on: + pull_request: push: branches: - master schedule: - # Run every morning to detect flakiness and broken dependencies - - cron: '17 8 * * *' + # Run every day to detect flakiness and broken dependencies + - cron: '07 7 * * *' jobs: - ci_source: - name: Foxy source job + coverage: + name: coverage build runs-on: ubuntu-20.04 strategy: fail-fast: false steps: - - uses: ros-tooling/setup-ros@v0.1 - - uses: ros-tooling/action-ros-ci@v0.1 + - uses: ros-tooling/setup-ros@0.0.26 + with: + required-ros-distributions: foxy + - uses: ros-tooling/action-ros-ci@v0.2 with: target-ros2-distro: foxy # build all packages listed in the meta package @@ -28,11 +31,15 @@ jobs: ros2_control ros2_control_test_assets vcs-repo-file-url: | - https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control/ros2_control.repos - colcon-mixin-name: coverage-gcc + colcon-defaults: | + { + "build": { + "mixin": ["coverage-gcc"] + } + } colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml - - uses: codecov/codecov-action@v1 + - uses: codecov/codecov-action@v1.0.14 with: file: ros_ws/lcov/total_coverage.info flags: unittests diff --git a/.github/workflows/ci-build-source.yml b/.github/workflows/ci-build-source.yml new file mode 100644 index 0000000000..de1d629026 --- /dev/null +++ b/.github/workflows/ci-build-source.yml @@ -0,0 +1,37 @@ +name: Source Build +on: + push: + branches: + - master + schedule: + # Run every day to detect flakiness and broken dependencies + - cron: '27 7 * * *' + +jobs: + source: + name: source build + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + steps: + - uses: ros-tooling/setup-ros@0.0.26 + - uses: ros-tooling/action-ros-ci@v0.2 + with: + target-ros2-distro: foxy + # build all packages listed in the meta package + package-name: + controller_interface + controller_manager + controller_manager_msgs + hardware_interface + ros2controlcli + ros2_control + ros2_control_test_assets + vcs-repo-file-url: | + https://raw.githubusercontent.com/ros2/ros2/foxy/ros2.repos + https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control/ros2_control.repos + colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml + - uses: actions/upload-artifact@v1 + with: + name: colcon-logs-${{ matrix.os }} + path: ros_ws/log diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-format.yml new file mode 100644 index 0000000000..74158cbd33 --- /dev/null +++ b/.github/workflows/ci-format.yml @@ -0,0 +1,24 @@ +# 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: + - master + +jobs: + pre-commit: + name: Format + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install clang-format-10 + run: sudo apt-get install clang-format-10 cppcheck + - uses: pre-commit/action@v2.0.2 + with: + extra_args: --all-files --hook-stage manual diff --git a/.github/workflows/ci-ros-lint.yaml b/.github/workflows/ci-ros-lint.yaml new file mode 100644 index 0000000000..67b18c58c1 --- /dev/null +++ b/.github/workflows/ci-ros-lint.yaml @@ -0,0 +1,51 @@ +name: ROS Lint +on: + pull_request: + +jobs: + ament_lint: + name: ament_${{ matrix.linter }} + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + linter: [copyright, cppcheck, lint_cmake] + steps: + - uses: actions/checkout@v1 + - uses: ros-tooling/setup-ros@v0.1 + - uses: ros-tooling/action-ros-lint@v0.1 + with: + distribution: foxy + linter: ${{ matrix.linter }} + package-name: + controller_interface + controller_manager + controller_manager_msgs + hardware_interface + ros2controlcli + ros2_control + ros2_control_test_assets + + ament_lint_cpplint: + name: ament_${{ matrix.linter }} + runs-on: ubuntu-20.04 + strategy: + fail-fast: false + matrix: + linter: [cpplint] + steps: + - uses: actions/checkout@v1 + - uses: ros-tooling/setup-ros@v0.1 + - uses: ros-tooling/action-ros-lint@v0.1 + with: + distribution: foxy + linter: cpplint + arguments: "--filter=-whitespace/newline" + package-name: + controller_interface + controller_manager + controller_manager_msgs + hardware_interface + ros2controlcli + ros2_control + ros2_control_test_assets diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml deleted file mode 100644 index 02b1ab2478..0000000000 --- a/.github/workflows/lint.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Lint ros2_control -on: - pull_request: - -jobs: - ament_lint: - name: ament_${{ matrix.linter }} - runs-on: ubuntu-20.04 - strategy: - fail-fast: false - matrix: - linter: [copyright, cppcheck, cpplint, flake8, pep257, uncrustify, xmllint] - steps: - - uses: actions/checkout@v1 - - uses: ros-tooling/setup-ros@v0.1 - - uses: ros-tooling/action-ros-lint@v0.1 - with: - distribution: foxy - linter: ${{ matrix.linter }} - package-name: - controller_interface - controller_manager - controller_manager_msgs - hardware_interface - ros2controlcli - ros2_control - ros2_control_test_assets - transmission_interface diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..377b87d6d4 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,143 @@ +# 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-ast + - id: check-case-conflict + - id: check-docstring-first + - id: check-merge-conflict + - id: check-symlinks + - id: check-xml + - id: check-yaml + - id: debug-statements + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + - id: fix-byte-order-marker + + # Python hooks + - repo: https://github.com/asottile/pyupgrade + rev: v2.12.0 + hooks: + - id: pyupgrade + args: [--py36-plus] + + - repo: https://github.com/psf/black + rev: 20.8b1 + hooks: + - id: black + args: ["--line-length=100"] + + # PEP 257 + - repo: https://github.com/FalconSocial/pre-commit-mirrors-pep257 + rev: v0.3.3 + hooks: + - id: pep257 + args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"] + + - repo: https://github.com/pycqa/flake8 + rev: 3.9.0 + hooks: + - id: flake8 + args: ["--ignore=E501"] + + # CPP hooks + - repo: local + hooks: + - id: clang-format + name: clang-format + description: Format files with ClangFormat. + entry: clang-format-10 + 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'] + # The same options as in ament_cppcheck are used, but its not working... + #- repo: https://github.com/pocc/pre-commit-hooks + #rev: v1.1.1 + #hooks: + #- id: cppcheck + #args: ['--error-exitcode=1', '-f', '--inline-suppr', '-q', '-rp', '--suppress=internalAstError', '--suppress=unknownMacro', '--verbose'] + + - repo: local + hooks: + - id: ament_cppcheck + name: ament_cppcheck + description: Static code analysis of C/C++ files. + stages: [commit] + entry: ament_cppcheck + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + + # Maybe use https://github.com/cpplint/cpplint instead + - repo: local + hooks: + - id: ament_cpplint + name: ament_cpplint + description: Static code analysis of C/C++ files. + stages: [commit] + entry: ament_cpplint + language: system + files: \.(h\+\+|h|hh|hxx|hpp|cuh|c|cc|cpp|cu|c\+\+|cxx|tpp|txx)$ + args: ["--linelength=100", "--filter=-whitespace/newline"] + + # Cmake hooks + - repo: local + hooks: + - id: ament_lint_cmake + name: ament_lint_cmake + description: Check format of CMakeLists.txt files. + stages: [commit] + entry: ament_lint_cmake + language: system + files: CMakeLists\.txt$ + + # Copyright + - repo: local + hooks: + - id: ament_copyright + name: ament_copyright + description: Check if copyright notice is available in all files. + stages: [commit] + entry: ament_copyright + language: system + + # Docs - RestructuredText hooks + - repo: https://github.com/PyCQA/doc8 + rev: 0.9.0a1 + hooks: + - id: doc8 + args: ['--max-line-length=100', '--ignore=D001'] + exclude: CHANGELOG\.rst$ + + - repo: https://github.com/pre-commit/pygrep-hooks + rev: v1.8.0 + hooks: + - id: rst-backticks + exclude: CHANGELOG\.rst$ + - id: rst-directive-colons + - id: rst-inline-touching-normal + + # Spellcheck in comments and docs + # skipping of *.svg files is not working... + - repo: https://github.com/codespell-project/codespell + rev: v2.0.0 + hooks: + - id: codespell + args: ['--write-changes'] + exclude: \.(svg|pyc)$