-
Notifications
You must be signed in to change notification settings - Fork 14
184 lines (173 loc) · 5.91 KB
/
hil-integration-esp-idf.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
name: "HIL: ESP-IDF Integration"
on:
workflow_dispatch:
inputs:
hil_board:
required: true
type: string
idf_target:
required: true
type: string
api-url:
required: true
type: string
api-key-id:
required: true
type: string
coap_gateway_url:
required: true
type: string
workflow_call:
inputs:
hil_board:
required: true
type: string
idf_target:
required: true
type: string
api-url:
required: true
type: string
api-key-id:
required: true
type: string
coap_gateway_url:
required: true
type: string
jobs:
build:
name: esp-idf-${{ inputs.hil_board }}-build
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository and Submodules
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Prep for build
id: build_prep
run: |
echo CONFIG_GOLIOTH_COAP_HOST_URI=\"${{ inputs.coap_gateway_url }}\" \
>> tests/hil/platform/esp-idf/sdkconfig.defaults
rm -rf test_binaries
mkdir test_binaries
echo test_list=$(ls tests/hil/tests) >> "$GITHUB_OUTPUT"
- name: Build Test Firmware
uses: espressif/esp-idf-ci-action@v1
with:
esp_idf_version: v5.4
target: ${{ inputs.idf_target }}
path: 'tests/hil/platform/esp-idf'
command: |
for test in ${{ steps.build_prep.outputs.test_list }}; do
idf.py -DGOLIOTH_HIL_TEST=$test build && \
mv build/merged.bin ../../../../test_binaries/${test}.bin || \
EXITCODE=$?
done
exit $EXITCODE
- name: Save Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.hil_board }}-esp-idf
path: test_binaries/*
test:
name: esp-idf-${{ inputs.hil_board }}-test
needs: build
runs-on:
- is_active
- has_${{ inputs.hil_board }}
timeout-minutes: 30
container:
image: golioth/golioth-hil-base:3407412
volumes:
- /dev:/dev
- /home/golioth/credentials:/opt/credentials
options: --privileged
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Python dependencies
run: |
pip install \
pytest \
pytest-timeout \
tests/hil/scripts/pytest-hil \
git+https://github.com/golioth/python-golioth-tools@v0.7.0
- name: Power On USB Hub
run: python3 /opt/golioth-scripts/usb_hub_power.py on
- name: Download build
uses: actions/download-artifact@v4
with:
name: ${{ inputs.hil_board }}-esp-idf
path: .
- name: Run test
shell: bash
env:
hil_board: ${{ inputs.hil_board }}
run: |
rm -rf summary
mkdir summary
rm -rf allure-reports
source /opt/credentials/runner_env.sh
PORT_VAR=CI_${hil_board^^}_PORT
for test in $(ls tests/hil/tests)
do
pytest --rootdir . tests/hil/tests/$test \
--board ${{ inputs.hil_board }}_espidf \
--port ${!PORT_VAR} \
--fw-image ${test}.bin \
--api-url ${{ inputs.api-url }} \
--api-key ${{ secrets[inputs.api-key-id] }} \
--wifi-ssid ${{ secrets[format('{0}_WIFI_SSID', runner.name)] }} \
--wifi-psk ${{ secrets[format('{0}_WIFI_PSK', runner.name)] }} \
--mask-secrets \
--timeout=600 \
--junitxml=summary/hil-espidf-${{ inputs.hil_board }}-${test}.xml \
--alluredir=allure-reports \
--platform esp-idf \
--runner-name ${{ runner.name }} \
|| EXITCODE=$?
done
exit $EXITCODE
- name: Prepare summary
if: success() || failure()
shell: bash
run: |
if ! command -v sudo; then
# Self-hosted runner docker images don't have sudo installed
mkdir -p -m 777 /tmp && apt update && apt install -y xml-twig-tools
else
sudo apt install -y xml-twig-tools
fi
xml_grep \
--pretty_print indented \
--wrap testsuites \
--descr '' \
--cond "testsuite" \
summary/*.xml \
> combined.xml
mv combined.xml summary/hil-espidf-${{ inputs.hil_board }}.xml
- name: Safe upload CI report summary
uses: ./.github/actions/safe-upload-artifacts
if: success() || failure()
with:
name: ci-summary-hil-espidf-${{ inputs.hil_board }}
path: summary/hil-espidf-${{ inputs.hil_board }}.xml
- name: Safe upload Allure reports
if: success() || failure()
uses: ./.github/actions/safe-upload-artifacts
with:
secrets-json: ${{ toJson(secrets) }}
name: allure-reports-hil-espidf-${{ inputs.hil_board }}
path: allure-reports
- name: Erase flash
if: always()
shell: bash
env:
hil_board: ${{ inputs.hil_board }}
run: |
source /opt/credentials/runner_env.sh
PORT_VAR=CI_${hil_board^^}_PORT
esptool.py --port ${!PORT_VAR} erase_flash
- name: Power Off USB Hub
if: always()
run: python3 /opt/golioth-scripts/usb_hub_power.py off