From eded02c0f393a8e1802931f9f9e45c12786b2c10 Mon Sep 17 00:00:00 2001 From: Nathan Moinvaziri Date: Mon, 19 Aug 2024 20:03:39 -0700 Subject: [PATCH] Upgrade clang-format to use version 17. --- .github/workflows/lint.yaml | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 89beb32..c2cb514 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -2,6 +2,7 @@ name: Lint on: [workflow_dispatch, pull_request] env: TERM: xterm-256color + CLANG_VERSION: 17 jobs: clang-format: @@ -11,9 +12,10 @@ jobs: - name: Install clang-format run: | wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - - sudo add-apt-repository 'deb http://apt.llvm.org/focal/ llvm-toolchain-focal-14 main' - sudo apt update - sudo apt install -y clang-format-14 + UBCN=$(lsb_release --short --codename) + sudo add-apt-repository "deb https://apt.llvm.org/${UBCN}/ llvm-toolchain-${UBCN}-${CLANG_VERSION} main" + sudo apt update || true + sudo apt install -y clang-format-${CLANG_VERSION} - name: Checkout repository uses: actions/checkout@v4 @@ -23,9 +25,8 @@ jobs: - name: Run clang-format run: | - output=$(git clang-format-14 --binary=clang-format-14 --diff --commit=origin/dev) - grep '^no modified files to format$' <<< "$output" && exit 0 - grep '^clang-format did not modify any files$' <<< "$output" && exit 0 - echo "$output" - echo -e "\033[1;31mCode style does not match clang-format" - exit 1 + if ! git clang-format-${CLANG_VERSION} --binary=clang-format-${CLANG_VERSION} --diff --commit=origin/dev + then + echo -e "\033[1;31mCode style does not match clang-format" + exit 1 + fi