mirror of
https://github.com/espressif/esp-mqtt.git
synced 2025-07-29 18:28:24 +02:00
feature: added host tests
This commit is contained in:
80
.github/workflows/mqtt__host-tests.yml
vendored
Normal file
80
.github/workflows/mqtt__host-tests.yml
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
name: "esp-mqtt: host-tests"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, labeled]
|
||||
|
||||
jobs:
|
||||
host_test_esp_mqtt:
|
||||
name: Host Tests
|
||||
runs-on: ubuntu-22.04
|
||||
permissions:
|
||||
contents: write
|
||||
container: espressif/idf:latest
|
||||
env:
|
||||
COMP_DIR: components/mqtt/esp-mqtt
|
||||
steps:
|
||||
- name: Checkout esp-mqtt
|
||||
uses: actions/checkout@v3
|
||||
- name: Build and Test
|
||||
shell: bash
|
||||
run: |
|
||||
apt-get update && apt-get install -y gcc-8 g++-8 python3-pip rsync
|
||||
${IDF_PATH}/install.sh
|
||||
. ${IDF_PATH}/export.sh
|
||||
echo "IDF_PATH=${IDF_PATH}" >> $GITHUB_ENV
|
||||
rm -rf $IDF_PATH/${{ env.COMP_DIR }}
|
||||
cp -r . $IDF_PATH/${{ env.COMP_DIR }}
|
||||
cd $IDF_PATH/${{ env.COMP_DIR }}/host_test
|
||||
idf.py build
|
||||
./build/host_mqtt_client_test.elf -r junit -o junit.xml
|
||||
- name: Build with Coverage Enabled
|
||||
shell: bash
|
||||
run: |
|
||||
. ${IDF_PATH}/export.sh
|
||||
cd $IDF_PATH/${{ env.COMP_DIR }}/host_test
|
||||
cat sdkconfig.ci.coverage >> sdkconfig.defaults
|
||||
rm -rf build sdkconfig
|
||||
idf.py build
|
||||
./build/host_mqtt_client_test.elf
|
||||
- name: Run gcovr
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install gcovr
|
||||
cd $IDF_PATH/${{ env.COMP_DIR }}
|
||||
gcov -b host_test/main/mqtt_client.c. -o `find . -name "mqtt_client*gcda" -exec dirname {} \;`
|
||||
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x esp_mqtt_coverage.xml
|
||||
mkdir docs_gcovr
|
||||
mv index.html docs_gcovr
|
||||
touch docs_gcovr/.nojekyll
|
||||
cp -r docs_gcovr esp_mqtt_coverage.xml $GITHUB_WORKSPACE
|
||||
- name: Code Coverage Summary Report
|
||||
uses: irongut/CodeCoverageSummary@v1.3.0
|
||||
with:
|
||||
filename: ${{ env.GITHUB_WORKSPACE }}/**/esp_mqtt_coverage.xml
|
||||
badge: true
|
||||
fail_below_min: false
|
||||
format: markdown
|
||||
hide_branch_rate: false
|
||||
hide_complexity: false
|
||||
indicators: true
|
||||
output: both
|
||||
thresholds: '60 80'
|
||||
- name: Write to Job Summary
|
||||
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
|
||||
- name: Upload artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
if: always()
|
||||
with:
|
||||
name: docs_gcovr
|
||||
path: ${{ env.IDF_PATH }}/${{ env.COMP_DIR }}/docs_gcovr
|
||||
if-no-files-found: error
|
||||
- name: Deploy coverage summary
|
||||
if: github.ref == 'refs/heads/master'
|
||||
uses: JamesIves/github-pages-deploy-action@v4.4.1
|
||||
with:
|
||||
branch: gh-pages
|
||||
folder: ${{ env.IDF_PATH }}/${{ env.COMP_DIR }}/docs_gcovr
|
@ -13,6 +13,3 @@ idf_component_register(SRCS "${srcs}"
|
||||
KCONFIG ${CMAKE_CURRENT_LIST_DIR}/Kconfig
|
||||
)
|
||||
target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format")
|
||||
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
set(COMPONENTS main)
|
||||
set(COMPONENTS mqtt main)
|
||||
list(APPEND EXTRA_COMPONENT_DIRS
|
||||
"mocks/heap/"
|
||||
"$ENV{IDF_PATH}/tools/mocks/esp_hw_support/"
|
||||
|
@ -1,3 +1,12 @@
|
||||
idf_component_register(SRCS "test_mqtt_client.cpp"
|
||||
INCLUDE_DIRS "$ENV{IDF_PATH}/tools/catch"
|
||||
REQUIRES cmock mqtt esp_timer esp_hw_support http_parser log)
|
||||
|
||||
if(CONFIG_GCOV_ENABLED)
|
||||
target_compile_options(${COMPONENT_LIB} PUBLIC --coverage -fprofile-arcs -ftest-coverage)
|
||||
target_link_options(${COMPONENT_LIB} PUBLIC --coverage -fprofile-arcs -ftest-coverage)
|
||||
|
||||
idf_component_get_property(mqtt mqtt COMPONENT_LIB)
|
||||
target_compile_options(${mqtt} PUBLIC --coverage -fprofile-arcs -ftest-coverage)
|
||||
target_link_options(${mqtt} PUBLIC --coverage -fprofile-arcs -ftest-coverage)
|
||||
endif()
|
||||
|
9
host_test/main/Kconfig
Normal file
9
host_test/main/Kconfig
Normal file
@ -0,0 +1,9 @@
|
||||
menu "Host-test config"
|
||||
|
||||
config GCOV_ENABLED
|
||||
bool "Coverage analyzer"
|
||||
default n
|
||||
help
|
||||
Enables coverage analyzing for host tests.
|
||||
|
||||
endmenu
|
1
host_test/sdkconfig.ci.coverage
Normal file
1
host_test/sdkconfig.ci.coverage
Normal file
@ -0,0 +1 @@
|
||||
CONFIG_GCOV_ENABLED=y
|
Reference in New Issue
Block a user