diff --git a/.github/actions/clang-tidy-native/action.yml b/.github/actions/clang-tidy-native/action.yml new file mode 100644 index 000000000..19e2d36e7 --- /dev/null +++ b/.github/actions/clang-tidy-native/action.yml @@ -0,0 +1,88 @@ +name: 'Native Clang-Tidy Analysis' +description: 'Run clang-tidy analysis without Docker' +inputs: + build_dir: + description: 'Build directory for CMake' + required: false + default: 'build' + exclude: + description: 'Directories to exclude from analysis' + required: false + default: '3rdparty' + clang_tidy_version: + description: 'Clang-tidy version to use' + required: false + default: '20' +outputs: + total_comments: + description: 'Total number of clang-tidy issues found' + value: ${{ steps.analyze.outputs.total_comments }} +runs: + using: 'composite' + steps: + - name: Verify clang-tidy installation + shell: bash + run: | + clang-tidy-${{ inputs.clang_tidy_version }} --version + + - name: Get changed files + id: changed-files + shell: bash + run: | + git config --global --add safe.directory $GITHUB_WORKSPACE + git fetch origin ${{ github.event.pull_request.base.ref }} + CHANGED_FILES=$(git diff --name-only \ + origin/${{ github.event.pull_request.base.ref }}...HEAD \ + -- '*.cpp' '*.hpp' '*.c' '*.h' | grep -v '^${{ inputs.exclude }}/' || true) + echo "changed_files<> $GITHUB_OUTPUT + echo "$CHANGED_FILES" >> $GITHUB_OUTPUT + echo "EOF" >> $GITHUB_OUTPUT + + if [ -z "$CHANGED_FILES" ]; then + echo "has_changes=false" >> $GITHUB_OUTPUT + else + echo "has_changes=true" >> $GITHUB_OUTPUT + fi + + - name: Run clang-tidy analysis + id: analyze + shell: bash + if: steps.changed-files.outputs.has_changes == 'true' + run: | + COMMENTS_FILE=$(mktemp) + TOTAL_ISSUES=0 + + while IFS= read -r file; do + if [ -n "$file" ] && [ -f "$file" ]; then + echo "Analyzing $file..." + if clang-tidy-${{ inputs.clang_tidy_version }} "$file" \ + -p ${{ inputs.build_dir }} --format-style=file 2>&1 | \ + tee -a "$COMMENTS_FILE"; then + ISSUES=$(grep -c "warning:\|error:" "$COMMENTS_FILE" || echo "0") + TOTAL_ISSUES=$((TOTAL_ISSUES + ISSUES)) + else + echo "::error::Failed to analyze $file" + TOTAL_ISSUES=$((TOTAL_ISSUES + 1)) + fi + fi + done <<< "${{ steps.changed-files.outputs.changed_files }}" + + echo "total_comments=$TOTAL_ISSUES" >> $GITHUB_OUTPUT + + if [ -f "$COMMENTS_FILE" ] && [ -s "$COMMENTS_FILE" ]; then + echo "::group::Clang-tidy Analysis Results" + cat "$COMMENTS_FILE" + echo "::endgroup::" + fi + + if [ "$TOTAL_ISSUES" -gt 0 ]; then + echo "::error::Found $TOTAL_ISSUES clang-tidy issues" + else + echo "No clang-tidy issues found" + fi + + - name: Set output for no changes + shell: bash + if: steps.changed-files.outputs.has_changes == 'false' + run: | + echo "total_comments=0" >> $GITHUB_OUTPUT diff --git a/.github/workflows/static-analysis-pr.yml b/.github/workflows/static-analysis-pr.yml index 3b0c271bd..2ce6031a9 100644 --- a/.github/workflows/static-analysis-pr.yml +++ b/.github/workflows/static-analysis-pr.yml @@ -21,31 +21,46 @@ concurrency: jobs: clang-tidy: runs-on: ubuntu-24.04 + container: + image: ghcr.io/learning-process/ppc-ubuntu:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ runner.os }}-clang - - uses: ZedThree/clang-tidy-review@v0.21.0 + create-symlink: true + max-size: 1G + + - name: CMake configure + run: > + cmake -S . -B build -G Ninja + -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + env: + CC: clang-20 + CXX: clang++-20 + + - name: Build project + run: | + cmake --build build --parallel + env: + CC: clang-20 + CXX: clang++-20 + + - name: Run clang-tidy + uses: ./.github/actions/clang-tidy-native id: review with: - build_dir: build - apt_packages: openmpi-bin,openmpi-common,libopenmpi-dev,ninja-build,libomp-19-dev,valgrind - cmake_command: > - cmake -S . -B build -G Ninja - -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache - -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON exclude: 3rdparty - clang_tidy_checks: "" - split_workflow: true - clang_tidy_version: "19" - lgtm_comment_body: "" - env: - CC: clang-19 - CXX: clang++-19 + clang_tidy_version: "20" - if: steps.review.outputs.total_comments > 0 run: | echo "clang-tidy run has failed. See previous 'Run clang-tidy' stage logs" @@ -54,28 +69,46 @@ jobs: needs: - clang-tidy runs-on: ubuntu-24.04 + container: + image: ghcr.io/learning-process/ppc-ubuntu:latest + credentials: + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v4 with: submodules: recursive + fetch-depth: 0 + - name: ccache uses: hendrikmuhs/ccache-action@v1.2 with: key: ${{ runner.os }}-gcc - - uses: ZedThree/clang-tidy-review@v0.21.0 + create-symlink: true + max-size: 1G + + - name: CMake configure + run: > + cmake -S . -B build -G Ninja + -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON + env: + CC: gcc-14 + CXX: g++-14 + + - name: Build project + run: | + cmake --build build --parallel + env: + CC: gcc-14 + CXX: g++-14 + + - name: Run clang-tidy + uses: ./.github/actions/clang-tidy-native id: review with: - build_dir: build - apt_packages: openmpi-bin,openmpi-common,libopenmpi-dev,ninja-build,libomp-19-dev,valgrind - cmake_command: > - cmake -S . -B build -G Ninja - -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache - -D CMAKE_BUILD_TYPE=RELEASE -DCMAKE_EXPORT_COMPILE_COMMANDS=ON exclude: 3rdparty - clang_tidy_checks: "" - split_workflow: true - clang_tidy_version: "19" - lgtm_comment_body: "" + clang_tidy_version: "20" - if: steps.review.outputs.total_comments > 0 run: | echo "clang-tidy run has failed. See previous 'Run clang-tidy' stage logs" diff --git a/modules/task/include/task.hpp b/modules/task/include/task.hpp index 7d1042530..9bb718119 100644 --- a/modules/task/include/task.hpp +++ b/modules/task/include/task.hpp @@ -2,14 +2,11 @@ #include -#include #include #include #include #include -#include #include -#include #include #include #include @@ -18,7 +15,6 @@ #include #include #include -#include namespace ppc::task { @@ -259,8 +255,8 @@ class Task { virtual bool PostProcessingImpl() = 0; private: - InType input_; - OutType output_; + InType input_{}; + OutType output_{}; StateOfTesting state_of_testing_ = kFunc; TypeOfTask type_of_task_ = kUnknown; StatusOfTask status_of_task_ = kEnabled;