From 750826446e371d8a988eb1159cb73f766a8b3732 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Sun, 18 Feb 2024 10:23:23 +0100 Subject: [PATCH 01/19] Create ci-format.yml --- .github/workflows/ci-format.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/ci-format.yml diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-format.yml new file mode 100644 index 0000000..569bb95 --- /dev/null +++ b/.github/workflows/ci-format.yml @@ -0,0 +1,23 @@ +# 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.0.0 + with: + python-version: '3.10' + - name: Install system hooks + run: sudo apt install -qq cppcheck + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --hook-stage manual From 54a3d052d0f4f7e57614de1c66ac50f9f0ea746b Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 09:46:08 +0000 Subject: [PATCH 02/19] Create a reusable workflow --- .github/workflows/ci-format.yml | 16 +--------------- .github/workflows/reusable-ci-format.yml | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/reusable-ci-format.yml diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-format.yml index 569bb95..343add7 100644 --- a/.github/workflows/ci-format.yml +++ b/.github/workflows/ci-format.yml @@ -1,6 +1,3 @@ -# 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: @@ -9,15 +6,4 @@ on: jobs: pre-commit: - name: Format - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5.0.0 - with: - python-version: '3.10' - - name: Install system hooks - run: sudo apt install -qq cppcheck - - uses: pre-commit/action@v3.0.1 - with: - extra_args: --all-files --hook-stage manual + uses: ./.github/workflows/reusable-ci-format.yml diff --git a/.github/workflows/reusable-ci-format.yml b/.github/workflows/reusable-ci-format.yml new file mode 100644 index 0000000..e9f173e --- /dev/null +++ b/.github/workflows/reusable-ci-format.yml @@ -0,0 +1,24 @@ +name: Format +# This is a format job. Pre-commit has a first-party GitHub action, so we use +# that: https://github.com/pre-commit/action +# The pre-commit configuration is in .pre-commit-config.yaml + +on: + workflow_call: + +jobs: + pre-commit: + name: Format + runs-on: ubuntu-latest + env: + AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-python@v5.0.0 + with: + python-version: '3.10' + - name: Install system hooks + run: sudo apt install -qq clang-format-14 cppcheck + - uses: pre-commit/action@v3.0.1 + with: + extra_args: --all-files --hook-stage manual From df325c35d724d6848710886e64389a92859ffc3e Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 11:10:20 +0000 Subject: [PATCH 03/19] Fix typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f9a10a..064ad93 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ This repository holds reusable workflows for CI of the ros2_control framework. -It also build the full ros2_control stack once per day. +It also builds the full ros2_control stack once per day. [![Rolling Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/rolling-binary-build.yml) [![Iron Stack Build](https://github.com/ros-controls/ros2_control_ci/actions/workflows/iron-binary-build.yml/badge.svg)](https://github.com/ros-controls/ros2_control_ci/actions/workflows/iron-binary-build.yml) From d069b1daa1c3682bc5b93740d380e7d8566d84b4 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 21:59:11 +0000 Subject: [PATCH 04/19] Rename workflows and remove system hooks --- .github/workflows/{ci-format.yml => ci-pre-commit.yml} | 2 +- .../{reusable-ci-format.yml => reusable-pre-commit.yml} | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) rename .github/workflows/{ci-format.yml => ci-pre-commit.yml} (58%) rename .github/workflows/{reusable-ci-format.yml => reusable-pre-commit.yml} (86%) diff --git a/.github/workflows/ci-format.yml b/.github/workflows/ci-pre-commit.yml similarity index 58% rename from .github/workflows/ci-format.yml rename to .github/workflows/ci-pre-commit.yml index 343add7..bda437d 100644 --- a/.github/workflows/ci-format.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -6,4 +6,4 @@ on: jobs: pre-commit: - uses: ./.github/workflows/reusable-ci-format.yml + uses: ./.github/workflows/reusable-pre-commit.yml diff --git a/.github/workflows/reusable-ci-format.yml b/.github/workflows/reusable-pre-commit.yml similarity index 86% rename from .github/workflows/reusable-ci-format.yml rename to .github/workflows/reusable-pre-commit.yml index e9f173e..32856bb 100644 --- a/.github/workflows/reusable-ci-format.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -17,8 +17,6 @@ jobs: - uses: actions/setup-python@v5.0.0 with: python-version: '3.10' - - name: Install system hooks - run: sudo apt install -qq clang-format-14 cppcheck - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files --hook-stage manual From 4669354e97ae5bdcd375852480aae9c2a071ad20 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 22:08:02 +0000 Subject: [PATCH 05/19] Remove commit stage from ros linters --- .pre-commit-config.yaml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 6e6d41c..4bc8f2c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,6 @@ repos: - 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)$ @@ -82,7 +81,6 @@ repos: - 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)$ @@ -94,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$ @@ -105,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 From 913e0e2866b10a12694ea451a471dd37a9f5c6f5 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 22:49:22 +0000 Subject: [PATCH 06/19] Install proper system hooks for ament_linters --- .github/workflows/ci-pre-commit.yml | 2 ++ .github/workflows/reusable-pre-commit.yml | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/.github/workflows/ci-pre-commit.yml b/.github/workflows/ci-pre-commit.yml index bda437d..ac7d8d6 100644 --- a/.github/workflows/ci-pre-commit.yml +++ b/.github/workflows/ci-pre-commit.yml @@ -7,3 +7,5 @@ on: jobs: pre-commit: uses: ./.github/workflows/reusable-pre-commit.yml + with: + ros_distro: rolling diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 32856bb..9bf13bc 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -5,6 +5,11 @@ name: Format on: workflow_call: + inputs: + ros_distro: + description: 'ROS2 distribution name' + required: true + type: string jobs: pre-commit: @@ -14,6 +19,9 @@ jobs: AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true steps: - uses: actions/checkout@v4 + - uses: ros-tooling/setup-ros@0.7.1 + - name: Install system hooks + run: sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppckeck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright - uses: actions/setup-python@v5.0.0 with: python-version: '3.10' From b2d414b984de27457098672025fd93d4a5265c22 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 22:53:27 +0000 Subject: [PATCH 07/19] Fix typo --- .github/workflows/reusable-pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 9bf13bc..5e0f88a 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -21,7 +21,7 @@ jobs: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1 - name: Install system hooks - run: sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppckeck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright + run: sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright - uses: actions/setup-python@v5.0.0 with: python-version: '3.10' From bcb7a0503aaaf42b2c47f46ff4e35de70acada83 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 22:58:12 +0000 Subject: [PATCH 08/19] Try not to give explicit python version --- .github/workflows/reusable-pre-commit.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 5e0f88a..e990448 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -22,9 +22,6 @@ jobs: - uses: ros-tooling/setup-ros@0.7.1 - name: Install system hooks run: sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright - - uses: actions/setup-python@v5.0.0 - with: - python-version: '3.10' - uses: pre-commit/action@v3.0.1 with: extra_args: --all-files --hook-stage manual From b6915477461ecb6a0b51c014bafd3e7b5f95881f Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 23:17:46 +0000 Subject: [PATCH 09/19] Update pre-commit hook versions --- .pre-commit-config.yaml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4bc8f2c..daafc2b 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,7 +36,7 @@ repos: # Python hooks - repo: https://github.com/asottile/pyupgrade - rev: v3.4.0 + rev: v3.15.1 hooks: - id: pyupgrade args: [--py36-plus] @@ -49,20 +49,20 @@ repos: args: ["--ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404"] - repo: https://github.com/psf/black - rev: 23.3.0 + 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: https://github.com/pre-commit/mirrors-clang-format - rev: v15.0.6 + rev: v17.0.6 hooks: - id: clang-format @@ -75,7 +75,6 @@ repos: 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 @@ -124,7 +123,7 @@ repos: # Spellcheck in comments and docs # skipping of *.svg files is not working... - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.2.6 hooks: - id: codespell args: ['--write-changes'] From 259c54dd382dc58bc903625b43a949ced2f69bdc Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 23:20:44 +0000 Subject: [PATCH 10/19] Remove redundant job name --- .github/workflows/reusable-pre-commit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index e990448..c5c1a65 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -13,7 +13,6 @@ on: jobs: pre-commit: - name: Format runs-on: ubuntu-latest env: AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true From d09ae582ab602a121d0c059ad66f5a6ac8bc68ad Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 23:22:42 +0000 Subject: [PATCH 11/19] Set AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS directly with pre-commit config --- .github/workflows/reusable-pre-commit.yml | 2 -- .pre-commit-config.yaml | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index c5c1a65..5ee5259 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -14,8 +14,6 @@ on: jobs: pre-commit: runs-on: ubuntu-latest - env: - AMENT_CPPCHECK_ALLOW_SLOW_VERSIONS: true steps: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index daafc2b..8dc0c0a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -71,7 +71,7 @@ repos: - id: ament_cppcheck name: ament_cppcheck description: Static code analysis of C/C++ files. - 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)$ From 17f3c52ffb23f918362db381e35cec9fe5dee639 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Sun, 18 Feb 2024 23:49:55 +0000 Subject: [PATCH 12/19] Source ROS workspace --- .github/workflows/reusable-pre-commit.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 5ee5259..d050c0c 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -18,7 +18,17 @@ jobs: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1 - name: Install system hooks - run: sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright + run: | + sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright + source /opt/ros/${{ inputs.ros_distro }}/setup.bash + echo ROS_PATH=$PATH >> $GITHUB_ENV + - env: + PATH: ${{ env.ROS_PATH }} + run: | + echo $PATH + python --version - uses: pre-commit/action@v3.0.1 + env: + PATH: ${{ env.ROS_PATH }} with: extra_args: --all-files --hook-stage manual From b49f7ee57bbe26bc1bac05efc9ba2770bbfbeb30 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 19 Feb 2024 00:14:00 +0000 Subject: [PATCH 13/19] Run pre-commit manually instead of composite action --- .github/workflows/reusable-pre-commit.yml | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index d050c0c..5266921 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -17,18 +17,13 @@ jobs: steps: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1 + - uses: actions/cache@v4 + with: + path: ~/.cache/pre-commit + key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }} - name: Install system hooks run: | sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright source /opt/ros/${{ inputs.ros_distro }}/setup.bash - echo ROS_PATH=$PATH >> $GITHUB_ENV - - env: - PATH: ${{ env.ROS_PATH }} - run: | - echo $PATH - python --version - - uses: pre-commit/action@v3.0.1 - env: - PATH: ${{ env.ROS_PATH }} - with: - extra_args: --all-files --hook-stage manual + python -m pip install pre-commit + pre-commit run --show-diff-on-failure --color=always --all-files --hook-stage manual From 1e8f742dea34f9caf9f828ad56df830f4c276814 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 19 Feb 2024 00:20:02 +0000 Subject: [PATCH 14/19] Update comments --- .github/workflows/reusable-pre-commit.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 5266921..36794d2 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -1,7 +1,6 @@ -name: Format -# This is a format job. Pre-commit has a first-party GitHub action, so we use -# that: https://github.com/pre-commit/action +name: Pre-commit # The pre-commit configuration is in .pre-commit-config.yaml +# we don't use the pre-commit action because it doesn't support local hooks in its virtual environment on: workflow_call: @@ -20,8 +19,8 @@ jobs: - uses: actions/cache@v4 with: path: ~/.cache/pre-commit - key: pre-commit-3|${{ hashFiles('.pre-commit-config.yaml') }} - - name: Install system hooks + key: pre-commit-3|${{ inputs.ros_distro }}|${{ hashFiles('.pre-commit-config.yaml') }} + - name: Install system hooks and run pre-commit run: | sudo apt-get install -qq ros-${{ inputs.ros_distro }}-ament-cppcheck ros-${{ inputs.ros_distro }}-ament-cpplint ros-${{ inputs.ros_distro }}-ament-lint-cmake ros-${{ inputs.ros_distro }}-ament-copyright source /opt/ros/${{ inputs.ros_distro }}/setup.bash From 56a83039498838492673ddc1bce39a3f56e22d5b Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 19 Feb 2024 00:24:40 +0000 Subject: [PATCH 15/19] Add linters for github actions and workflows --- .github/workflows/reusable-ros-tooling-source-build.yml | 2 -- .pre-commit-config.yaml | 8 ++++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/reusable-ros-tooling-source-build.yml b/.github/workflows/reusable-ros-tooling-source-build.yml index 86a2d2c..424cba3 100644 --- a/.github/workflows/reusable-ros-tooling-source-build.yml +++ b/.github/workflows/reusable-ros-tooling-source-build.yml @@ -31,8 +31,6 @@ jobs: env: # this will be src/{repo-owner}/{repo-name} path: src/${{ github.repository }} - strategy: - fail-fast: false steps: - uses: ros-tooling/setup-ros@0.7.1 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8dc0c0a..4c27d33 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -128,3 +128,11 @@ repos: - 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"] From 5b0c6fd9fbc393f5ca791b9a65199e6da8d68919 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 19 Feb 2024 00:41:37 +0000 Subject: [PATCH 16/19] Use fallback-style to clang-format --- .pre-commit-config.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c27d33..ec3cbbf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -65,6 +65,7 @@ repos: rev: v17.0.6 hooks: - id: clang-format + args: ['-fallback-style=none', '-i'] - repo: local hooks: @@ -136,3 +137,5 @@ repos: args: ["--verbose"] - id: check-github-actions args: ["--verbose"] + - id: check-dependabot + args: ["--verbose"] From e70f7697d8e54e0ab42da2859b701fc6a9efd3a4 Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Mon, 19 Feb 2024 09:44:05 +0000 Subject: [PATCH 17/19] Add pre-commit auto-update workflows --- .../workflows/reusable-update-pre-commit.yml | 49 +++++++++++++++++++ .github/workflows/update-pre-commit.yml | 12 +++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/reusable-update-pre-commit.yml create mode 100644 .github/workflows/update-pre-commit.yml diff --git a/.github/workflows/reusable-update-pre-commit.yml b/.github/workflows/reusable-update-pre-commit.yml new file mode 100644 index 0000000..36f9230 --- /dev/null +++ b/.github/workflows/reusable-update-pre-commit.yml @@ -0,0 +1,49 @@ +name: Update pre-commit +# Update pre-commit config and create PR if changes are detected +# author: Christoph Fröhlich + +on: + workflow_call: + +jobs: + auto_update_and_create_pr: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install pre-commit + run: | + pip install pre-commit + + - name: Auto-update with pre-commit + run: | + pre-commit autoupdate || true # Ignoring errors + + - name: Check for changes + id: git_status + run: | + git diff --quiet && echo "::set-output name=changed::false" || echo "::set-output name=changed::true" + + - name: There are changes + if: steps.git_status.outputs.changed == 'true' + run: | + echo "Files have changed" + git diff --exit-code || true + + - name: No changes! + if: steps.git_status.outputs.changed == 'false' + run: | + echo "No changes detected" + + - name: Create Pull Request + if: steps.git_status.outputs.changed == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: auto-update + commit-message: Auto-update with pre-commit + title: Bump version of pre-commit hooks + body: This pull request contains auto-updated files of pre-commit config. + delete-branch: true diff --git a/.github/workflows/update-pre-commit.yml b/.github/workflows/update-pre-commit.yml new file mode 100644 index 0000000..81a42f5 --- /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: ./.github/workflows/reusable-update-pre-commit.yml From adcac78101e28170ff0ddc58606da033252d130b Mon Sep 17 00:00:00 2001 From: Christoph Froehlich Date: Tue, 20 Feb 2024 22:37:06 +0000 Subject: [PATCH 18/19] Add os_name input --- .github/workflows/reusable-pre-commit.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index 36794d2..dda4c67 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -9,10 +9,15 @@ on: description: 'ROS2 distribution name' required: true type: string + os_name: + description: 'On which OS to run the linter' + required: false + default: 'ubuntu-latest' + type: string jobs: pre-commit: - runs-on: ubuntu-latest + runs-on: os_name steps: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1 From 92072dacb16af74f74b07940cd6dead333f560d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20Fr=C3=B6hlich?= Date: Wed, 21 Feb 2024 21:06:51 +0100 Subject: [PATCH 19/19] Fix os_name --- .github/workflows/reusable-pre-commit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-pre-commit.yml b/.github/workflows/reusable-pre-commit.yml index dda4c67..62c0e29 100644 --- a/.github/workflows/reusable-pre-commit.yml +++ b/.github/workflows/reusable-pre-commit.yml @@ -17,7 +17,7 @@ on: jobs: pre-commit: - runs-on: os_name + runs-on: ${{ inputs.os_name }} steps: - uses: actions/checkout@v4 - uses: ros-tooling/setup-ros@0.7.1