Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci(common): Add clang tidy check to esp-protocols #545

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Run clang-tidy

on:
pull_request:
push:
branches:
- master

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
curl -sSL https://raw.githubusercontent.com/espressif/idf-extra-components/master/.github/filter_sarif.py -o filter_sarif.py
- 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: esp32
working-directory: test_app
run: |
. ${IDF_PATH}/export.sh
idf.py clang-check --include-paths $GITHUB_WORKSPACE --exclude-paths $PWD --run-clang-tidy-py run-clang-tidy
cp warnings.txt ../
- name: Convert clang-tidy results into SARIF output
run: |
export PATH=$PWD:$PATH
./clang-tidy-sarif -o results.sarif.raw warnings.txt
python3 filter_sarif.py -o results.sarif --include-prefix ${GITHUB_WORKSPACE}/ results.sarif.raw
- uses: actions/upload-artifact@v2
with:
path: |
warnings.txt
results.sarif
results.sarif.raw
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@v2
with:
sarif_file: results.sarif
category: clang-tidy
30 changes: 30 additions & 0 deletions test_app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# The following lines of boilerplate have to be in your project's
# CMakeLists in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/version.cmake)

# Add newly added components to one of these lines:
set(EXTRA_COMPONENT_DIRS
../components/eppp_link
../components/esp_modem
../components/esp_mqtt_cxx
../components/esp_websocket_client
../components/console_cmd_ifconfig
../components/console_cmd_ping
../components/console_cmd_wifi
../components/console_simple_init
../components/mbedtls_cxx
../components/mdns)


# !This section should NOT be touched when adding new component!
# Take all components in EXTRA_COMPONENT_DIRS, strip leading '../' and add it to TEST_COMPONENTS
# The build system will build and link unit tests, if the component contains 'test' subdirectory
set(TEST_COMPONENTS "" CACHE STRING "List of components to test")
foreach (CMP_DIR ${EXTRA_COMPONENT_DIRS})
string(SUBSTRING ${CMP_DIR} 3 100 STRIPPED_CMP) # There should be no component name longer than 100 bytes...
list(APPEND TEST_COMPONENTS ${STRIPPED_CMP})
endforeach()

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(esp_protocols_test_app)
3 changes: 3 additions & 0 deletions test_app/main/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
idf_component_register(SRCS "test_app_main.c"
INCLUDE_DIRS ""
REQUIRES unity)
14 changes: 14 additions & 0 deletions test_app/main/test_app_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include "unity.h"

void app_main(void)
{
UNITY_BEGIN();
unity_run_all_tests();
UNITY_END();
}
5 changes: 5 additions & 0 deletions test_app/partitions.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Name, Type, SubType, Offset, Size, Flags
# Note: if you have increased the bootloader size, make sure to update the offsets to avoid overlap
nvs, data, nvs, , 0x6000,
phy_init, data, phy, , 0x1000,
factory, app, factory, , 2M,
4 changes: 4 additions & 0 deletions test_app/pytest_test_app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
def test_app(dut):
dut.expect_unity_test_output(timeout=240)
15 changes: 15 additions & 0 deletions test_app/sdkconfig.defaults
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
CONFIG_ESP_INT_WDT=n
CONFIG_ESP_TASK_WDT=n
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"

# Run-time checks of Heap and Stack
CONFIG_HEAP_POISONING_COMPREHENSIVE=y
CONFIG_COMPILER_STACK_CHECK_MODE_STRONG=y
CONFIG_COMPILER_STACK_CHECK=y
CONFIG_ESP_MAIN_TASK_STACK_SIZE=16000
CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK=y

CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL=y
Loading