Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
43 changes: 43 additions & 0 deletions testing/pre-commit-config-style.yaml
Original file line number Diff line number Diff line change
@@ -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]
63 changes: 37 additions & 26 deletions testing/run.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,43 +1,54 @@
#!/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

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

configs=(
"pre-commit-config.yaml"
"pre-commit-config-version.yaml"
"pre-commit-config-verbose.yaml"
"pre-commit-config-style.yaml"
)

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 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
Loading