From 1e0b90db45baba5ac86ff1d37e56f029696bdad6 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Sat, 5 Aug 2023 22:21:14 -0400 Subject: [PATCH 1/3] common: bump up the required clang-format version --- src/benchmarks/pmembench.cpp | 7 ++++--- utils/style_check.sh | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/benchmarks/pmembench.cpp b/src/benchmarks/pmembench.cpp index 5c73e2682ce..0f73242ff8b 100644 --- a/src/benchmarks/pmembench.cpp +++ b/src/benchmarks/pmembench.cpp @@ -1215,9 +1215,10 @@ scale_up_min_exe_time(struct benchmark *bench, struct benchmark_args *args, * scale up number of operations to get assumed minimal * execution time */ - args->n_ops_per_thread = (size_t)( - (double)args->n_ops_per_thread * - (min_exe_time + MIN_EXE_TIME_E) / total_res->total.min); + args->n_ops_per_thread = + (size_t)((double)args->n_ops_per_thread * + (min_exe_time + MIN_EXE_TIME_E) / + total_res->total.min); results_free(total_res); *total_results = results_alloc(args); diff --git a/utils/style_check.sh b/utils/style_check.sh index 37a09b9ac45..681a09160fe 100755 --- a/utils/style_check.sh +++ b/utils/style_check.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash # SPDX-License-Identifier: BSD-3-Clause -# Copyright 2016-2022, Intel Corporation +# Copyright 2016-2023, Intel Corporation # # utils/style_check.sh -- common style checking script # @@ -29,15 +29,15 @@ function usage() { } # -# require clang-format version 9.0 +# require clang-format version 14.0 # function check_clang_version() { set +e which ${clang_format_bin} &> /dev/null && ${clang_format_bin} --version |\ - grep "version 9\.0"\ + grep "version 14\.0"\ &> /dev/null if [ $? -ne 0 ]; then - echo "SKIP: requires clang-format version 9.0" + echo "SKIP: requires clang-format version==14.0" exit 0 fi set -e From 02703dd5e27c26022ac436859d6c18599b82d6fe Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Sat, 5 Aug 2023 21:58:08 -0400 Subject: [PATCH 2/3] common: install clang-format for cstyle purposes Signed-off-by: Jan Michalski --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4f8c0dcbafd..a5b6b8f9af6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,9 @@ jobs: fetch-depth: 50 - name: Install dependencies - run: sudo pip install flake8 + run: | + sudo pip install flake8 + sudo apt-get install clang-format-14 - name: Check licenses env: From 64c2156c70f25791baae37f9cb630f604f747326 Mon Sep 17 00:00:00 2001 From: Jan Michalski Date: Sun, 6 Aug 2023 19:01:16 -0400 Subject: [PATCH 3/3] common: introduce the CSTYLE_FAIL_IF_CLANG_FORMAT_MISSING flag Signed-off-by: Jan Michalski --- .github/workflows/main.yml | 1 + utils/style_check.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a5b6b8f9af6..415defebb5e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,6 +28,7 @@ jobs: - name: Check style env: + CSTYLE_FAIL_IF_CLANG_FORMAT_MISSING: 1 NDCTL_ENABLE: n # just to speed up the job run: make -j$(nproc) cstyle diff --git a/utils/style_check.sh b/utils/style_check.sh index 681a09160fe..34f5688fd7a 100755 --- a/utils/style_check.sh +++ b/utils/style_check.sh @@ -37,8 +37,14 @@ function check_clang_version() { grep "version 14\.0"\ &> /dev/null if [ $? -ne 0 ]; then - echo "SKIP: requires clang-format version==14.0" - exit 0 + MSG="requires clang-format version==14.0" + if [ "x$CSTYLE_FAIL_IF_CLANG_FORMAT_MISSING" == "x1" ]; then + echo "FAIL: $MSG" + exit 1 + else + echo "SKIP: $MSG" + exit 0 + fi fi set -e }