From 7d1d1749bc308cb28c4a630788bd9b290c8fa2ad Mon Sep 17 00:00:00 2001 From: Sergey Kuznetsov Date: Mon, 11 Dec 2023 15:11:30 +0000 Subject: [PATCH] Another fix of clang-tidy workflow (#1026) Another fix for clang-tidy nightly check for #884 --- .github/actions/clang_tidy/action.yml | 55 --------------------------- .github/workflows/clang-tidy.yml | 55 +++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 58 deletions(-) delete mode 100644 .github/actions/clang_tidy/action.yml diff --git a/.github/actions/clang_tidy/action.yml b/.github/actions/clang_tidy/action.yml deleted file mode 100644 index ecf44571..00000000 --- a/.github/actions/clang_tidy/action.yml +++ /dev/null @@ -1,55 +0,0 @@ -name: Run clang-tidy -description: Build clio in build directory -runs: - using: composite - steps: - - name: Get number of threads - uses: ./.github/actions/get_number_of_threads - id: number_of_threads - - - name: Run clang-tidy - continue-on-error: true - shell: bash - id: run_clang_tidy - run: | - run-clang-tidy-17 -p build -j ${{ steps.number_of_threads.outputs.threads_number }} -fix -quiet 1>output.txt - - - name: Print issues found - if: ${{ steps.run_clang_tidy.outcome != 'success' }} - shell: bash - run: | - sed -i '/error\||/!d' ./output.txt - cat output.txt - - - name: Create an issue - if: ${{ steps.run_clang_tidy.outcome != 'success' }} - id: create_issue - shell: bash - env: - GH_TOKEN: ${{ github.token }} - run: | - echo -e 'Clang-tidy found issues in the code:\n' > issue.md - echo -e "List of the issues found: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/job/${{ github.job }}" >> issue.md - gh issue create --assignee 'cindyyan317,godexsoft,kuznetsss' --label bug --title 'Clang-tidy found bugs in code🐛' --body-file ./issue.md > create_issue.log - created_issue=$(cat create_issue.log | sed 's|.*/||') - echo "created_issue=$created_issue" >> $GITHUB_OUTPUT - - - name: Create PR with fixes - if: ${{ steps.run_clang_tidy.outcome != 'success' }} - uses: peter-evans/create-pull-request@v5 - env: - GH_REPO: ${{ github.repository }} - GH_TOKEN: ${{ github.token }} - with: - commit-message: '[CI]: clang-tidy auto fixes' - branch: 'clang_tidy/autofix' - branch-suffix: timestamp - delete-branch: true - title: '[CI]: clang-tidy auto fixes' - body: 'Fixes #${{ steps.create_issue.outputs.created_issue }}. Please review and commit clang-tidy fixes' - reviewers: 'cindyyan317,godexsoft,kuznetsss' - - - name: Fail the job - if: ${{ steps.run_clang_tidy.outcome != 'success' }} - shell: bash - run: exit 1 diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml index 48c43925..67624fd7 100644 --- a/.github/workflows/clang-tidy.yml +++ b/.github/workflows/clang-tidy.yml @@ -7,8 +7,7 @@ on: branches: [develop] paths: - .clang_tidy - - '.github/**clang_tidy**' - - '.github/**clang-tidy**' + - .github/workflows/clang-tidy.yml jobs: clang_tidy: @@ -49,5 +48,55 @@ jobs: conan_cache_hit: ${{ steps.restore_cache.outputs.conan_cache_hit }} build_type: Release + - name: Get number of threads + uses: ./.github/actions/get_number_of_threads + id: number_of_threads + - name: Run clang-tidy - uses: ./.github/actions/clang_tidy + continue-on-error: true + shell: bash + id: run_clang_tidy + run: | + run-clang-tidy-17 -p build -j ${{ steps.number_of_threads.outputs.threads_number }} -fix -quiet 1>output.txt + + - name: Print issues found + if: ${{ steps.run_clang_tidy.outcome != 'success' }} + shell: bash + run: | + sed -i '/error\||/!d' ./output.txt + cat output.txt + rm output.txt + + - name: Create an issue + if: ${{ steps.run_clang_tidy.outcome != 'success' }} + id: create_issue + shell: bash + env: + GH_TOKEN: ${{ github.token }} + run: | + echo -e 'Clang-tidy found issues in the code:\n' > issue.md + echo -e "List of the issues found: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}/" >> issue.md + gh issue create --assignee 'cindyyan317,godexsoft,kuznetsss' --label bug --title 'Clang-tidy found bugs in code🐛' --body-file ./issue.md > create_issue.log + created_issue=$(cat create_issue.log | sed 's|.*/||') + echo "created_issue=$created_issue" >> $GITHUB_OUTPUT + rm create_issue.log issue.md + + - name: Create PR with fixes + if: ${{ steps.run_clang_tidy.outcome != 'success' }} + uses: peter-evans/create-pull-request@v5 + env: + GH_REPO: ${{ github.repository }} + GH_TOKEN: ${{ github.token }} + with: + commit-message: '[CI] clang-tidy auto fixes' + branch: 'clang_tidy/autofix' + branch-suffix: timestamp + delete-branch: true + title: '[CI] clang-tidy auto fixes' + body: 'Fixes #${{ steps.create_issue.outputs.created_issue }}. Please review and commit clang-tidy fixes' + reviewers: 'cindyyan317,godexsoft,kuznetsss' + + - name: Fail the job + if: ${{ steps.run_clang_tidy.outcome != 'success' }} + shell: bash + run: exit 1