feat: Added clang tidy to PR #4
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Static analysis | |
on: pull_request | |
jobs: | |
clang-tidy: | |
runs-on: ubuntu-22.04 | |
permissions: | |
pull-requests: write | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 | |
- 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: Install clang-tidy | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y clang-tidy | |
- name: Prepare compile_commands.json | |
run: | | |
cmake -B build -DCMAKE_EXPORT_COMPILE_COMMANDS=ON | |
- name: Create results directory | |
run: | | |
mkdir clang-tidy-result | |
- name: Analyze | |
run: | | |
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 | |
- name: Run clang-tidy-pr-comments action | |
uses: platisd/clang-tidy-pr-comments@v1 | |
with: | |
# The GitHub token (or a personal access token) | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
# The path to the clang-tidy fixes generated previously | |
clang_tidy_fixes: clang-tidy-result/fixes.yml | |
# Optionally set to true if you want the Action to request | |
# changes in case warnings are found | |
request_changes: true |