Skip to content

Commit 0584da5

Browse files
authored
Merge pull request espressif#397 from gabsuren/feat/modem_reusable_actions
ci(common): Created reusable actions for host and coverage tests (IDF-7856)
2 parents 7c5a832 + 9ad04de commit 0584da5

File tree

6 files changed

+69
-114
lines changed

6 files changed

+69
-114
lines changed

.github/workflows/modem__build-host-tests.yml

Lines changed: 9 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -54,105 +54,12 @@ jobs:
5454
5555
host_test_esp_modem:
5656
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
57-
name: Host Tests
58-
runs-on: ubuntu-20.04
59-
container: espressif/idf:release-v4.3
60-
env:
61-
lwip: lwip-2.1.2
62-
lwip_contrib: contrib-2.1.0
63-
lwip_uri: http://download.savannah.nongnu.org/releases/lwip
64-
COMP_DIR: esp-protocols/components/esp_modem
65-
steps:
66-
- name: Checkout esp-protocols
67-
uses: actions/checkout@v3
68-
with:
69-
path: esp-protocols
70-
71-
- name: Build and Test
72-
shell: bash
73-
run: |
74-
apt-get update && apt-get install -y gcc-8 g++-8
75-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
76-
export LWIP_PATH=`pwd`/${{ env.lwip }}
77-
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
78-
. ${IDF_PATH}/export.sh
79-
$GITHUB_WORKSPACE/${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
80-
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/examples/linux_modem
81-
idf.py build
82-
cd $GITHUB_WORKSPACE/esp-protocols/components/esp_modem/test/host_test
83-
idf.py build
84-
./build/host_modem_test.elf -r junit -o junit.xml
85-
86-
- name: Publish Results
87-
uses: EnricoMi/publish-unit-test-result-action@v1
88-
if: always()
89-
with:
90-
files: esp-protocols/components/esp_modem/test/host_test/junit.xml
91-
92-
host_test_gcov_esp_modem:
93-
if: contains(github.event.pull_request.labels.*.name, 'modem') || github.event_name == 'push'
94-
name: Run gcovr on esp modem host test
95-
runs-on: ubuntu-22.04
96-
permissions:
97-
contents: write
98-
container: espressif/idf:release-v4.3
99-
env:
100-
lwip: lwip-2.1.2
101-
lwip_contrib: contrib-2.1.0
102-
lwip_uri: http://download.savannah.nongnu.org/releases/lwip
103-
COMP_DIR: esp-protocols/components/esp_modem
104-
steps:
105-
- name: Checkout esp-protocols
106-
uses: actions/checkout@v3
107-
with:
108-
path: esp-protocols
109-
repository: ''
110-
persist-credentials: false
111-
- name: Build and Test
112-
shell: bash
113-
run: |
114-
apt-get update && apt-get install -y gcc-8 g++-8 python3-pip
115-
apt-get install -y rsync
116-
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
117-
export DEBIAN_FRONTEND=noninteractive
118-
export LWIP_PATH=`pwd`/${{ env.lwip }}
119-
export LWIP_CONTRIB_PATH=`pwd`/${{ env.lwip_contrib }}
120-
. ${IDF_PATH}/export.sh
121-
${{ env.COMP_DIR }}/test/host_test/env.sh $lwip $lwip_uri $lwip_contrib
122-
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/test/host_test
123-
cat sdkconfig.ci.coverage >> sdkconfig.defaults
124-
idf.py build
125-
./build/host_modem_test.elf
126-
- name: Run gcovr
127-
shell: bash
128-
run: |
129-
python -m pip install gcovr
130-
cd $GITHUB_WORKSPACE/${{ env.COMP_DIR }}
131-
gcov-8 `find . -name "esp_modem*gcda" -printf '%h\n' | head -n 1`/*
132-
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x esp_modem_coverage.xml
133-
mkdir modem_coverage_report
134-
cp $GITHUB_WORKSPACE/${{ env.COMP_DIR }}/index.html modem_coverage_report
135-
cp -rf modem_coverage_report $GITHUB_WORKSPACE
136-
- name: Code Coverage Summary Report
137-
uses: irongut/CodeCoverageSummary@v1.3.0
138-
with:
139-
filename: esp-protocols/**/esp_modem_coverage.xml
140-
badge: true
141-
fail_below_min: false
142-
format: markdown
143-
hide_branch_rate: false
144-
hide_complexity: false
145-
indicators: true
146-
output: both
147-
thresholds: '60 80'
148-
- name: Write to Job Summary
149-
run: cat code-coverage-results.md >> $GITHUB_STEP_SUMMARY
150-
151-
- name: Upload artifacts
152-
uses: actions/upload-artifact@v3
153-
if: always()
154-
with:
155-
name: modem_coverage_report
156-
path: |
157-
${{ env.COMP_DIR }}/modem_coverage_report
158-
if-no-files-found: error
57+
uses: "./.github/workflows/run-host-tests.yml"
58+
with:
59+
idf_version: "release-v4.3"
60+
app_name: "host_modem_test"
61+
app_path: "esp-protocols/components/esp_modem/test/host_test"
62+
component_path: "esp-protocols/components/esp_modem"
63+
upload_artifacts: true
64+
pre_run_script: "esp-protocols/components/esp_modem/test/host_test/env.sh"
65+
publish_unit_test_result: true

.github/workflows/run-host-tests.yml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ on:
1818
upload_artifacts:
1919
type: boolean
2020
required: true
21+
pre_run_script:
22+
type: string
23+
required: false
24+
publish_unit_test_result:
25+
type: boolean
26+
required: false
2127

2228
jobs:
2329
build:
@@ -34,20 +40,35 @@ jobs:
3440
- name: Build ${{ inputs.app_name }} with IDF-${{ inputs.idf_version }}
3541
shell: bash
3642
run: |
43+
component=$(basename ${{ inputs.component_path }})
44+
if [ -f "${{ inputs.pre_run_script }}" ]; then
45+
source ${{ inputs.pre_run_script }} ${{ inputs.idf_version }} $component
46+
fi
3747
. ${IDF_PATH}/export.sh
38-
cd $GITHUB_WORKSPACE/${{inputs.app_path}}
48+
cd ${{inputs.app_path}}
3949
rm -rf sdkconfig sdkconfig.defaults build
50+
# The sdkconfig.ci.linux specifies Linux as the build target with apropriate settings.
4051
cp sdkconfig.ci.linux sdkconfig.defaults
4152
idf.py build
42-
./build/${{inputs.app_name}}.elf
53+
./build/${{inputs.app_name}}.elf -r junit -o junit.xml
54+
- name: Publish Unit Test Result
55+
uses: EnricoMi/publish-unit-test-result-action@v2
56+
if: ${{ inputs.publish_unit_test_result }}
57+
with:
58+
files: ${{inputs.component_path}}/**/*junit.xml
4359
- name: Build with Coverage Enabled
4460
shell: bash
4561
run: |
62+
component=$(basename ${{ inputs.component_path }})
63+
if [ -f "${{ inputs.pre_run_script }}" ]; then
64+
source ${{ inputs.pre_run_script }} ${{ inputs.idf_version }} $component
65+
fi
4666
. ${IDF_PATH}/export.sh
4767
cd $GITHUB_WORKSPACE/${{inputs.app_path}}
4868
rm -rf build sdkconfig sdkconfig.defaults
49-
cp sdkconfig.ci.coverage sdkconfig.defaults
5069
idf.py fullclean
70+
# The sdkconfig.ci.coverage specifies Linux as the build target with apropriate settings (CONFIG_GCOV_ENABLED=y).
71+
cp sdkconfig.ci.coverage sdkconfig.defaults
5172
idf.py build
5273
./build/${{inputs.app_name}}.elf
5374
- name: Run Coverage
@@ -56,7 +77,8 @@ jobs:
5677
apt-get update && apt-get install -y python3-pip rsync
5778
python -m pip install gcovr
5879
cd $GITHUB_WORKSPACE/${{inputs.component_path}}
59-
gcov `find . -name "*gcda"`
80+
component=$(basename ${{ inputs.component_path }})
81+
gcov `find . -name "$component*gcda"`
6082
gcovr --gcov-ignore-parse-errors -g -k -r . --html index.html -x ${{inputs.app_name}}_coverage.xml
6183
mkdir ${{inputs.app_name}}_coverage_report
6284
touch ${{inputs.app_name}}_coverage_report/.nojekyll
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_IDF_TARGET="linux"
2+
CONFIG_COMPILER_CXX_EXCEPTIONS=y
3+
CONFIG_COMPILER_CXX_RTTI=y
4+
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
5+
CONFIG_COMPILER_STACK_CHECK_NONE=y
Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
#!/bin/bash
22

3-
lwip=$1
4-
lwip_uri=$2
5-
lwip_contrib=$3
6-
7-
wget --no-verbose ${lwip_uri}/${lwip}.zip
8-
unzip -oq ${lwip}.zip
9-
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
10-
unzip -oq ${lwip_contrib}.zip
3+
idf_version=$1
4+
component=$2
5+
6+
if [[ "$idf_version" == "release-v4.3" ]] && [[ "$component" == "esp_modem" ]]; then
7+
lwip=lwip-2.1.2
8+
lwip_uri=http://download.savannah.nongnu.org/releases/lwip
9+
lwip_contrib=contrib-2.1.0
10+
11+
wget --no-verbose ${lwip_uri}/${lwip}.zip
12+
unzip -oq ${lwip}.zip
13+
wget --no-verbose ${lwip_uri}/${lwip_contrib}.zip
14+
unzip -oq ${lwip_contrib}.zip
15+
16+
apt-get update && apt-get install -y gcc-8 g++-8
17+
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 800 --slave /usr/bin/g++ g++ /usr/bin/g++-8
18+
rm /usr/bin/gcov && ln -s /usr/bin/gcov-8 /usr/bin/gcov
19+
export LWIP_PATH=`pwd`/$lwip
20+
export LWIP_CONTRIB_PATH=`pwd`/$lwip_contrib
21+
fi
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,6 @@
1+
CONFIG_IDF_TARGET="linux"
2+
CONFIG_COMPILER_CXX_EXCEPTIONS=y
3+
CONFIG_COMPILER_CXX_RTTI=y
4+
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
5+
CONFIG_COMPILER_STACK_CHECK_NONE=y
16
CONFIG_GCOV_ENABLED=y
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CONFIG_IDF_TARGET="linux"
2+
CONFIG_COMPILER_CXX_EXCEPTIONS=y
3+
CONFIG_COMPILER_CXX_RTTI=y
4+
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
5+
CONFIG_COMPILER_STACK_CHECK_NONE=y

0 commit comments

Comments
 (0)