From 56f30cd482e5a4355a15c4066f2e4ebce50e0bdc Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 22:57:08 +0200 Subject: [PATCH 1/8] Add more tests --- .pre-commit-config.yaml | 2 +- testing/pre-commit-config-style.yaml | 43 ++++++++++++++++++++++++++++ testing/run.sh | 40 ++++++++++++-------------- 3 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 testing/pre-commit-config-style.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4562e09..708d486 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -10,7 +10,7 @@ repos: - id: check-toml - id: requirements-txt-fixer - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.13.1 + rev: v0.14.2 hooks: # Run the linter. - id: ruff-check diff --git a/testing/pre-commit-config-style.yaml b/testing/pre-commit-config-style.yaml new file mode 100644 index 0000000..568e275 --- /dev/null +++ b/testing/pre-commit-config-style.yaml @@ -0,0 +1,43 @@ +repos: + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=LLVM, --version=16] # to load .clang-format + - id: clang-tidy + args: [--checks=.clang-tidy, --version=16] # path/to/.clang-tidy + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=Google, --version=17] + - id: clang-tidy + args: [--checks=.clang-tidy, --version=17] + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=Microsoft, --version=18] + - id: clang-tidy + args: [--checks=.clang-tidy, --version=18] + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=WebKit, --version=19] + - id: clang-tidy + args: [--checks=.clang-tidy, --version=19] + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=Mozilla, --version=20] + - id: clang-tidy + args: [--checks=.clang-tidy, --version=20] + - repo: . + rev: HEAD + hooks: + - id: clang-format + args: [--style=Chromium, --version=21] + - id: clang-tidy + args: [--checks=.clang-tidy, --version=21] diff --git a/testing/run.sh b/testing/run.sh index b176b06..5d88ca2 100644 --- a/testing/run.sh +++ b/testing/run.sh @@ -1,35 +1,31 @@ #!/bin/bash -echo "===========================" -echo "Test pre-commit-config.yaml" -echo "===========================" -pre-commit clean -pre-commit run -c testing/pre-commit-config.yaml --files testing/main.c | tee -a result.txt || true -git restore testing/main.c -echo "====================================" -echo "Test pre-commit-config-version.yaml" -echo "====================================" -pre-commit clean -pre-commit run -c testing/pre-commit-config-version.yaml --files testing/main.c | tee -a result.txt || true -git restore testing/main.c +configs=( + "pre-commit-config.yaml" + "pre-commit-config-version.yaml" + "pre-commit-config-verbose.yaml" + "pre-commit-config-style.yaml" +) -echo "====================================" -echo "Test pre-commit-config-verbose.yaml" -echo "====================================" -pre-commit clean -pre-commit run -c testing/pre-commit-config-verbose.yaml --files testing/main.c | tee -a result.txt || true -git restore testing/main.c +for config in "${configs[@]}"; do + echo "====================================" + echo "Test $config" + echo "====================================" + pre-commit clean + pre-commit run -c testing/$config --files testing/main.c | tee -a result.txt || true + git restore testing/main.c +done echo "==================================================================================" -echo "print result.txt" +echo "Print result.txt" cat result.txt echo "==================================================================================" -failed_cases=`grep -c "Failed" result.txt` +failed_cases=$(grep -c "Failed" result.txt) -echo $failed_cases " cases failed." +echo "$failed_cases cases failed." -if [ $failed_cases -eq 10 ]; then +if [[ $failed_cases -eq 10 ]]; then echo "==============================" echo "Test cpp-linter-hooks success." echo "==============================" From 7062bd59cb554e5b3ef21f1572c5ffede09acc29 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:03:44 +0200 Subject: [PATCH 2/8] Update shebang --- testing/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/run.sh b/testing/run.sh index 5d88ca2..45ad073 100644 --- a/testing/run.sh +++ b/testing/run.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash configs=( "pre-commit-config.yaml" From 0ac1ea1193eddbbb635b9f8159c59d0f394efd9f Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:06:54 +0200 Subject: [PATCH 3/8] chmod +x testing/run.sh --- testing/run.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 testing/run.sh diff --git a/testing/run.sh b/testing/run.sh old mode 100644 new mode 100755 From 6a5de1fb2dd00cc321a4c41ba26f53fe84d3bef4 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:10:19 +0200 Subject: [PATCH 4/8] update run.sh --- testing/run.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/testing/run.sh b/testing/run.sh index 45ad073..baf9768 100755 --- a/testing/run.sh +++ b/testing/run.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/bin/bash configs=( "pre-commit-config.yaml" @@ -25,7 +25,7 @@ failed_cases=$(grep -c "Failed" result.txt) echo "$failed_cases cases failed." -if [[ $failed_cases -eq 10 ]]; then +if [ $failed_cases -eq 10 ]; then echo "==============================" echo "Test cpp-linter-hooks success." echo "==============================" From a843ad25dfa781499fe47fc5913e8606ff55c524 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:14:11 +0200 Subject: [PATCH 5/8] update run.sh --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 362b1d8..c9c8d5a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -40,4 +40,4 @@ jobs: fail_ci_if_error: true # optional (default = false) verbose: true # optional (default = false) - name: Test cpp-linter-hooks - run: sh testing/run.sh + run: bash testing/run.sh From a9bb718adb1117052bf150132eb1c07969d51e14 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:19:29 +0200 Subject: [PATCH 6/8] update run.sh --- testing/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/run.sh b/testing/run.sh index baf9768..39b7ae9 100755 --- a/testing/run.sh +++ b/testing/run.sh @@ -25,7 +25,7 @@ failed_cases=$(grep -c "Failed" result.txt) echo "$failed_cases cases failed." -if [ $failed_cases -eq 10 ]; then +if [ $failed_cases -eq 21 ]; then echo "==============================" echo "Test cpp-linter-hooks success." echo "==============================" From 4752feaa5b54a26b751ca9e8ecf7af1338573f43 Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:21:43 +0200 Subject: [PATCH 7/8] update run.sh --- testing/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testing/run.sh b/testing/run.sh index 39b7ae9..fa4928a 100755 --- a/testing/run.sh +++ b/testing/run.sh @@ -25,7 +25,7 @@ failed_cases=$(grep -c "Failed" result.txt) echo "$failed_cases cases failed." -if [ $failed_cases -eq 21 ]; then +if [[ $failed_cases -eq 21 ]]; then echo "==============================" echo "Test cpp-linter-hooks success." echo "==============================" From bfc3e61b5d5ce5c4f7ceb7034b5ebaedfb1f315d Mon Sep 17 00:00:00 2001 From: shenxianpeng Date: Mon, 27 Oct 2025 23:23:53 +0200 Subject: [PATCH 8/8] add result to github summary --- testing/run.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/testing/run.sh b/testing/run.sh index fa4928a..549c524 100755 --- a/testing/run.sh +++ b/testing/run.sh @@ -29,11 +29,26 @@ if [[ $failed_cases -eq 21 ]]; then echo "==============================" echo "Test cpp-linter-hooks success." echo "==============================" + result="success" rm result.txt - exit 0 + exit_code=0 else echo "=============================" echo "Test cpp-linter-hooks failed." echo "=============================" - exit 1 + result="failure" + exit_code=1 fi + +# Add result to GitHub summary if running in GitHub Actions +if [[ -n "$GITHUB_STEP_SUMMARY" ]]; then + { + echo "### cpp-linter-hooks Test Result" + echo "" + echo "**Result:** $result" + echo "" + echo "**Failed cases:** $failed_cases" + } >> "$GITHUB_STEP_SUMMARY" +fi + +exit $exit_code