Skip to content

Commit 65172e5

Browse files
committed
fix(ci): Fix tests and workflows
1 parent 491e2d2 commit 65172e5

File tree

9 files changed

+128
-15
lines changed

9 files changed

+128
-15
lines changed

.github/scripts/tests_run.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,23 @@ function run_test {
111111

112112
rm "$sketchdir"/diagram.json 2>/dev/null || true
113113

114+
local wifi_args=""
115+
if [ -n "$wifi_ssid" ]; then
116+
wifi_args="--wifi-ssid \"$wifi_ssid\""
117+
fi
118+
if [ -n "$wifi_password" ]; then
119+
wifi_args="$wifi_args --wifi-password \"$wifi_password\""
120+
fi
121+
114122
result=0
115-
printf "\033[95mpytest -s \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}"
116-
bash -c "set +e; pytest -s \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$?
123+
printf "\033[95mpytest -s \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}" "$wifi_args"
124+
bash -c "set +e; pytest -s \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q} $wifi_args; exit \$?" || result=$?
117125
printf "\n"
118126
if [ $result -ne 0 ]; then
119127
result=0
120128
printf "\033[95mRetrying test: %s -- Config: %s\033[0m\n" "$sketchname" "$i"
121-
printf "\033[95mpytest -s \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}"
122-
bash -c "set +e; pytest -s \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q}; exit \$?" || result=$?
129+
printf "\033[95mpytest -s \"%s/test_%s.py\" --build-dir \"%s\" --junit-xml=\"%s\" -o junit_suite_name=%s_%s_%s_%s%s %s %s\033[0m\n" "$sketchdir" "$sketchname" "$build_dir" "$report_file" "$test_type" "$platform" "$target" "$sketchname" "$i" "${extra_args[*]@Q}" "$wifi_args"
130+
bash -c "set +e; pytest -s \"$sketchdir/test_$sketchname.py\" --build-dir \"$build_dir\" --junit-xml=\"$report_file\" -o junit_suite_name=${test_type}_${platform}_${target}_${sketchname}${i} ${extra_args[*]@Q} $wifi_args; exit \$?" || result=$?
123131
printf "\n"
124132
if [ $result -ne 0 ]; then
125133
printf "\033[91mFailed test: %s -- Config: %s\033[0m\n\n" "$sketchname" "$i"
@@ -137,6 +145,8 @@ platform="hardware"
137145
chunk_run=0
138146
options=0
139147
erase=0
148+
wifi_ssid=""
149+
wifi_password=""
140150

141151
while [ -n "$1" ]; do
142152
case $1 in
@@ -188,6 +198,14 @@ while [ -n "$1" ]; do
188198
shift
189199
test_type=$1
190200
;;
201+
-wifi-ssid )
202+
shift
203+
wifi_ssid=$1
204+
;;
205+
-wifi-password )
206+
shift
207+
wifi_password=$1
208+
;;
191209
* )
192210
break
193211
;;

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
mkdir -p ${{ github.workspace }}/hosted
6969
7070
# Copy hosted binaries to proper directory without overwriting existing files
71-
cp -n ${{ github.workspace }}/hosted-latest/*.bin ${{ github.workspace }}/hosted/
71+
cp --update=none ${{ github.workspace }}/hosted-latest/*.bin ${{ github.workspace }}/hosted/
7272
7373
# Commit the changes
7474
git config user.name "github-actions[bot]"

.github/workflows/tests_hw_wokwi.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,14 @@ jobs:
361361
download_artifacts: 'true'
362362
download_artifacts_on_failure: 'true'
363363
download_path: './gitlab-artifacts'
364-
variables: '{"TEST_TYPES":"${{ steps.prepare-variables.outputs.test_types }}","TEST_CHIPS":"${{ steps.prepare-variables.outputs.test_chips }}","PIPELINE_ID":"${{ env.id }}","BINARIES_RUN_ID":"${{ github.event.workflow_run.id }}","GITHUB_REPOSITORY":"${{ github.repository }}"}'
364+
variables: >-
365+
{
366+
"TEST_TYPES":"${{ steps.prepare-variables.outputs.test_types }}",
367+
"TEST_CHIPS":"${{ steps.prepare-variables.outputs.test_chips }}",
368+
"PIPELINE_ID":"${{ env.id }}",
369+
"BINARIES_RUN_ID":"${{ github.event.workflow_run.id }}",
370+
"GITHUB_REPOSITORY":"${{ github.repository }}"
371+
}
365372
366373
- name: Process Downloaded Artifacts
367374
if: ${{ always() && steps.check-tests.outputs.enabled == 'true' }}
@@ -536,8 +543,11 @@ jobs:
536543
if: ${{ steps.check-tests.outputs.enabled == 'true' }}
537544
env:
538545
WOKWI_CLI_TOKEN: ${{ secrets.WOKWI_CLI_TOKEN }}
546+
WOKWI_WIFI_SSID: "Wokwi-GUEST"
547+
# The Wokwi Wi-Fi does not have a password, so we use an empty string
548+
WOKWI_WIFI_PASSWORD: ""
539549
run: |
540-
bash .github/scripts/tests_run.sh -c -type ${{ matrix.type }} -t ${{ matrix.chip }} -i 0 -m 1 -W
550+
bash .github/scripts/tests_run.sh -c -type "${{ matrix.type }}" -t "${{ matrix.chip }}" -i 0 -m 1 -W -wifi-ssid "${{ env.WOKWI_WIFI_SSID }}" -wifi-password "${{ env.WOKWI_WIFI_PASSWORD }}"
541551
542552
- name: Upload ${{ matrix.chip }} ${{ matrix.type }} Wokwi results as cache
543553
uses: actions/cache/save@5a3ec84eff668545956fd18022155c47e93e2684 # v4.2.3

.gitlab/workflows/hw_test_template.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ hw-test-template:
5050
[ -z "$d" ] && continue;
5151
sketch=$(basename "$d");
5252
echo Running $sketch in $d;
53-
bash .github/scripts/tests_run.sh -t $TEST_CHIP -s $sketch -e || rc=$?;
53+
bash .github/scripts/tests_run.sh -t "$TEST_CHIP" -s "$sketch" -e -wifi-ssid "$RUNNER_WIFI_SSID" -wifi-password "$RUNNER_WIFI_PASSWORD" || rc=$?;
5454
done <<< "$TEST_LIST"; exit $rc
5555
5656
artifacts:

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import pytest
2+
3+
4+
def pytest_addoption(parser):
5+
parser.addoption("--wifi-password", action="store", default=None, help="Wi-Fi password.")
6+
parser.addoption("--wifi-ssid", action="store", default=None, help="Wi-Fi SSID.")
7+
8+
9+
@pytest.fixture(scope="session")
10+
def wifi_ssid(request):
11+
return request.config.getoption("--wifi-ssid")
12+
13+
14+
@pytest.fixture(scope="session")
15+
def wifi_pass(request):
16+
return request.config.getoption("--wifi-password")
17+

tests/performance/ramspeed/ramspeed.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,8 +234,8 @@ void setup() {
234234
delay(10);
235235
}
236236

237-
void *dest = malloc(MAX_TEST_SIZE);
238-
const void *src = malloc(MAX_TEST_SIZE);
237+
void *dest = heap_caps_malloc(MAX_TEST_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
238+
const void *src = heap_caps_malloc(MAX_TEST_SIZE, MALLOC_CAP_8BIT | MALLOC_CAP_INTERNAL);
239239

240240
if (!dest || !src) {
241241
Serial.println("Memory allocation failed");

tests/pytest.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[pytest]
22
addopts = --embedded-services esp,arduino,wokwi,qemu
3+
junit_family = xunit1
4+
filterwarnings =
5+
ignore::pytest.PytestExperimentalApiWarning
36

47
# log related
58
log_cli = True

tests/validation/wifi/test_wifi.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,36 @@
11
import logging
2+
import pytest
23

34

4-
def test_wifi(dut):
5+
def test_wifi(dut, wifi_ssid, wifi_pass):
56
LOGGER = logging.getLogger(__name__)
67

8+
# Fail if no WiFi SSID is provided
9+
if not wifi_ssid:
10+
pytest.fail("WiFi SSID is required but not provided. Use --wifi-ssid argument.")
11+
12+
# Wait for device to be ready and send WiFi credentials
13+
LOGGER.info("Waiting for device to be ready...")
14+
dut.expect_exact("Device ready for WiFi credentials")
15+
16+
dut.expect_exact("Send SSID:")
17+
LOGGER.info(f"Sending WiFi credentials: SSID={wifi_ssid}")
18+
dut.write(f"{wifi_ssid}")
19+
20+
dut.expect_exact("Send Password:")
21+
LOGGER.info(f"Sending WiFi password: Password={wifi_pass}")
22+
dut.write(f"{wifi_pass or ''}")
23+
24+
# Verify credentials were received
25+
dut.expect_exact(f"SSID: {wifi_ssid}")
26+
dut.expect_exact(f"Password: {wifi_pass or ''}")
27+
728
LOGGER.info("Starting WiFi Scan")
829
dut.expect_exact("Scan start")
930
dut.expect_exact("Scan done")
10-
dut.expect_exact("Wokwi-GUEST")
31+
32+
LOGGER.info(f"Looking for WiFi network: {wifi_ssid}")
33+
dut.expect_exact(wifi_ssid)
1134
LOGGER.info("WiFi Scan done")
1235

1336
LOGGER.info("Connecting to WiFi")

tests/validation/wifi/wifi.ino

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@
3838

3939
#include <WiFi.h>
4040

41-
const char *ssid = "Wokwi-GUEST";
42-
const char *password = "";
41+
String ssid = "";
42+
String password = "";
4343

4444
// WARNING: This function is called from a separate FreeRTOS task (thread)!
4545
void WiFiEvent(WiFiEvent_t event) {
@@ -87,14 +87,56 @@ void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
8787
Serial.println(IPAddress(info.got_ip.ip_info.ip.addr));
8888
}
8989

90+
void readWiFiCredentials() {
91+
Serial.println("Waiting for WiFi credentials...");
92+
Serial.println("Send SSID:");
93+
94+
// Wait for SSID
95+
while (ssid.length() == 0) {
96+
if (Serial.available()) {
97+
ssid = Serial.readStringUntil('\n');
98+
ssid.trim();
99+
}
100+
delay(100);
101+
}
102+
103+
Serial.println("Send Password:");
104+
105+
// Wait for password (allow empty password)
106+
bool password_received = false;
107+
while (!password_received) {
108+
if (Serial.available()) {
109+
password = Serial.readStringUntil('\n');
110+
password.trim();
111+
password_received = true; // Accept even empty password
112+
}
113+
delay(100);
114+
}
115+
116+
Serial.print("SSID: ");
117+
Serial.println(ssid);
118+
Serial.print("Password: ");
119+
Serial.println(password);
120+
}
121+
90122
void setup() {
91123
Serial.begin(115200);
92124

125+
while (!Serial) {
126+
delay(100);
127+
}
128+
93129
// delete old config
94130
WiFi.disconnect(true);
95131

96132
delay(1000);
97133

134+
// Wait for test to be ready
135+
Serial.println("Device ready for WiFi credentials");
136+
137+
// Read WiFi credentials from serial
138+
readWiFiCredentials();
139+
98140
// Examples of different ways to register wifi events;
99141
// these handlers will be called from another thread.
100142
WiFi.onEvent(WiFiEvent);
@@ -134,7 +176,7 @@ void setup() {
134176
// Delete the scan result to free memory for code below.
135177
WiFi.scanDelete();
136178

137-
WiFi.begin(ssid, password);
179+
WiFi.begin(ssid.c_str(), password.c_str());
138180

139181
Serial.println();
140182
Serial.println();

0 commit comments

Comments
 (0)