CI: Add Clang tidy #20
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: Run clang-tidy | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
parameters: | ||
Check failure on line 9 in .github/workflows/clang-tidy.yml GitHub Actions / Run clang-tidyInvalid workflow file
|
||
- name: modules | ||
type: object | ||
default: | ||
- name: 'esp_tinyusb' | ||
path: 'device/esp_tinyusb/test_app' | ||
- name: 'hid' | ||
path: 'host/class/hid/usb_host_hid/test_app' | ||
jobs: | ||
build: | ||
name: Run clang-tidy | ||
runs-on: ubuntu-20.04 | ||
container: espressif/idf:latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: 'true' | ||
- name: Install libtinfo (esp-clang dependency) | ||
run: | | ||
export DEBIAN_FRONTEND=noninteractive | ||
apt update && apt-get install -y libtinfo5 | ||
- name: Install esp-clang | ||
run: | | ||
${IDF_PATH}/tools/idf_tools.py --non-interactive install esp-clang | ||
- name: Install clang-tidy-sarif | ||
run: | | ||
curl -sSL https://github.com/psastras/sarif-rs/releases/download/clang-tidy-sarif-v0.3.3/clang-tidy-sarif-x86_64-unknown-linux-gnu -o clang-tidy-sarif | ||
chmod +x clang-tidy-sarif | ||
- name: Install pyclang | ||
run: | | ||
. ${IDF_PATH}/export.sh | ||
pip install pyclang~=0.2.0 | ||
- name: Run code analysis | ||
shell: bash | ||
env: | ||
IDF_TOOLCHAIN: clang | ||
IDF_TARGET: esp32s3 | ||
run: | | ||
. ${IDF_PATH}/export.sh | ||
for module in ${{ parameters.modules}}; do | ||
echo "${{ module.path }}" | ||
echo "${{ module.name }}" | ||
idf.py clang-check --project-dir ${{ module.path }} --run-clang-tidy-py run-clang-tidy | ||
mv ${{ module.path }}/warnings.txt warnings_${{ module.name }}.txt | ||
done | ||
- name: Convert clang-tidy results into SARIF output | ||
run: | | ||
for module in ${{ parameters.modules }}; do | ||
./clang-tidy-sarif -o results_${{ module.name }}.sarif.raw warnings_${{ module.name }}.txt | ||
python3 $GITHUB_WORKSPACE/.github/filter_sarif.py -o results_${{ module.name }}.sarif --include-prefix ${GITHUB_WORKSPACE}/ results_${{ module.name }}.sarif.raw | ||
done | ||
# - name: Upload artifacts | ||
# - ${{ each module in parameters.modules }}: | ||
# uses: actions/upload-artifact@v2 | ||
# with: | ||
# path: | | ||
# results_${{ module.name }}.txt | ||
# results_${{ module.name }}.sarif | ||
# results_${{ module.name }}.sarif.raw | ||
# - name: Upload SARIF files | ||
# - ${{ each module in parameters.modules }}: | ||
# uses: github/codeql-action/upload-sarif@v2 | ||
# with: | ||
# sarif_file: results_${{ module.name }}.sarif | ||
# category: clang-tidy-${{ module.name }} | ||
# run: | | ||
# . ${IDF_PATH}/export.sh | ||
# idf.py clang-check --project-dir device/esp_tinyusb/test_app --run-clang-tidy-py run-clang-tidy | ||
# mv device/esp_tinyusb/test_app/warnings.txt warnings_device.txt | ||
# | ||
# idf.py clang-check --project-dir host/class/hid/usb_host_hid/test_app --run-clang-tidy-py run-clang-tidy | ||
# mv host/class/hid/usb_host_hid/test_app/warnings.txt warnings_host.txt | ||
# - name: Convert clang-tidy results into SARIF output | ||
# run: | | ||
# export PATH=$PWD:$PATH | ||
# ./clang-tidy-sarif -o results_device.sarif.raw warnings_device.txt | ||
# python3 $GITHUB_WORKSPACE/.github/filter_sarif.py -o results_device.sarif --include-prefix ${GITHUB_WORKSPACE}/ results_device.sarif.raw | ||
# | ||
# ./clang-tidy-sarif -o results_host.sarif.raw warnings_host.txt | ||
# python3 $GITHUB_WORKSPACE/.github/filter_sarif.py -o results_host.sarif --include-prefix ${GITHUB_WORKSPACE}/ results_host.sarif.raw | ||
# - uses: actions/upload-artifact@v2 | ||
# with: | ||
# path: | | ||
# warnings_device.txt | ||
# warnings_host.txt | ||
# results_device.sarif | ||
# results_host.sarif | ||
# results_device.sarif.raw | ||
# results_host.sarif.raw | ||
# - name: Upload SARIF device file | ||
# uses: github/codeql-action/upload-sarif@v2 | ||
# with: | ||
# sarif_file: results_device.sarif | ||
# category: clang-tidy-device | ||
# | ||
# - name: Upload SARIF host file | ||
# uses: github/codeql-action/upload-sarif@v2 | ||
# with: | ||
# sarif_file: results_host.sarif | ||
# category: clang-tidy-host | ||