From 190c6509321059b0b20340919c9dad109de5b814 Mon Sep 17 00:00:00 2001 From: Xianpeng Shen Date: Fri, 24 Jul 2026 15:47:42 +0300 Subject: [PATCH 1/2] test: add mis-formatted source + auto-fix e2e workflow Adds a deliberately mis-formatted C++ file and a workflow that runs cpp-linter-action (test/auto-fix-e2e branch, which installs the unreleased cpp-linter --fix) with auto-fix enabled, to verify the auto-fix commit is pushed back to the PR branch. --- .github/workflows/test-auto-fix.yml | 31 +++++++++++++++++++++++++++++ src/auto_fix_demo.cpp | 2 ++ 2 files changed, 33 insertions(+) create mode 100644 .github/workflows/test-auto-fix.yml create mode 100644 src/auto_fix_demo.cpp diff --git a/.github/workflows/test-auto-fix.yml b/.github/workflows/test-auto-fix.yml new file mode 100644 index 0000000..fc3198a --- /dev/null +++ b/.github/workflows/test-auto-fix.yml @@ -0,0 +1,31 @@ +name: e2e auto-fix test + +on: + pull_request: + branches: [master] + +permissions: + contents: write + pull-requests: read + +jobs: + auto-fix: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v7 + + - uses: cpp-linter/cpp-linter-action@test/auto-fix-e2e + id: linter + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + style: file + tidy-checks: '-*' # disable clang-tidy; test clang-format auto-fix only + files-changed-only: false + version: '18' + auto-fix: true + verbosity: debug + + - name: Report + run: | + echo "clang-format-checks-failed: ${{ steps.linter.outputs.clang-format-checks-failed }}" diff --git a/src/auto_fix_demo.cpp b/src/auto_fix_demo.cpp new file mode 100644 index 0000000..81d244c --- /dev/null +++ b/src/auto_fix_demo.cpp @@ -0,0 +1,2 @@ +#include +int main( ){int x=0 ;for(int i=0;i<10;i++){x +=i;}printf("%d",x);return 0 ;} From 0dc9f90db92c5315cfdb94074cfc5de69c9c31b4 Mon Sep 17 00:00:00 2001 From: shenxianpeng <3353385+shenxianpeng@users.noreply.github.com> Date: Fri, 24 Jul 2026 12:48:29 +0000 Subject: [PATCH 2/2] style: apply styling format fix --- src/auto_fix_demo.cpp | 10 +++++++++- src/demo.cpp | 2 +- src/demo.hpp | 32 ++++---------------------------- 3 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/auto_fix_demo.cpp b/src/auto_fix_demo.cpp index 81d244c..644fe2d 100644 --- a/src/auto_fix_demo.cpp +++ b/src/auto_fix_demo.cpp @@ -1,2 +1,10 @@ #include -int main( ){int x=0 ;for(int i=0;i<10;i++){x +=i;}printf("%d",x);return 0 ;} +int main() +{ + int x = 0; + for (int i = 0; i < 10; i++) { + x += i; + } + printf("%d", x); + return 0; +} diff --git a/src/demo.cpp b/src/demo.cpp index 0c1db60..8bbf972 100644 --- a/src/demo.cpp +++ b/src/demo.cpp @@ -1,7 +1,7 @@ /** This is a very ugly test code (doomed to fail linting) */ #include "demo.hpp" -#include #include +#include // using size_t from cstddef size_t dummyFunc(size_t i) { return i; } diff --git a/src/demo.hpp b/src/demo.hpp index 2695731..5e29a02 100644 --- a/src/demo.hpp +++ b/src/demo.hpp @@ -1,41 +1,17 @@ #pragma once - - class Dummy { char* useless; int numb; - public: - void *not_usefull(char *str){ +public: + void* not_usefull(char* str) + { useless = str; return 0; } }; - - - - - - - - - - - - - - - - - - - - - -struct LongDiff -{ +struct LongDiff { long diff; - };