|
| 1 | +name: Static analysis |
| 2 | + |
| 3 | +on: pull_request |
| 4 | + |
| 5 | +jobs: |
| 6 | + |
| 7 | + clang-tidy: |
| 8 | + runs-on: ubuntu-22.04 |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Install clang-tidy |
| 12 | + run: | |
| 13 | + sudo apt-get update |
| 14 | + sudo apt-get install -y clang-tidy bear |
| 15 | + - name: Fetch libtorrent |
| 16 | + run: | |
| 17 | + git clone https://github.com/rakshasa/libtorrent |
| 18 | + - name: Build libtorrent |
| 19 | + run: | |
| 20 | + cd libtorrent |
| 21 | + libtoolize |
| 22 | + aclocal -I scripts |
| 23 | + autoconf -i |
| 24 | + autoheader |
| 25 | + automake --add-missing |
| 26 | + ./configure |
| 27 | + make |
| 28 | + make install |
| 29 | + cd .. |
| 30 | + rm -rf libtorrent |
| 31 | + - uses: actions/checkout@v4 |
| 32 | + with: |
| 33 | + ref: ${{ github.event.pull_request.head.sha }} |
| 34 | + fetch-depth: 0 |
| 35 | + - name: Fetch base branch |
| 36 | + run: | |
| 37 | + git remote add upstream "https://github.com/${{ github.event.pull_request.base.repo.full_name }}" |
| 38 | + git fetch --no-tags --no-recurse-submodules upstream "${{ github.event.pull_request.base.ref }}" |
| 39 | + - name: Configure Project |
| 40 | + run: | |
| 41 | + libtoolize |
| 42 | + aclocal -I scripts |
| 43 | + autoconf -i |
| 44 | + autoheader |
| 45 | + automake --add-missing |
| 46 | + ./configure |
| 47 | + - name: Prepare compile_commands.json |
| 48 | + run: | |
| 49 | + bear -- make |
| 50 | + - name: Create results directory |
| 51 | + run: | |
| 52 | + mkdir clang-tidy-result |
| 53 | + - name: Analyze |
| 54 | + run: | |
| 55 | + git diff -U0 "$(git merge-base HEAD "upstream/${{ github.event.pull_request.base.ref }}")" | clang-tidy-diff -p1 -path build -export-fixes clang-tidy-result/fixes.yml |
| 56 | + - name: Save PR metadata |
| 57 | + run: | |
| 58 | + echo "${{ github.event.number }}" > clang-tidy-result/pr-id.txt |
| 59 | + echo "${{ github.event.pull_request.head.repo.full_name }}" > clang-tidy-result/pr-head-repo.txt |
| 60 | + echo "${{ github.event.pull_request.head.sha }}" > clang-tidy-result/pr-head-sha.txt |
| 61 | + - uses: actions/upload-artifact@v4 |
| 62 | + with: |
| 63 | + name: clang-tidy-result |
| 64 | + path: clang-tidy-result/ |
| 65 | + - name: Run clang-tidy-pr-comments action |
| 66 | + uses: platisd/clang-tidy-pr-comments@v1 |
| 67 | + with: |
| 68 | + # The GitHub token (or a personal access token) |
| 69 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + # The path to the clang-tidy fixes generated previously |
| 71 | + clang_tidy_fixes: clang-tidy-result/fixes.yml |
| 72 | + # Optionally set to true if you want the Action to request |
| 73 | + # changes in case warnings are found |
| 74 | + request_changes: true |
| 75 | + # Optionally set the number of comments per review |
| 76 | + # to avoid GitHub API timeouts for heavily loaded |
| 77 | + # pull requests |
| 78 | + suggestions_per_comment: 10 |
0 commit comments