mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-17 20:42:21 +02:00
ci(common): Created reusable action for host and coverage tests
This commit is contained in:
111
.github/workflows/modem__build-host-tests.yml
vendored
111
.github/workflows/modem__build-host-tests.yml
vendored
@ -54,105 +54,12 @@ jobs:
|
|||||||
|
|
||||||
host_test_esp_modem:
|
host_test_esp_modem:
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
|
||||||
name: Host Tests
|
uses: "./.github/workflows/run-host-tests.yml"
|
||||||
runs-on: ubuntu-20.04
|
with:
|
||||||
container: espressif/idf:release-v4.3
|
idf_version: "release-v4.3"
|
||||||
env:
|
app_name: "host_modem_test"
|
||||||
lwip: lwip-2.1.2
|
app_path: "esp-protocols/components/esp_modem/test/host_test"
|
||||||
lwip_contrib: contrib-2.1.0
|
component_path: "esp-protocols/components/esp_modem"
|
||||||
lwip_uri: http://download.savannah.nongnu.org/releases/lwip
|
upload_artifacts: true
|
||||||
COMP_DIR: esp-protocols/components/esp_modem
|
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
|
||||||
steps:
|
publish_unit_test_result: true
|
||||||
- name: Checkout esp-protocols
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: esp-protocols
|
|
||||||
|
|
||||||
- name: Build and Test
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
apt-get update && apt-get install -y gcc-8 g++-8
|
|
||||||
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
|
||||||
export LWIP_PATH=`pwd`/${{ env.lwip }}
|
|
||||||
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
|
|
||||||
. ${IDF_PATH}/export.sh
|
|
||||||
$GITHUB_WORKSPACE/${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
|
|
||||||
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/examples/linux_modem
|
|
||||||
idf.py build
|
|
||||||
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/test/host_test
|
|
||||||
idf.py build
|
|
||||||
./build/host_modem_test.elf -r junit -o junit.xml
|
|
||||||
|
|
||||||
- name: Publish Results
|
|
||||||
uses: EnricoMi/publish-unit-test-result-action@v1
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
files: esp-protocols/components/esp_modem/test/host_test/junit.xml
|
|
||||||
|
|
||||||
host_test_gcov_esp_modem:
|
|
||||||
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
|
|
||||||
lwip_contrib: contrib-2.1.0
|
|
||||||
lwip_uri: http://download.savannah.nongnu.org/releases/lwip
|
|
||||||
COMP_DIR: esp-protocols/components/esp_modem
|
|
||||||
steps:
|
|
||||||
- name: Checkout esp-protocols
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: esp-protocols
|
|
||||||
repository: ''
|
|
||||||
persist-credentials: false
|
|
||||||
- name: Build and Test
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
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
|
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
|
||||||
export LWIP_PATH=`pwd`/${{ env.lwip }}
|
|
||||||
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
|
|
||||||
. ${IDF_PATH}/export.sh
|
|
||||||
${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
|
|
||||||
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/test/host_test
|
|
||||||
cat sdkconfig.ci.coverage >> sdkconfig.defaults
|
|
||||||
idf.py build
|
|
||||||
./build/host_modem_test.elf
|
|
||||||
- name: Run gcovr
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
python -m pip install gcovr
|
|
||||||
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 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/CodeCoverageSummary@v1.3.0
|
|
||||||
with:
|
|
||||||
filename: esp-protocols/**/esp_modem_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: modem_coverage_report
|
|
||||||
path: |
|
|
||||||
${{ env.COMP_DIR }}/modem_coverage_report
|
|
||||||
if-no-files-found: error
|
|
||||||
|
30
.github/workflows/run-host-tests.yml
vendored
30
.github/workflows/run-host-tests.yml
vendored
@ -18,6 +18,12 @@ on:
|
|||||||
upload_artifacts:
|
upload_artifacts:
|
||||||
type: boolean
|
type: boolean
|
||||||
required: true
|
required: true
|
||||||
|
pre_run_script:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
publish_unit_test_result:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
@ -34,20 +40,35 @@ jobs:
|
|||||||
- name: Build ${{ inputs.app_name }} with IDF-${{ inputs.idf_version }}
|
- name: Build ${{ inputs.app_name }} with IDF-${{ inputs.idf_version }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
component=$(basename ${{ inputs.component_path }})
|
||||||
|
if [ -f "${{ inputs.pre_run_script }}" ]; then
|
||||||
|
source ${{ inputs.pre_run_script }} ${{ inputs.idf_version }} $component
|
||||||
|
fi
|
||||||
. ${IDF_PATH}/export.sh
|
. ${IDF_PATH}/export.sh
|
||||||
cd $GITHUB_WORKSPACE/${{inputs.app_path}}
|
cd ${{inputs.app_path}}
|
||||||
rm -rf sdkconfig sdkconfig.defaults build
|
rm -rf sdkconfig sdkconfig.defaults build
|
||||||
|
# The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings.
|
||||||
cp sdkconfig.ci.linux sdkconfig.defaults
|
cp sdkconfig.ci.linux sdkconfig.defaults
|
||||||
idf.py build
|
idf.py build
|
||||||
./build/${{inputs.app_name}}.elf
|
./build/${{inputs.app_name}}.elf -r junit -o junit.xml
|
||||||
|
- name: Publish Unit Test Result
|
||||||
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
||||||
|
if: ${{ inputs.publish_unit_test_result }}
|
||||||
|
with:
|
||||||
|
files: ${{inputs.component_path}}/**/*junit.xml
|
||||||
- name: Build with Coverage Enabled
|
- name: Build with Coverage Enabled
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
|
component=$(basename ${{ inputs.component_path }})
|
||||||
|
if [ -f "${{ inputs.pre_run_script }}" ]; then
|
||||||
|
source ${{ inputs.pre_run_script }} ${{ inputs.idf_version }} $component
|
||||||
|
fi
|
||||||
. ${IDF_PATH}/export.sh
|
. ${IDF_PATH}/export.sh
|
||||||
cd $GITHUB_WORKSPACE/${{inputs.app_path}}
|
cd $GITHUB_WORKSPACE/${{inputs.app_path}}
|
||||||
rm -rf build sdkconfig sdkconfig.defaults
|
rm -rf build sdkconfig sdkconfig.defaults
|
||||||
cp sdkconfig.ci.coverage sdkconfig.defaults
|
|
||||||
idf.py fullclean
|
idf.py fullclean
|
||||||
|
# The sdkconfig.ci.coverage specifies Linux as the build target with apropriate settings (CONFIG_GCOV_ENABLED=y).
|
||||||
|
cp sdkconfig.ci.coverage sdkconfig.defaults
|
||||||
idf.py build
|
idf.py build
|
||||||
./build/${{inputs.app_name}}.elf
|
./build/${{inputs.app_name}}.elf
|
||||||
- name: Run Coverage
|
- name: Run Coverage
|
||||||
@ -56,7 +77,8 @@ jobs:
|
|||||||
apt-get update && apt-get install -y python3-pip rsync
|
apt-get update && apt-get install -y python3-pip rsync
|
||||||
python -m pip install gcovr
|
python -m pip install gcovr
|
||||||
cd $GITHUB_WORKSPACE/${{inputs.component_path}}
|
cd $GITHUB_WORKSPACE/${{inputs.component_path}}
|
||||||
gcov `find . -name "*gcda"`
|
component=$(basename ${{ inputs.component_path }})
|
||||||
|
gcov `find . -name "$component*gcda"`
|
||||||
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x ${{inputs.app_name}}_coverage.xml
|
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x ${{inputs.app_name}}_coverage.xml
|
||||||
mkdir ${{inputs.app_name}}_coverage_report
|
mkdir ${{inputs.app_name}}_coverage_report
|
||||||
touch ${{inputs.app_name}}_coverage_report/.nojekyll
|
touch ${{inputs.app_name}}_coverage_report/.nojekyll
|
||||||
|
@ -0,0 +1,5 @@
|
|||||||
|
CONFIG_IDF_TARGET="linux"
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
|
CONFIG_COMPILER_CXX_RTTI=y
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
|
||||||
|
CONFIG_COMPILER_STACK_CHECK_NONE=y
|
@ -1,10 +1,21 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
lwip=$1
|
idf_version=$1
|
||||||
lwip_uri=$2
|
component=$2
|
||||||
lwip_contrib=$3
|
|
||||||
|
|
||||||
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then
|
||||||
unzip -oq ${lwip}.zip
|
lwip=lwip-2.1.2
|
||||||
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
|
||||||
unzip -oq ${lwip_contrib}.zip
|
lwip_contrib=contrib-2.1.0
|
||||||
|
|
||||||
|
wget --no-verbose ${lwip_uri}/${lwip}.zip
|
||||||
|
unzip -oq ${lwip}.zip
|
||||||
|
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
|
||||||
|
unzip -oq ${lwip_contrib}.zip
|
||||||
|
|
||||||
|
apt-get update && apt-get install -y gcc-8 g++-8
|
||||||
|
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
|
||||||
|
rm /usr/bin/gcov && ln -s /usr/bin/gcov-8 /usr/bin/gcov
|
||||||
|
export LWIP_PATH=`pwd`/$lwip
|
||||||
|
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
|
||||||
|
fi
|
||||||
|
@ -1 +1,6 @@
|
|||||||
|
CONFIG_IDF_TARGET="linux"
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
|
CONFIG_COMPILER_CXX_RTTI=y
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
|
||||||
|
CONFIG_COMPILER_STACK_CHECK_NONE=y
|
||||||
CONFIG_GCOV_ENABLED=y
|
CONFIG_GCOV_ENABLED=y
|
||||||
|
5
components/esp_modem/test/host_test/sdkconfig.ci.linux
Normal file
5
components/esp_modem/test/host_test/sdkconfig.ci.linux
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
CONFIG_IDF_TARGET="linux"
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS=y
|
||||||
|
CONFIG_COMPILER_CXX_RTTI=y
|
||||||
|
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
|
||||||
|
CONFIG_COMPILER_STACK_CHECK_NONE=y
|
Reference in New Issue
Block a user