From d3d28c9336cdaa83a270960bcb831452e85630d0 Mon Sep 17 00:00:00 2001 From: Masahiro Kubota <42679530+masahiro-kubota@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:38:52 +0900 Subject: [PATCH] Ci/add commit test2 (#11) * add-precommit Signed-off-by: Masahiro Kubota * add precommit Signed-off-by: Masahiro Kubota * modify Signed-off-by: Masahiro Kubota * modify Signed-off-by: Masahiro Kubota * modify Signed-off-by: Masahiro Kubota * modify Signed-off-by: Masahiro Kubota * delete redundant hook Signed-off-by: Masahiro Kubota * add --fix arg Signed-off-by: Masahiro Kubota * Revert "add --fix arg" This reverts commit 4b06ccab9c2b69586c60ad2858d17b9828fefdbb. Signed-off-by: Masahiro Kubota * remove autoware-precommit Signed-off-by: Masahiro Kubota * delete cache Signed-off-by: Masahiro Kubota * modify precommit Signed-off-by: Masahiro Kubota * modify precommit options Signed-off-by: Masahiro Kubota * add config Signed-off-by: Masahiro Kubota --------- Signed-off-by: Masahiro Kubota --- .clang-format | 51 ++++++++++++++++++++++++++ .github/workflows/pre-commit.yaml | 19 ++++++++++ .markdownlint.yaml | 9 +++++ .pre-commit-config.yaml | 61 +++++++++++++++++++++++++++++++ .prettierignore | 6 +++ .prettierrc.yaml | 24 ++++++++++++ .yamllint.yaml | 26 +++++++++++++ CPPLINT.cfg | 20 ++++++++++ 8 files changed, 216 insertions(+) create mode 100644 .clang-format create mode 100644 .github/workflows/pre-commit.yaml create mode 100644 .markdownlint.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 .prettierignore create mode 100644 .prettierrc.yaml create mode 100644 .yamllint.yaml create mode 100644 CPPLINT.cfg diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..bbf9715 --- /dev/null +++ b/.clang-format @@ -0,0 +1,51 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +# Modified from https://github.com/ament/ament_lint/blob/master/ament_clang_format/ament_clang_format/configuration/.clang-format +Language: Cpp +BasedOnStyle: Google + +AccessModifierOffset: -2 +AlignAfterOpenBracket: AlwaysBreak +AllowShortFunctionsOnASingleLine: InlineOnly +BraceWrapping: + AfterClass: true + AfterFunction: true + AfterNamespace: true + AfterStruct: true +BreakBeforeBraces: Custom +ColumnLimit: 100 +ConstructorInitializerIndentWidth: 0 +ContinuationIndentWidth: 2 +DerivePointerAlignment: false +PointerAlignment: Middle +ReflowComments: true +IncludeCategories: + # C++ system headers + - Regex: <[a-z_]*> + Priority: 6 + CaseSensitive: true + # C system headers + - Regex: <.*\.h> + Priority: 5 + CaseSensitive: true + # Boost headers + - Regex: boost/.* + Priority: 4 + CaseSensitive: true + # Message headers + - Regex: .*_msgs/.* + Priority: 3 + CaseSensitive: true + - Regex: .*_srvs/.* + Priority: 3 + CaseSensitive: true + # Other Package headers + - Regex: <.*> + Priority: 2 + CaseSensitive: true + # Local package headers + - Regex: '".*"' + Priority: 1 + CaseSensitive: true \ No newline at end of file diff --git a/.github/workflows/pre-commit.yaml b/.github/workflows/pre-commit.yaml new file mode 100644 index 0000000..61f6d65 --- /dev/null +++ b/.github/workflows/pre-commit.yaml @@ -0,0 +1,19 @@ +on: + pull_request: +jobs: + pre-commit: + runs-on: ubuntu-latest + steps: + - name: Check out repository + uses: actions/checkout@v3 + with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} + + - name: Set git config + uses: autowarefoundation/autoware-github-actions/set-git-config@v1 + + - name: Run pre-commit + uses: pre-commit/action@v3.0.1 + with: + extra_args: --config .pre-commit-config.yaml --all-files diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..cdc87c8 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,9 @@ +# See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md for all rules. +default: true +MD013: false +MD024: + siblings_only: true +MD033: false +MD041: false +MD046: false +MD049: false \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..a99f3c0 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,61 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +# https://pre-commit.ci/#configuration +ci: + autofix_commit_msg: "style(pre-commit): autofix" + # we already have our own daily update mechanism, we set this to quarterly + autoupdate_schedule: quarterly + autoupdate_commit_msg: "ci(pre-commit): quarterly autoupdate" + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-merge-conflict + - id: check-xml + - id: check-yaml + args: [--unsafe] + - id: detect-private-key + - id: end-of-file-fixer + - id: mixed-line-ending + - id: trailing-whitespace + args: [--markdown-linebreak-ext=md] + + - repo: https://github.com/igorshubovych/markdownlint-cli + rev: v0.43.0 + hooks: + - id: markdownlint + args: [-c, .markdownlint.yaml, --fix] + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v4.0.0-alpha.8 + hooks: + - id: prettier + + - repo: https://github.com/adrienverge/yamllint + rev: v1.35.1 + hooks: + - id: yamllint + + - repo: https://github.com/tier4/pre-commit-hooks-ros + rev: v0.10.0 + hooks: + - id: prettier-launch-xml + - id: prettier-package-xml + - id: ros-include-guard + - id: sort-package-xml + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format + types_or: [c++, c, cuda] + + - repo: https://github.com/cpplint/cpplint + rev: 2.0.0 + hooks: + - id: cpplint + args: [--quiet] + exclude: .cu \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..3f85574 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +*.param.yaml +*.rviz \ No newline at end of file diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 0000000..f26e895 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,24 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +printWidth: 100 +tabWidth: 2 +overrides: + - files: package.xml + options: + printWidth: 1000 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore + + - files: "*.launch.xml" + options: + printWidth: 200 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore + + - files: "*.xacro" + options: + printWidth: 200 + xmlSelfClosingSpace: false + xmlWhitespaceSensitivity: ignore \ No newline at end of file diff --git a/.yamllint.yaml b/.yamllint.yaml new file mode 100644 index 0000000..f635c55 --- /dev/null +++ b/.yamllint.yaml @@ -0,0 +1,26 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +extends: default + +ignore: | + *.param.yaml + +rules: + braces: + level: error + max-spaces-inside: 1 # To format with Prettier + comments: + level: error + min-spaces-from-content: 1 # To be compatible with C++ and Python + document-start: + level: error + present: false # Don't need document start markers + line-length: disable # Delegate to Prettier + truthy: + level: error + check-keys: false # To allow 'on' of GitHub Actions + quoted-strings: + level: error + required: only-when-needed # To keep consistent style \ No newline at end of file diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 0000000..928cdd9 --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,20 @@ +# This file is automatically synced from: +# https://github.com/autowarefoundation/sync-file-templates +# To make changes, update the source repository and follow the guidelines in its README. + +# Modified from https://github.com/ament/ament_lint/blob/ebd524bb9973d5ec1dc48a670ce54f958a5a0243/ament_cpplint/ament_cpplint/main.py#L64-L120 +set noparent +linelength=100 +includeorder=standardcfirst +filter=-build/c++11 # we do allow C++11 +filter=-build/c++17 # we allow +filter=-build/namespaces_literals # we allow using namespace for literals +filter=-runtime/references # we consider passing non-const references to be ok +filter=-whitespace/braces # we wrap open curly braces for namespaces, classes and functions +filter=-whitespace/indent # we don't indent keywords like public, protected and private with one space +filter=-whitespace/newline # we allow the developer to decide about newline at the end of file (it's clashing with clang-format) +filter=-whitespace/parens # we allow closing parenthesis to be on the next line +filter=-whitespace/semicolon # we allow the developer to decide about whitespace after a semicolon +filter=-build/header_guard # we automatically fix the names of header guards using pre-commit +filter=-build/include_order # we use the custom include order +filter=-build/include_subdir # we allow the style of "foo.hpp" \ No newline at end of file