Skip to content

Commit 5ab1db6

Browse files
fix(ci): Fix tests and workflows (#12024)
* fix(ci): Fix tests and workflows * feat(tests): Add job ID fixture * fix(tests): Fix performance test result generation * ci(pre-commit): Apply automatic fixes --------- Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
1 parent a90a523 commit 5ab1db6

File tree

16 files changed

+147
-22
lines changed

16 files changed

+147
-22
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: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import pytest
2+
import os
3+
4+
5+
def pytest_addoption(parser):
6+
parser.addoption("--wifi-password", action="store", default=None, help="Wi-Fi password.")
7+
parser.addoption("--wifi-ssid", action="store", default=None, help="Wi-Fi SSID.")
8+
9+
10+
@pytest.fixture(scope="session")
11+
def wifi_ssid(request):
12+
return request.config.getoption("--wifi-ssid")
13+
14+
15+
@pytest.fixture(scope="session")
16+
def wifi_pass(request):
17+
return request.config.getoption("--wifi-password")
18+
19+
20+
@pytest.fixture(scope="session")
21+
def ci_job_id(request):
22+
return os.environ.get("CI_JOB_ID")

tests/performance/coremark/test_coremark.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,14 @@ def test_coremark(dut, request):
4545
results = {"coremark": {"runs": runs, "cores": cores, "avg_score": avg_score}}
4646

4747
current_folder = os.path.dirname(request.path)
48+
os.makedirs(os.path.join(current_folder, dut.app.target), exist_ok=True)
4849
file_index = 0
4950
report_file = os.path.join(current_folder, dut.app.target, "result_coremark" + str(file_index) + ".json")
5051
while os.path.exists(report_file):
5152
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
5253
file_index += 1
5354

54-
with open(report_file, "w") as f:
55+
with open(report_file, "w+") as f:
5556
try:
5657
f.write(json.dumps(results))
5758
except Exception as e:

tests/performance/fibonacci/test_fibonacci.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,14 @@ def test_fibonacci(dut, request):
6767
results = {"fibonacci": {"runs": runs, "fib_n": fib_n, "avg_time": avg_time}}
6868

6969
current_folder = os.path.dirname(request.path)
70+
os.makedirs(os.path.join(current_folder, dut.app.target), exist_ok=True)
7071
file_index = 0
7172
report_file = os.path.join(current_folder, dut.app.target, "result_fibonacci" + str(file_index) + ".json")
7273
while os.path.exists(report_file):
7374
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
7475
file_index += 1
7576

76-
with open(report_file, "w") as f:
77+
with open(report_file, "w+") as f:
7778
try:
7879
f.write(json.dumps(results))
7980
except Exception as e:

tests/performance/linpack_double/test_linpack_double.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ def test_linpack_double(dut, request):
4848
results = {"linpack_double": {"runs": runs, "avg_score": avg_score, "min_score": min_score, "max_score": max_score}}
4949

5050
current_folder = os.path.dirname(request.path)
51+
os.makedirs(os.path.join(current_folder, dut.app.target), exist_ok=True)
5152
file_index = 0
5253
report_file = os.path.join(current_folder, dut.app.target, "result_linpack_double" + str(file_index) + ".json")
5354
while os.path.exists(report_file):
5455
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
5556
file_index += 1
5657

57-
with open(report_file, "w") as f:
58+
with open(report_file, "w+") as f:
5859
try:
5960
f.write(json.dumps(results))
6061
except Exception as e:

tests/performance/linpack_float/test_linpack_float.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,14 @@ def test_linpack_float(dut, request):
4848
results = {"linpack_float": {"runs": runs, "avg_score": avg_score, "min_score": min_score, "max_score": max_score}}
4949

5050
current_folder = os.path.dirname(request.path)
51+
os.makedirs(os.path.join(current_folder, dut.app.target), exist_ok=True)
5152
file_index = 0
5253
report_file = os.path.join(current_folder, dut.app.target, "result_linpack_float" + str(file_index) + ".json")
5354
while os.path.exists(report_file):
5455
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
5556
file_index += 1
5657

57-
with open(report_file, "w") as f:
58+
with open(report_file, "w+") as f:
5859
try:
5960
f.write(json.dumps(results))
6061
except Exception as e:

tests/performance/psramspeed/test_psramspeed.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,14 @@ def test_psramspeed(dut, request):
9292
results = {"psramspeed": {"runs": runs, "copies": copies, "max_test_size": max_test_size, "results": avg_results}}
9393

9494
current_folder = os.path.dirname(request.path)
95+
os.makedirs(os.path.join(current_folder, dut.app.target), exist_ok=True)
9596
file_index = 0
9697
report_file = os.path.join(current_folder, dut.app.target, "result_psramspeed" + str(file_index) + ".json")
9798
while os.path.exists(report_file):
9899
report_file = report_file.replace(str(file_index) + ".json", str(file_index + 1) + ".json")
99100
file_index += 1
100101

101-
with open(report_file, "w") as f:
102+
with open(report_file, "w+") as f:
102103
try:
103104
f.write(json.dumps(results))
104105
except Exception as e:

0 commit comments

Comments
 (0)