From 741e0fade697eb22c7016ca9ccb5551b4eacdabe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Mon, 4 Mar 2024 22:06:32 +0100 Subject: [PATCH] [CI] Update pre-commit and remove ros-lint (#187) --- .github/workflows/ci-format.yml | 21 --------- .github/workflows/ci-pre-commit.yml | 15 +++++++ .github/workflows/ros-lint.yml | 59 ------------------------- .github/workflows/update-pre-commit.yml | 12 +++++ .pre-commit-config.yaml | 45 ++++++++++--------- CONTRIBUTING.md | 1 - README.md | 1 + src/sine_sweep.cpp | 2 +- 8 files changed, 52 insertions(+), 104 deletions(-) delete mode 100644 .github/workflows/ci-format.yml create mode 100644 .github/workflows/ci-pre-commit.yml delete mode 100644 .github/workflows/ros-lint.yml create mode 100644 .github/workflows/update-pre-commit.yml diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-format.yml deleted file mode 100644 index 88fad33b..00000000 --- a/.github/workflows/ci-format.yml +++ /dev/null @@ -1,21 +0,0 @@ -# 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: - -jobs: - pre-commit: - name: Format - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 - - name: Install clang-format-14 - run: sudo apt-get install clang-format-14 cppcheck - - uses: pre-commit/action@v3.0.1 - with: - extra_args: --all-files --hook-stage manual diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml new file mode 100644 index 00000000..676f1f46 --- /dev/null +++ b/.github/workflows/ci-pre-commit.yml @@ -0,0 +1,15 @@ +name: Pre-Commit + +on: + workflow_dispatch: + pull_request: + +jobs: + pre-commit: + uses: ros-controls/ros2_control_ci/.github/workflows/reusable-pre-commit.yml@master + strategy: + fail-fast: false + matrix: + ROS_DISTRO: [rolling, iron, humble] + with: + ros_distro: ${{ matrix.ROS_DISTRO }} diff --git a/.github/workflows/ros-lint.yml b/.github/workflows/ros-lint.yml deleted file mode 100644 index 11060a32..00000000 --- a/.github/workflows/ros-lint.yml +++ /dev/null @@ -1,59 +0,0 @@ -name: ROS2 Lint -on: - pull_request: - -jobs: - ament_lint: - name: ament_${{ matrix.linter }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - linter: [copyright, lint_cmake] - steps: - - uses: actions/checkout@v4 - - uses: ros-tooling/setup-ros@v0.7 - - uses: ros-tooling/action-ros-lint@v0.1 - with: - distribution: rolling - linter: ${{ matrix.linter }} - package-name: - control_toolbox - - ament_lint_100: - name: ament_${{ matrix.linter }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - linter: [cpplint] - steps: - - uses: actions/checkout@v4 - - uses: ros-tooling/setup-ros@v0.7 - - uses: ros-tooling/action-ros-lint@v0.1 - with: - distribution: rolling - linter: cpplint - arguments: "--linelength=100 --filter=-whitespace/newline" - package-name: - control_toolbox - - ament_cppcheck: - name: ament_${{ matrix.linter }} - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - linter: [cppcheck] - env: - AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true - steps: - - uses: actions/checkout@v4 - - uses: ros-tooling/setup-ros@0.7.1 - - uses: ros-tooling/action-ros-lint@v0.1 - with: - distribution: rolling - linter: ${{ matrix.linter }} - arguments: "--language=c++" - package-name: - control_toolbox diff --git a/.github/workflows/update-pre-commit.yml b/.github/workflows/update-pre-commit.yml new file mode 100644 index 00000000..8b9545df --- /dev/null +++ b/.github/workflows/update-pre-commit.yml @@ -0,0 +1,12 @@ +name: Auto Update pre-commit +# Update pre-commit config and create PR if changes are detected +# author: Christoph Fröhlich + +on: + workflow_dispatch: + schedule: + - cron: '0 0 * * 0' # Run every Sunday at midnight + +jobs: + auto_update_and_create_pr: + uses: ros-controls/ros2_control_ci/.github/workflows/reusable-update-pre-commit.yml@master diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3e0e111c..ec3cbbf3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: # Standard hooks - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v4.5.0 hooks: - id: check-added-large-files - id: check-ast @@ -36,17 +36,11 @@ repos: # Python hooks - repo: https://github.com/asottile/pyupgrade - rev: v3.3.1 + rev: v3.15.1 hooks: - id: pyupgrade args: [--py36-plus] - - repo: https://github.com/psf/black - rev: 23.1.0 - hooks: - - id: black - args: ["--line-length=99"] - # PyDocStyle - repo: https://github.com/PyCQA/pydocstyle rev: 6.3.0 @@ -54,21 +48,23 @@ repos: - id: pydocstyle args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"] + - repo: https://github.com/psf/black + rev: 24.2.0 + hooks: + - id: black + args: ["--line-length=99"] + - repo: https://github.com/pycqa/flake8 - rev: 6.0.0 + rev: 7.0.0 hooks: - id: flake8 args: ["--extend-ignore=E501"] # CPP hooks - - repo: local + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v17.0.6 hooks: - id: clang-format - name: clang-format - description: Format files with ClangFormat. - entry: clang-format-14 - 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: local @@ -76,18 +72,15 @@ repos: - id: ament_cppcheck name: ament_cppcheck description: Static code analysis of C/C++ files. - stages: [commit] - entry: ament_cppcheck + entry: env AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS=1 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)$ @@ -99,7 +92,6 @@ repos: - 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$ @@ -110,7 +102,6 @@ repos: - id: ament_copyright name: ament_copyright description: Check if copyright notice is available in all files. - stages: [commit] entry: ament_copyright language: system @@ -133,8 +124,18 @@ repos: # Spellcheck in comments and docs # skipping of *.svg files is not working... - repo: https://github.com/codespell-project/codespell - rev: v2.2.2 + rev: v2.2.6 hooks: - id: codespell args: ['--write-changes'] exclude: CHANGELOG\.rst|\.(svg|pyc)$ + + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.28.0 + hooks: + - id: check-github-workflows + args: ["--verbose"] + - id: check-github-actions + args: ["--verbose"] + - id: check-dependabot + args: ["--verbose"] diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7b741ee5..dcace4f9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,4 +58,3 @@ be under the 3-Clause BSD License, as dictated by that [issues]: https://github.com/ros-controls/control_toolbox/issues [closed-issues]: https://github.com/ros-controls/control_toolbox/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aclosed%20 [help-wanted]: https://github.com/ros-controls/control_toolbox/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22 -[license]: https://opensource.org/licenses/BSD-3-Clause diff --git a/README.md b/README.md index 0dd32485..846c4a7e 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ control_toolbox =========== +[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause) [![codecov](https://codecov.io/gh/ros-controls/control_toolbox/graph/badge.svg?token=0o4dFzADHj)](https://codecov.io/gh/ros-controls/control_toolbox) See the documentation of [ros2_control](http://control.ros.org) and release infos on [index.ros.org](http://index.ros.org/p/control_toolbox). diff --git a/src/sine_sweep.cpp b/src/sine_sweep.cpp index f606907a..eb000f36 100644 --- a/src/sine_sweep.cpp +++ b/src/sine_sweep.cpp @@ -60,7 +60,7 @@ bool SineSweep::init(double start_freq, double end_freq, double duration, double amplitude_ = amplitude; duration_ = rclcpp::Duration::from_seconds(duration); - // calculate the angular fequencies + // calculate the angular frequencies start_angular_freq_ = 2 * M_PI * start_freq; end_angular_freq_ = 2 * M_PI * end_freq;