From 4910e89249fc0b9122dfb2acec4aff90845fbc9a Mon Sep 17 00:00:00 2001 From: Suren Gabrielyan Date: Mon, 15 May 2023 18:45:29 +0400 Subject: [PATCH] fix(ci): enable code coverage publishing to github pages --- .github/workflows/modem__build-host-tests.yml | 34 ++++++------------- components/esp_modem/CMakeLists.txt | 12 ------- .../esp_modem/test/host_test/CMakeLists.txt | 12 ------- .../test/host_test/main/CMakeLists.txt | 9 +++++ 4 files changed, 19 insertions(+), 48 deletions(-) diff --git a/.github/workflows/modem__build-host-tests.yml b/.github/workflows/modem__build-host-tests.yml index 009d032b9..a1c520119 100644 --- a/.github/workflows/modem__build-host-tests.yml +++ b/.github/workflows/modem__build-host-tests.yml @@ -91,6 +91,8 @@ jobs: if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push' name: Run gcovr on esp modem host test runs-on: ubuntu-22.04 + permissions: + contents: write container: espressif/idf:release-v4.3 env: lwip: lwip-2.1.2 @@ -102,6 +104,7 @@ jobs: uses: actions/checkout@v3 with: path: esp-protocols + repository: '' persist-credentials: false - name: Build and Test shell: bash @@ -128,8 +131,7 @@ jobs: gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x esp_modem_coverage.xml mkdir docs_gcovr cp $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/index.html docs_gcovr - touch docs_gcovr/.nojekyll - + cp -rf docs_gcovr $GITHUB_WORKSPACE - name: Code Coverage Summary Report uses: irongut/CodeCoverageSummary@v1.3.0 with: @@ -142,7 +144,6 @@ jobs: indicators: true output: both thresholds: '60 80' - - name: Write to Job Summary run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY @@ -154,24 +155,9 @@ jobs: path: | ${{ env.COMP_DIR }}/docs_gcovr if-no-files-found: error - -# show_report_data: -# name: Publish-Results -# if: github.ref == 'refs/heads/master' || github.repository != 'espressif/esp-protocols' -# runs-on: ubuntu-22.04 -# needs: gcovr_analyzer_esp_modem -# steps: -# - name: Checkout 🛎️ -# uses: actions/checkout@v3 -# with: -# persist-credentials: false -# - name: Download Artifacts -# uses: actions/download-artifact@v1 -# with: -# name: docs_gcovr -# -# - name: Deploy generated docs -# uses: JamesIves/github-pages-deploy-action@v4 -# with: -# branch: gh-pages -# folder: 'docs_gcovr' + - name: Deploy code coverage results + if: github.ref == 'refs/heads/master' + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./docs_gcovr diff --git a/components/esp_modem/CMakeLists.txt b/components/esp_modem/CMakeLists.txt index ca4c4dd0b..10d39577c 100644 --- a/components/esp_modem/CMakeLists.txt +++ b/components/esp_modem/CMakeLists.txt @@ -47,15 +47,3 @@ if(${target} STREQUAL "linux") # This is needed for ESP_LOGx() macros, as integer formats differ on ESP32(..) and x64 set_target_properties(${COMPONENT_LIB} PROPERTIES COMPILE_FLAGS -Wno-format) endif() - -if(CONFIG_GCOV_ENABLED) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage") - - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) -endif() diff --git a/components/esp_modem/test/host_test/CMakeLists.txt b/components/esp_modem/test/host_test/CMakeLists.txt index d03242625..8c603a21e 100644 --- a/components/esp_modem/test/host_test/CMakeLists.txt +++ b/components/esp_modem/test/host_test/CMakeLists.txt @@ -13,15 +13,3 @@ idf_component_get_property(esp_modem esp_modem COMPONENT_LIB) target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_COMPILER_CXX_EXCEPTIONS") target_compile_definitions(${esp_modem} PRIVATE "-DCONFIG_IDF_TARGET_LINUX") target_link_options(${esp_modem} INTERFACE -fsanitize=address -fsanitize=undefined) - -if(CONFIG_GCOV_ENABLED) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage -fprofile-arcs -ftest-coverage") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fprofile-arcs -ftest-coverage") - - - MARK_AS_ADVANCED( - CMAKE_CXX_FLAGS_COVERAGE - CMAKE_C_FLAGS_COVERAGE - CMAKE_EXE_LINKER_FLAGS_COVERAGE - CMAKE_SHARED_LINKER_FLAGS_COVERAGE ) -endif() diff --git a/components/esp_modem/test/host_test/main/CMakeLists.txt b/components/esp_modem/test/host_test/main/CMakeLists.txt index 245cd9316..9b6d4ab57 100644 --- a/components/esp_modem/test/host_test/main/CMakeLists.txt +++ b/components/esp_modem/test/host_test/main/CMakeLists.txt @@ -12,3 +12,12 @@ set_target_properties(${COMPONENT_LIB} PROPERTIES CXX_EXTENSIONS ON ) target_compile_definitions(${COMPONENT_LIB} PRIVATE "-DCONFIG_IDF_TARGET_LINUX") + +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(esp_modem esp_modem COMPONENT_LIB) + target_compile_options(${esp_modem} PUBLIC --coverage -fprofile-arcs -ftest-coverage) + target_link_options(${esp_modem} PUBLIC --coverage -fprofile-arcs -ftest-coverage) +endif()