diff --git a/README.md b/README.md index 2c5a712..6c4d479 100644 --- a/README.md +++ b/README.md @@ -8,27 +8,27 @@ GitHub Action for `clang-format` checks. Note that this Action does **NOT** form You can define your own formatting rules in a `.clang-format` file at your repository root, or you can provide a fallback style (see [`fallback-style`](#inputs)). You can also provide a path to check. If you want to run checks against multiple paths in your repository, you can use this Action in a [matrix run](#multiple-paths). -## Versions supported -* `clang-format-3.9` -* `clang-format-4.0` -* `clang-format-5.0` -* `clang-format-6.0` -* `clang-format-7` -* `clang-format-8` -* `clang-format-9` -* `clang-format-10` -* `clang-format-11` -* `clang-format-12` -* `clang-format-13` -* `clang-format-14` -* `clang-format-15` +## Major versions supported +* 3: `clang-format-3.9` +* 4: `clang-format-4.0` +* 5: `clang-format-5.0` +* 6: `clang-format-6.0` +* 7: `clang-format-7` +* 8: `clang-format-8` +* 9: `clang-format-9` +* 10: `clang-format-10` +* 11: `clang-format-11` +* 12: `clang-format-12` +* 13: `clang-format-13` +* 14: `clang-format-14` +* 15: `clang-format-15` ## Do you find this useful? You can sponsor me [here](https://github.com/sponsors/jidicula)! ## Inputs -* `clang-format-version` [optional]: The version of `clang-format` that you want to run on your codebase. +* `clang-format-version` [optional]: The major version of `clang-format` that you want to run on your codebase. * Default: `13` * Available versions: see [Versions supported](#versions-supported) * `check-path` [optional]: The path to the directory in the repo that should be checked for C/C++/Protobuf formatting. diff --git a/action.yml b/action.yml index 2e12039..7aec3f1 100644 --- a/action.yml +++ b/action.yml @@ -7,7 +7,7 @@ branding: inputs: clang-format-version: - description: 'The version of clang-format that you want to use.' + description: 'The major version of clang-format that you want to use.' required: false default: '13' check-path: diff --git a/check.sh b/check.sh index 73f11da..4ea3929 100755 --- a/check.sh +++ b/check.sh @@ -5,11 +5,11 @@ ############################################################################### # USAGE: ./entrypoint.sh [] [] # -# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c, .C, -# .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path +# Checks all C/C++/Protobuf/CUDA files (.h, .H, .hpp, .hh, .h++, .hxx and .c, +# .C, .cpp, .cc, .c++, .cxx, .proto, .cu) in the provided GitHub repository path # (arg1) for conforming to clang-format. If no path is provided or provided path -# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files are -# incorrectly formatted, the script lists them and exits with 1. +# is not a directory, all C/C++/Protobuf/CUDA files are checked. If any files +# are incorrectly formatted, the script lists them and exits with 1. # # Define your own formatting rules in a .clang-format file at your repository # root. Otherwise, the provided style guide (arg2) is used as a fallback. @@ -20,10 +20,10 @@ format_diff() { local filepath="$1" # Invoke clang-format with dry run and formatting error output - if [[ $CLANG_FORMAT_VERSION -gt "9" ]]; then - local_format="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_VERSION" -n --Werror --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" + if [[ $CLANG_FORMAT_MAJOR_VERSION -gt "9" ]]; then + local_format="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" -n --Werror --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" else # Versions below 9 don't have dry run - formatted="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_VERSION" --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" + formatted="$(docker run -i -v "$(pwd)":"$(pwd)" -w "$(pwd)" --rm ghcr.io/jidicula/clang-format:"$CLANG_FORMAT_MAJOR_VERSION" --style=file --fallback-style="$FALLBACK_STYLE" "${filepath}")" local_format="$(diff -q <(cat "${filepath}") <(echo "${formatted}"))" fi @@ -41,7 +41,7 @@ format_diff() { return 0 } -CLANG_FORMAT_VERSION="$1" +CLANG_FORMAT_MAJOR_VERSION="$1" CHECK_PATH="$2" FALLBACK_STYLE="$3" EXCLUDE_REGEX="$4"