Skip to content

Add clang review workflow #6

Add clang review workflow

Add clang review workflow #6

name: Clang-tidy review
on:
pull_request:
jobs:
build:
name: Clang tidy review
runs-on: ubuntu-latest
container: zephyrprojectrtos/ci:v0.26.4
env:
CMAKE_PREFIX_PATH: /opt/toolchains
steps:
- name: Checkout the code
uses: actions/checkout@v2
with:
path: ncs/nrf
fetch-depth: 2
- name: Install deps
run: |
apt-get update
apt-get install -y jq clang-tidy ruby-full
# The docker image comes pre-initialized with west dependencies. We want to do west update ourselves to to be sure that we get the latest changes in all repos.
# The docker image is built nightly. So it may contain slightly out of date repos.
# Hence we remove the .west folder and do a re-init
- name: West init and update
run: |
rm -rf /workdir/.west/
west init -l ncs/nrf
cd ncs
west update --narrow -o=--depth=1
- name: Build native_posix tests (via sonarcloud build wrapper)
shell: bash
run: |
source ncs/zephyr/zephyr-env.sh
ncs/zephyr/scripts/twister -b -v -i -s applications.asset_tracker_v2.aws -T ncs/nrf/applications/asset_tracker_v2 -p native_posix
#- name: Use jq to combine compile_commands.json files
# run: |
# jq -s 'map(.[])' twister-out/**/compile_commands.json > compile_commands.json
- name: Analyze
shell: bash
working-directory: ncs/nrf/
run: |
git diff -U0 HEAD^ | clang-tidy-diff -p1 -path ../../twister-out/native_posix/applications.asset_tracker_v2.aws -export-fixes clang-tidy-result/fixes.yml
- name: Run clang-tidy-pr-comments action
uses: platisd/clang-tidy-pr-comments@master
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: ncs/nrf/clang-tidy-result/fixes.yml
# Optionally set the number of comments per review
# to avoid GitHub API timeouts for heavily loaded
# pull requests
suggestions_per_comment: 10