Skip to content

Commit 8cbf4ab

Browse files
committed
CI: Add script to run all tests locally
1 parent dd445a0 commit 8cbf4ab

File tree

3 files changed

+83
-1
lines changed

3 files changed

+83
-1
lines changed

extras/README.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
This folder contains files that are not directly part of the library.
44

5+
## CI – Continuous Integration
6+
7+
The [ci](ci) folder contains scripts and data used for automated testing.
8+
59
## Documentation
610

711
The [docs](docs/) folder contains documentation about the internal structure
@@ -49,4 +53,4 @@ unsigned char example_key_DER[] = {
4953
};
5054
unsigned int example_key_DER_len = 608;
5155

52-
```
56+
```

extras/ci/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Testing and Continuous Integration
2+
3+
This folder contains the scripts and data that is used to run the tests that are specified in the GitHub Action workflows.
4+
5+
The structure of this folder is as follows:
6+
7+
- **apps** contains applications that are used during CI testing
8+
- **scripts** contains scripts and tools that are part of the workflows
9+
- **templates** contains project skeletons etc. used for testing
10+
- **tests** contains test suites written in Python which run against real hardware
11+
12+
## Run Tests Locally
13+
14+
You can (and should) run tests on your local machine before submitting an PR.
15+
16+
System Requirements
17+
18+
- A recent, Linux-based OS (it might work on macOS, too)
19+
- Python 3 installed (`sudo apt-get install python3` on Debian or Ubuntu)
20+
- Platform IO on your `PATH` (`source ~/.platformio/penv/bin/activate` if you're using an IDE like VSCode)
21+
- For the hardware checks: An ESP32 development board connected to your machine and a WiFi access point shared between you and the ESP32
22+
23+
### Build Examples
24+
25+
You can use `extras/ci/scripts/build-example.sh <"wroom"|"wrover"> <example-name>` to build a specific example.
26+
The main purpose of this is to check that everything still compiles as intended.
27+
The script will only try to build the example, but it will not flash it.
28+
The project folder is created in `tmp/<example-name>-<board-name>` in the root of the repositry.
29+
If you want, you can run `pio run -t upload -e <"wroom"|"wrover">` in these project directories to upload the example to a board.
30+
31+
To build all examples (and to check that everything works), there is a script for manual testing: `extras/ci/scripts/build-example.sh`
32+
33+
### Run Tests on Hardware
34+
35+
(tbd)
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
3+
# Find the script and repository location based on the current script location
4+
SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
5+
REPODIR=$(cd "$(dirname $SCRIPTDIR/../../../..)" && pwd)
6+
7+
TOTAL_TESTS=0
8+
FAILED_TESTS=0
9+
OK_TESTS=0
10+
11+
EXAMPLES_SUCCESS=()
12+
EXAMPLES_FAILURE=()
13+
for BOARD in wrover wroom; do
14+
for EXAMPLENAME in $(ls "$REPODIR/examples"); do
15+
if [ -d "$REPODIR/examples/$EXAMPLENAME" ] && [ -f "$REPODIR/examples/$EXAMPLENAME/$EXAMPLENAME.ino" ]; then
16+
$SCRIPTDIR/build-example.sh "$BOARD" "$EXAMPLENAME"
17+
RC=$?
18+
TOTAL_TESTS=$[ TOTAL_TESTS + 1 ]
19+
if [[ "$RC" == "0" ]]; then
20+
OK_TESTS=$[ OK_TESTS + 1 ]
21+
EXAMPLES_SUCCESS+=("$EXAMPLENAME ($BOARD)")
22+
else
23+
FAILED_TESTS=$[ FAILED_TESTS + 1 ]
24+
EXAMPLES_FAILURE+=("$EXAMPLENAME ($BOARD)")
25+
fi
26+
fi
27+
done # example loop
28+
done # board loop
29+
30+
echo "Summary: $OK_TESTS/$TOTAL_TESTS succeeded"
31+
echo "-----------------------------------------"
32+
for exmpl in "${EXAMPLES_SUCCESS[@]}"; do
33+
printf " \u2714 $exmpl\n"
34+
done
35+
for exmpl in "${EXAMPLES_FAILURE[@]}"; do
36+
printf " \u274c $exmpl\n"
37+
done
38+
if [[ "$FAILED_TESTS" != "0" ]]; then
39+
echo "$FAILED_TESTS Tests failed."
40+
exit 1
41+
else
42+
echo "Success."
43+
fi

0 commit comments

Comments
 (0)