diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..4603b81 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,25 @@ +HeaderFilterRegex: '' +Checks: ' + bugprone-*, + concurrency-*, + cppcoreguidelines-*, + modernize-*, + portability-*, + readability-*, + -bugprone-easily-swappable-parameters, + -bugprone-macro-parentheses, + -bugprone-narrowing-conversions, + -bugprone-unchecked-optional-access, + -modernize-use-trailing-return-type, + -modernize-avoid-c-arrays, + -modernize-use-nodiscard, + -readability-function-cognitive-complexity, + -readability-identifier-length, + -readability-magic-numbers, + -readability-math-missing-parentheses, + -cppcoreguidelines-avoid-c-arrays, + -cppcoreguidelines-avoid-magic-numbers, + -cppcoreguidelines-narrowing-conversions, + -cppcoreguidelines-owning-memory +' +FormatStyle: none diff --git a/.github/workflows/linux-eic-shell.yml b/.github/workflows/linux-eic-shell.yml index 1a0f3be..17d41e4 100644 --- a/.github/workflows/linux-eic-shell.yml +++ b/.github/workflows/linux-eic-shell.yml @@ -12,6 +12,9 @@ concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true +env: + clang-tidy-CXX: clang++ + jobs: build: @@ -20,8 +23,9 @@ jobs: fail-fast: false matrix: include: - - { cc: gcc, cxx: g++ } - - { cc: clang, cxx: clang++ } + - { cc: gcc, cxx: g++, build_type: Release } + - { cc: clang, cxx: clang++, build_type: Release } + - { cc: clang, cxx: clang++, build_type: Debug } steps: - uses: actions/checkout@v3 - uses: cvmfs-contrib/github-action-cvmfs@v5 @@ -29,12 +33,70 @@ jobs: with: platform-release: "eic_xl:nightly" run: | - CC=${{matrix.cc}} CXX=${{matrix.cxx}} cmake -S . -B build -DDELPHES=ON -DEVALUATION=OFF -DCMAKE_INSTALL_PREFIX=install + CC=${{matrix.cc}} CXX=${{matrix.cxx}} cmake -S . -B build -DDELPHES=ON -DEVALUATION=OFF -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=${{matrix.build_type}} cmake --build build cmake --install build + - name: Compress build directory + if: matrix.cxx == env.clang-tidy-CXX && matrix.build_type == 'Debug' + run: tar -caf build.tar.zst build/ + - name: Upload build directory + if: matrix.cxx == env.clang-tidy-CXX && matrix.build_type == 'Debug' + uses: actions/upload-artifact@v4 + with: + name: build_${{matrix.cc}}_${{matrix.build_type}} + path: build.tar.zst + retention-days: 1 + if-no-files-found: error - uses: actions/upload-artifact@v4 with: - name: install_${{matrix.cc}} + name: install_${{matrix.cc}}_${{matrix.build_type}} path: install retention-days: 1 if-no-files-found: error + + clang-tidy: + runs-on: ubuntu-latest + needs: build + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: cvmfs-contrib/github-action-cvmfs@v5 + - name: Download build artifact + uses: actions/download-artifact@v4 + with: + name: build_clang_Debug + path: . + - name: Uncompress build artifact + run: tar -xaf build.tar.zst + - name: Run clang-tidy on changed files + uses: eic/run-cvmfs-osg-eic-shell@main + if: ${{ github.event_name == 'pull_request' }} + with: + platform-release: "eic_xl:nightly" + run: | + git diff ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | clang-tidy-diff -p 1 -path build -quiet -export-fixes clang_tidy_fixes.yaml + - name: Run clang-tidy on all files + uses: eic/run-cvmfs-osg-eic-shell@main + if: ${{ github.event_name == 'push' }} + with: + platform-release: "eic_xl:nightly" + run: | + run-clang-tidy -p build -export-fixes clang_tidy_fixes.yaml + - name: Upload clang-tidy fixes as artifact + uses: actions/upload-artifact@v4 + with: + name: clang-tidy-fixes.yaml + path: clang_tidy_fixes.yaml + if-no-files-found: ignore + - name: Suggest clang-tidy fixes as PR comments + uses: platisd/clang-tidy-pr-comments@v1.8.0 + if: ${{ github.event_name == 'pull_request' }} + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + clang_tidy_fixes: clang_tidy_fixes.yaml + request_changes: false + suggestions_per_comment: 10