-
Notifications
You must be signed in to change notification settings - Fork 11
135 lines (129 loc) · 4.24 KB
/
hil_test_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
name: ESP-IDF Hardware-in-the-Loop Tests
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-latest
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.2.1
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 }}" ]
container:
image: golioth/golioth-hil-base:e635559
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
pip install tests/hil/scripts/pytest-hil
pip install git+https://github.com/golioth/[email protected]
- 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: |
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 \
|| EXITCODE=$?
done
exit $EXITCODE
- 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