forked from espressif/esp-protocols
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request espressif#310 from gabsuren/feat/websocket_linux_p…
…ort_component feat(websocket): Added linux port for websocket (IDF-7097)
- Loading branch information
Showing
20 changed files
with
362 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,7 +109,6 @@ jobs: | |
- name: Build and Test | ||
shell: bash | ||
run: | | ||
apt-get update | ||
apt-get update && apt-get install -y gcc-8 g++-8 python3-pip | ||
apt-get install -y rsync | ||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8 | ||
|
@@ -129,9 +128,9 @@ jobs: | |
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }} | ||
gcov-8 `find . -name "esp_modem*gcda" -printf '%h\n' | head -n 1`/* | ||
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 | ||
cp -rf docs_gcovr $GITHUB_WORKSPACE | ||
mkdir modem_coverage_report | ||
cp $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/index.html modem_coverage_report | ||
cp -rf modem_coverage_report $GITHUB_WORKSPACE | ||
- name: Code Coverage Summary Report | ||
uses: irongut/[email protected] | ||
with: | ||
|
@@ -151,13 +150,7 @@ jobs: | |
uses: actions/upload-artifact@v3 | ||
if: always() | ||
with: | ||
name: docs_gcovr | ||
name: modem_coverage_report | ||
path: | | ||
${{ env.COMP_DIR }}/docs_gcovr | ||
${{ env.COMP_DIR }}/modem_coverage_report | ||
if-no-files-found: error | ||
- 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 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: Publish coverage report to Github Pages | ||
|
||
on: | ||
workflow_run: | ||
workflows: ["websocket: build/host-tests", "esp-modem: build/host-tests"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
publish_github_pages: | ||
runs-on: ubuntu-latest | ||
if: github.repository == 'espressif/esp-protocols' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
- name: Download Websocket Artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: websocket__build-host-tests.yml | ||
workflow_conclusion: success | ||
name: websocket_coverage_report | ||
path: websocket_coverage_report_artifact | ||
- name: Download Modem Artifact | ||
uses: dawidd6/action-download-artifact@v2 | ||
with: | ||
workflow: modem__build-host-tests.yml | ||
workflow_conclusion: success | ||
name: modem_coverage_report | ||
path: modem_coverage_report_artifact | ||
- name: Merge HTML files | ||
run: | | ||
echo "<html><body>" > index.html | ||
cat modem_coverage_report_artifact/index.html >> index.html | ||
cat websocket_coverage_report_artifact/index.html >> index.html | ||
echo "</body></html>" >> index.html | ||
mkdir coverage_report | ||
mv index.html coverage_report | ||
- name: Deploy generated docs | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
folder: coverage_report |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Run on host | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
idf_version: | ||
required: true | ||
type: string | ||
app_name: | ||
type: string | ||
required: true | ||
app_path: | ||
type: string | ||
required: true | ||
component_path: | ||
type: string | ||
required: true | ||
upload_artifacts: | ||
type: boolean | ||
required: true | ||
|
||
jobs: | ||
build: | ||
name: Build App | ||
runs-on: ubuntu-20.04 | ||
permissions: | ||
contents: write | ||
container: espressif/idf:${{inputs.idf_version}} | ||
steps: | ||
- name: Checkout esp-protocols | ||
uses: actions/checkout@v3 | ||
with: | ||
path: esp-protocols | ||
- name: Build ${{ inputs.app_name }} with IDF-${{ inputs.idf_version }} | ||
shell: bash | ||
run: | | ||
. ${IDF_PATH}/export.sh | ||
cd $GITHUB_WORKSPACE/${{inputs.app_path}} | ||
rm -rf sdkconfig sdkconfig.defaults build | ||
cp sdkconfig.ci.linux sdkconfig.defaults | ||
idf.py build | ||
./build/${{inputs.app_name}}.elf | ||
- name: Build with Coverage Enabled | ||
shell: bash | ||
run: | | ||
. ${IDF_PATH}/export.sh | ||
cd $GITHUB_WORKSPACE/${{inputs.app_path}} | ||
rm -rf build sdkconfig sdkconfig.defaults | ||
cp sdkconfig.ci.coverage sdkconfig.defaults | ||
idf.py fullclean | ||
idf.py build | ||
./build/${{inputs.app_name}}.elf | ||
- name: Run Coverage | ||
shell: bash | ||
run: | | ||
apt-get update && apt-get install -y gcc-8 g++-8 python3-pip rsync | ||
python -m pip install gcovr | ||
cd $GITHUB_WORKSPACE/${{inputs.component_path}} | ||
gcov `find . -name "*gcda"` | ||
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x ${{inputs.app_name}}_coverage.xml | ||
mkdir ${{inputs.app_name}}_coverage_report | ||
touch ${{inputs.app_name}}_coverage_report/.nojekyll | ||
cp index.html ${{inputs.app_name}}_coverage_report | ||
cp -rf ${{inputs.app_name}}_coverage_report ${{inputs.app_name}}_coverage.xml $GITHUB_WORKSPACE | ||
- name: Code Coverage Summary Report | ||
uses: irongut/[email protected] | ||
with: | ||
filename: esp-protocols/**/${{inputs.app_name}}_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 files to artifacts for run-target job | ||
uses: actions/upload-artifact@v3 | ||
if: ${{inputs.upload_artifacts}} | ||
with: | ||
name: ${{inputs.app_name}}_coverage_report | ||
path: | | ||
${{inputs.component_path}}/${{inputs.app_name}}_coverage_report | ||
if-no-files-found: error |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: "websocket: build/host-tests" | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
types: [opened, synchronize, reopened, labeled] | ||
|
||
|
||
jobs: | ||
host_test_websocket: | ||
if: contains(github.event.pull_request.labels.*.name, 'websocket') || github.event_name == 'push' | ||
uses: "./.github/workflows/run-host-tests.yml" | ||
with: | ||
idf_version: "latest" | ||
app_name: "websocket" | ||
app_path: "esp-protocols/components/esp_websocket_client/examples/linux" | ||
component_path: "esp-protocols/components/esp_websocket_client" | ||
upload_artifacts: true |
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
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
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
15 changes: 15 additions & 0 deletions
15
components/esp_websocket_client/examples/linux/CMakeLists.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
|
||
set(COMPONENTS esp_websocket_client main) | ||
set(common_component_dir ../../../../common_components) | ||
set(EXTRA_COMPONENT_DIRS | ||
../../.. | ||
"${common_component_dir}/linux_compat/esp_timer" | ||
"${common_component_dir}/linux_compat" | ||
"${common_component_dir}/linux_compat/freertos") | ||
|
||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common) | ||
list(APPEND EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/protocols/linux_stubs/esp_stubs) | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
||
project(websocket) |
14 changes: 14 additions & 0 deletions
14
components/esp_websocket_client/examples/linux/main/CMakeLists.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
idf_component_register(SRCS "main.c" | ||
INCLUDE_DIRS | ||
"." | ||
REQUIRES esp_websocket_client protocol_examples_common) | ||
|
||
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_websocket_client esp_websocket_client COMPONENT_LIB) | ||
|
||
target_compile_options(${esp_websocket_client} PUBLIC --coverage -fprofile-arcs -ftest-coverage) | ||
target_link_options(${esp_websocket_client} PUBLIC --coverage -fprofile-arcs -ftest-coverage) | ||
endif() |
15 changes: 15 additions & 0 deletions
15
components/esp_websocket_client/examples/linux/main/Kconfig.projbuild
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
menu "Host-test config" | ||
|
||
config GCOV_ENABLED | ||
bool "Coverage analyzer" | ||
default n | ||
help | ||
Enables coverage analyzing for host tests. | ||
|
||
config WEBSOCKET_URI | ||
string "Websocket endpoint URI" | ||
default "ws://echo.websocket.events" | ||
help | ||
URL of websocket endpoint this example connects to and sends echo | ||
|
||
endmenu |
Oops, something went wrong.