forked from espressif/esp-protocols
ci(common): Add clang tidy check to esp-protocols
This commit is contained in:
59
.github/workflows/clang-tidy.yml
vendored
Normal file
59
.github/workflows/clang-tidy.yml
vendored
Normal file
@ -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
test_app/CMakeLists.txt
Normal file
30
test_app/CMakeLists.txt
Normal file
@ -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
test_app/main/CMakeLists.txt
Normal file
3
test_app/main/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "test_app_main.c"
|
||||||
|
INCLUDE_DIRS ""
|
||||||
|
REQUIRES unity)
|
14
test_app/main/test_app_main.c
Normal file
14
test_app/main/test_app_main.c
Normal file
@ -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
test_app/partitions.csv
Normal file
5
test_app/partitions.csv
Normal file
@ -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
test_app/pytest_test_app.py
Normal file
4
test_app/pytest_test_app.py
Normal file
@ -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
test_app/sdkconfig.defaults
Normal file
15
test_app/sdkconfig.defaults
Normal file
@ -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
|
Reference in New Issue
Block a user