From 09ad6c16632999747707134e613a509d508a2949 Mon Sep 17 00:00:00 2001 From: Francesco Andreuzzi Date: Fri, 4 Jul 2025 14:51:48 +0100 Subject: [PATCH] Auto-generated clang-tidy review comments (#1360) --- .github/workflows/code-check.yml | 39 ++++++++++++++++++++++++++++++++ Makefile | 8 ++++--- docker/code-check.Dockerfile | 6 ++++- 3 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/code-check.yml diff --git a/.github/workflows/code-check.yml b/.github/workflows/code-check.yml new file mode 100644 index 00000000..319655e6 --- /dev/null +++ b/.github/workflows/code-check.yml @@ -0,0 +1,39 @@ +name: code-check + +on: +- pull_request + +jobs: + cpp-lint: + runs-on: ubuntu-latest + container: + image: "public.ecr.aws/async-profiler/asprof-code-check:latest" + permissions: + pull-requests: write + contents: write + steps: + - uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Mark repo as safe for Git + run: git config --global --add safe.directory $GITHUB_WORKSPACE + - name: Fetch base branch + run: | + git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}" + git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}" + - name: Run clang-tidy + run: | + set pipefail + make cpp-lint-diff \ + DIFF_BASE="$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" \ + CLANG_TIDY_ARGS_EXTRA="-export-fixes clang-tidy-fixes.yml" + shell: bash + - name: Run clang-tidy-pr-comments action + uses: platisd/clang-tidy-pr-comments@v1 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + clang_tidy_fixes: clang-tidy-fixes.yml + python_path: python + auto_resolve_conversations: true + suggestions_per_comment: 100 diff --git a/Makefile b/Makefile index 38ea9e0b..af6f6b94 100644 --- a/Makefile +++ b/Makefile @@ -276,12 +276,14 @@ build/$(TEST_JAR): $(TEST_SOURCES) build/$(CONVERTER_JAR) $(JAR) cf $@ -C build/test/classes . LINT_SOURCES=`ls -1 src/*.cpp src/*/*.cpp | grep -v rustDemangle.cpp` +CLANG_TIDY_ARGS_EXTRA= cpp-lint: - clang-tidy $(LINT_SOURCES) -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS) + clang-tidy $(LINT_SOURCES) $(CLANG_TIDY_ARGS_EXTRA) -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS) +DIFF_BASE= cpp-lint-diff: - git diff -U0 -- '**/*.cpp' '**/*.h' ':!**/rustDemangle.cpp' | \ - clang-tidy-diff.py -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS) + git diff -U0 $(DIFF_BASE) -- '**/*.cpp' '**/*.h' ':!**/rustDemangle.cpp' | \ + clang-tidy-diff.py -p1 $(CLANG_TIDY_ARGS_EXTRA) -- -x c++ $(CXXFLAGS) $(INCLUDES) $(DEFS) $(LIBS) check-md: prettier -c README.md "docs/**/*.md" diff --git a/docker/code-check.Dockerfile b/docker/code-check.Dockerfile index b6e9db03..5cb6edad 100644 --- a/docker/code-check.Dockerfile +++ b/docker/code-check.Dockerfile @@ -2,5 +2,9 @@ FROM public.ecr.aws/docker/library/amazoncorretto:11-alpine-jdk ADD --chmod=555 https://raw.githubusercontent.com/llvm/llvm-project/67be4fe3d5fd986a3149de3806bcf2c92320015e/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py /usr/bin/ -RUN apk add --no-cache clang-extra-tools linux-headers make python3 git +RUN apk add --no-cache clang-extra-tools linux-headers make python3 git py3-pip bash +# Needed by clang-tidy-diff.py to merge multiple results in one file. +# '--break-system-packages' is needed because Alpine does not like other package managers than 'apk' ('pip' in this case) to install +# software globally, but it's safe to do in this case. +RUN pip install --break-system-packages pyyaml ENV CPLUS_INCLUDE_PATH="/usr/lib/jvm/java-11-amazon-corretto/include:/usr/lib/jvm/java-11-amazon-corretto/include/linux"