From 7db4fca6c09e031fe3e66a2261569abde71fd735 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Mon, 11 Apr 2022 19:25:32 -0500 Subject: [PATCH] Allow override of clang-format executable Because GitHub's Ubuntu image offers multiple version fo clang-format, and sometimes it seems to prefer a version lower than 12 (which is the minimum required by our config file), I added an override via the new environment variable `KALEIDOSCOPE_CODE_FORMATTER`. Signed-off-by: Michael Richters --- .github/workflows/build.yml | 2 +- bin/format-code.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a2d0f93..0cdc31b2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,7 +36,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: make check-code-style + - run: KALEIDOSCOPE_CODE_FORMATTER=clang-format-12 make check-code-style check-shellcheck: runs-on: ubuntu-latest steps: diff --git a/bin/format-code.py b/bin/format-code.py index 59a464d4..f8eaf963 100755 --- a/bin/format-code.py +++ b/bin/format-code.py @@ -172,7 +172,9 @@ def main(): return 1 # Locate `clang-format` executable: - clang_format_exe = shutil.which('clang-format') + clang_format_exe = os.getenv('KALEIDOSCOPE_CODE_FORMATTER') + if clang_format_exe is None: + clang_format_exe = shutil.which('clang-format') logging.debug("Found `clang-format` executable: %s", clang_format_exe) clang_format_cmd = [clang_format_exe, '-i'] if opts.loglevel <= logging.INFO: