From 31d1b1c75ca1e09fad96066bc882a601540a96e5 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Wed, 16 Feb 2022 11:16:54 +0100 Subject: [PATCH 1/9] on-push.sh: Use the SCRIPTS_DIR variable when possible. Signed-off-by: Abdelatif Guettouche --- .github/scripts/on-push.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/scripts/on-push.sh b/.github/scripts/on-push.sh index 5d8ffe9cd3e..6e92b9be88f 100755 --- a/.github/scripts/on-push.sh +++ b/.github/scripts/on-push.sh @@ -58,7 +58,7 @@ fi SCRIPTS_DIR="./.github/scripts" if [ "$BUILD_PIO" -eq 0 ]; then - source ./.github/scripts/install-arduino-ide.sh + source ${SCRIPTS_DIR}/install-arduino-ide.sh source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" @@ -80,7 +80,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then build "esp32s2" $FQBN_ESP32S2 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX else - source ./${SCRIPTS_DIR}/install-platformio-esp32.sh + source ${SCRIPTS_DIR}/install-platformio-esp32.sh # PlatformIO ESP32 Test BOARD="esp32dev" OPTIONS="board_build.partitions = huge_app.csv" From 3818f0a9af3a2abf2a6a47bb32160b260ba78e44 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Wed, 16 Feb 2022 11:44:02 +0100 Subject: [PATCH 2/9] Add test workflow and necessary scripts. Signed-off-by: Abdelatif Guettouche --- .github/scripts/tests_build.sh | 34 ++++++++++++ .github/scripts/tests_run.sh | 71 +++++++++++++++++++++++++ .github/workflows/hil.yml | 76 +++++++++++++++++++++++++++ .gitignore | 3 ++ tests/.gitignore | 2 + tests/hello_world/hello_world.ino | 12 +++++ tests/hello_world/test_hello_world.py | 2 + tests/pytest.ini | 13 +++++ tests/requirements.txt | 13 +++++ tests/serial/serial.ino | 12 +++++ tests/serial/test_serial.py | 2 + 11 files changed, 240 insertions(+) create mode 100755 .github/scripts/tests_build.sh create mode 100755 .github/scripts/tests_run.sh create mode 100644 .github/workflows/hil.yml create mode 100644 tests/.gitignore create mode 100644 tests/hello_world/hello_world.ino create mode 100644 tests/hello_world/test_hello_world.py create mode 100644 tests/pytest.ini create mode 100644 tests/requirements.txt create mode 100644 tests/serial/serial.ino create mode 100644 tests/serial/test_serial.py diff --git a/.github/scripts/tests_build.sh b/.github/scripts/tests_build.sh new file mode 100755 index 00000000000..3ab2ad26946 --- /dev/null +++ b/.github/scripts/tests_build.sh @@ -0,0 +1,34 @@ +#!/bin/bash + +target=$1 +chunk_index=$2 +chunk_max=$3 + +if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then + chunk_index=$chunk_max +fi + +case "$target" in + "esp32") fqbn="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" + ;; + "esp32s2") fqbn="espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app" + ;; + "esp32c3") fqbn="espressif:esp32:esp32c3:PartitionScheme=huge_app" + ;; +esac + +if [ -z $fqbn ]; then + echo "Unvalid chip $1" + exit 0 +fi + +SCRIPTS_DIR="./.github/scripts" +BUILD_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" + +source ${SCRIPTS_DIR}/install-arduino-ide.sh +source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh + +args="$ARDUINO_IDE_PATH $ARDUINO_USR_PATH" +args+=" \"$fqbn\" $target $PWD/tests $chunk_index $chunk_max" +${BUILD_SKETCHES} ${args} + diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh new file mode 100755 index 00000000000..3f77f23cf07 --- /dev/null +++ b/.github/scripts/tests_run.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +target=$1 +chunk_idex=$2 +chunks_num=$3 + +SCRIPTS_DIR="./.github/scripts" +COUNT_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh count" + +source ${SCRIPTS_DIR}/install-arduino-ide.sh + +if [ "$chunks_num" -le 0 ]; then + echo "ERROR: Chunks count must be positive number" + return 1 +fi +if [ "$chunk_idex" -ge "$chunks_num" ] && [ "$chunks_num" -ge 2 ]; then + echo "ERROR: Chunk index must be less than chunks count" + return 1 +fi + +set +e +${COUNT_SKETCHES} $PWD/tests $target +sketchcount=$? +set -e +sketches=$(cat sketches.txt) +rm -rf sketches.txt + +chunk_size=$(( $sketchcount / $chunks_num )) +all_chunks=$(( $chunks_num * $chunk_size )) +if [ "$all_chunks" -lt "$sketchcount" ]; then + chunk_size=$(( $chunk_size + 1 )) +fi + +start_index=0 +end_index=0 +if [ "$chunk_idex" -ge "$chunks_num" ]; then + start_index=$chunk_idex + end_index=$sketchcount +else + start_index=$(( $chunk_idex * $chunk_size )) + if [ "$sketchcount" -le "$start_index" ]; then + echo "Skipping job" + return 0 + fi + + end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size )) + if [ "$end_index" -gt "$sketchcount" ]; then + end_index=$sketchcount + fi +fi + +start_num=$(( $start_index + 1 )) +sketchnum=0 + +for sketch in $sketches; do + sketchdir=$(dirname $sketch) + sketchdirname=$(basename $sketchdir) + sketchname=$(basename $sketch) + sketchnum=$(($sketchnum + 1)) + if [ "$sketchnum" -le "$start_index" ] \ + || [ "$sketchnum" -gt "$end_index" ]; then + continue + fi + echo "" + echo "Test for Sketch Index $(($sketchnum - 1)) - $sketchdirname" + pytest tests -k test_$sketchdirname + result=$? + if [ $result -ne 0 ]; then + return $result + fi +done diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml new file mode 100644 index 00000000000..c866ca3502a --- /dev/null +++ b/.github/workflows/hil.yml @@ -0,0 +1,76 @@ +name: Run tests in hardware + +on: + pull_request: + types: [opened, reopened, synchronize, labeled] + +# schedule: +# - cron: '0 2 * * *' + +env: + MAX_CHUNKS: 15 + +concurrency: + group: hil-${{github.event.pull_request.number || github.ref}} + cancel-in-progress: true + +jobs: + Build: + if: contains(github.event.pull_request.labels.*.name, 'hil_test') + name: ${{matrix.chip}}-Build#${{matrix.chunks}} + runs-on: ubuntu-latest + strategy: + matrix: + chip: ['esp32', 'esp32s2', 'esp32c3'] + chunks: [0, 1, 2, 3] + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Build sketches + run: | + bash .github/scripts/tests_build.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}} + - name: Upload ${{matrix.chip}}-${{matrix.chunks}} artifacts + uses: actions/upload-artifact@v2 + with: + name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts + path: | + tests/*/build/*.bin + tests/*/build/*.json + Test: + needs: Build + name: ${{matrix.chip}}-Test#${{matrix.chunks}} + runs-on: ESP32 + strategy: + fail-fast: false + matrix: + chip: ['esp32', 'esp32s2', 'esp32c3'] + chunks: [0, 1, 2, 3] + container: + image: python:3.10.1-bullseye + options: --privileged + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Download ${{matrix.chip}}-${{matrix.chunks}} artifacts + uses: actions/download-artifact@v2 + with: + name: ${{matrix.chip}}-${{matrix.chunks}}.artifacts + path: tests/ + + - name: Check Artifacts + run: | + ls -R tests + cat tests/*/build/build.options.json + + - name: Install dependencies + run: | + pip install -U pip + pip install -r tests/requirements.txt + + - name: Run Tests + run: | + bash .github/scripts/tests_run.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}} diff --git a/.gitignore b/.gitignore index 5114d19da5c..df9c98da7a5 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ boards.sloeber.txt # Ignore docs build (Sphinx) docs/build docs/source/_build + +# Test log files +*.log diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 00000000000..3d433392930 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1,2 @@ +build/ +__pycache__/ diff --git a/tests/hello_world/hello_world.ino b/tests/hello_world/hello_world.ino new file mode 100644 index 00000000000..0cc110d42a5 --- /dev/null +++ b/tests/hello_world/hello_world.ino @@ -0,0 +1,12 @@ +void setup(){ + // Open serial communications and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; + } + + Serial.println("Hello Arduino!"); +} + +void loop(){ +} diff --git a/tests/hello_world/test_hello_world.py b/tests/hello_world/test_hello_world.py new file mode 100644 index 00000000000..f7ed50cde40 --- /dev/null +++ b/tests/hello_world/test_hello_world.py @@ -0,0 +1,2 @@ +def test_hello_world(dut): + dut.expect('Hello Arduino!') diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 00000000000..ef7e6d7c5ae --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,13 @@ +[pytest] +addopts = --embedded-services esp,arduino + +# log related +log_cli = True +log_cli_level = INFO +log_cli_format = %(asctime)s %(levelname)s %(message)s +log_cli_date_format = %Y-%m-%d %H:%M:%S + +log_file = test.log +log_file_level = INFO +log_file_format = %(asctime)s %(levelname)s %(message)s +log_file_date_format = %Y-%m-%d %H:%M:%S diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 00000000000..c4095ef6c49 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,13 @@ +pyserial>=3.0 +esptool>=3.1 +pytest-cov +cryptography<3.4; platform_machine == "armv7l" + +pytest>=6.2.0 +pexpect>=4.4 + +pytest-embedded>=0.5.1 +pytest-embedded-serial>=0.5.1 +pytest-embedded-serial-esp>=0.5.1 +pytest-embedded-arduino>=0.5.1 + diff --git a/tests/serial/serial.ino b/tests/serial/serial.ino new file mode 100644 index 00000000000..7baec2ed0ba --- /dev/null +++ b/tests/serial/serial.ino @@ -0,0 +1,12 @@ +void setup(){ + // Open serial communications and wait for port to open: + Serial.begin(115200); + while (!Serial) { + ; + } + + Serial.println("Hello Serial!"); +} + +void loop(){ +} diff --git a/tests/serial/test_serial.py b/tests/serial/test_serial.py new file mode 100644 index 00000000000..75422e0b934 --- /dev/null +++ b/tests/serial/test_serial.py @@ -0,0 +1,2 @@ +def test_serial(dut): + dut.expect('Hello Serial!') From 28e3ea54022a33c806650754c42a8c7547e616ec Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Sun, 20 Feb 2022 22:05:15 +0100 Subject: [PATCH 3/9] sketch_utils.sh: Sort the result of `find` to have the same output on all plateforms. Signed-off-by: Abdelatif Guettouche --- .github/scripts/sketch_utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index abc6a0476e5..c1f70fea7aa 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -47,7 +47,7 @@ function count_sketches(){ # count_sketches return 0 fi - local sketches=$(find $path -name *.ino) + local sketches=$(find $path -name *.ino | sort) local sketchnum=0 for sketch in $sketches; do local sketchdir=$(dirname $sketch) From fa3929ba291e06feec875a32032d57ef028c9e42 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Mon, 21 Feb 2022 11:48:01 +0100 Subject: [PATCH 4/9] sketch_utils.sh: Make the `target` argument optional. This will allow using the function to count all sketches present in a directory. Signed-off-by: Abdelatif Guettouche --- .github/scripts/sketch_utils.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/sketch_utils.sh b/.github/scripts/sketch_utils.sh index c1f70fea7aa..d8e4aead5a4 100755 --- a/.github/scripts/sketch_utils.sh +++ b/.github/scripts/sketch_utils.sh @@ -32,13 +32,13 @@ function build_sketch(){ # build_sketch +function count_sketches(){ # count_sketches [target] local path=$1 local target=$2 - if [ $# -lt 2 ]; then + if [ $# -lt 1 ]; then echo "ERROR: Illegal number of parameters" - echo "USAGE: ${0} count " + echo "USAGE: ${0} count [target]" fi rm -rf sketches.txt @@ -55,7 +55,7 @@ function count_sketches(){ # count_sketches local sketchname=$(basename $sketch) if [[ "$sketchdirname.ino" != "$sketchname" ]]; then continue - elif [[ -f "$sketchdir/.skip.$target" ]]; then + elif [[ -n $target ]] && [[ -f "$sketchdir/.skip.$target" ]]; then continue else echo $sketch >> sketches.txt From 9c6751d4901e7d71fd27e6addf6e0e074d5ca9e1 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Mon, 21 Feb 2022 11:49:05 +0100 Subject: [PATCH 5/9] hil.yml: Generate the chunk matrix based on how many sketches there are in a given folder. Signed-off-by: Abdelatif Guettouche --- .github/workflows/hil.yml | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index c866ca3502a..9292c614ff9 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -15,14 +15,38 @@ concurrency: cancel-in-progress: true jobs: - Build: + gen_chunks: if: contains(github.event.pull_request.labels.*.name, 'hil_test') + name: Generate Chunks matrix + runs-on: ubuntu-latest + outputs: + chunks: ${{ steps.gen-chunks.outputs.chunks }} + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Generate Chunks matrix + id: gen-chunks + run: | + set +e + bash .github/scripts/sketch_utils.sh count tests + sketches=$((? - 1)) + if [[ $sketches -gt ${{env.MAX_CHUNKS}} ]]; then + $sketches=${{env.MAX_CHUNKS}} + fi + set -e + rm sketches.txt + CHUNKS=$(jq -c -n '$ARGS.positional' --args `seq 0 1 $sketches`) + echo "::set-output name=chunks::${CHUNKS}" + + Build: + needs: gen_chunks name: ${{matrix.chip}}-Build#${{matrix.chunks}} runs-on: ubuntu-latest strategy: matrix: chip: ['esp32', 'esp32s2', 'esp32c3'] - chunks: [0, 1, 2, 3] + chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} steps: - name: Checkout Repository @@ -39,14 +63,14 @@ jobs: tests/*/build/*.bin tests/*/build/*.json Test: - needs: Build + needs: [gen_chunks, Build] name: ${{matrix.chip}}-Test#${{matrix.chunks}} runs-on: ESP32 strategy: fail-fast: false matrix: chip: ['esp32', 'esp32s2', 'esp32c3'] - chunks: [0, 1, 2, 3] + chunks: ${{fromJson(needs.gen_chunks.outputs.chunks)}} container: image: python:3.10.1-bullseye options: --privileged From bfbbf0567a62355d63b8f557d7c8464d6b89f4b3 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Tue, 8 Mar 2022 16:57:00 +0100 Subject: [PATCH 6/9] tests_build.sh: Update the script to be able to build one skecth at a time. Signed-off-by: Abdelatif Guettouche --- .github/scripts/tests_build.sh | 46 +++++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/.github/scripts/tests_build.sh b/.github/scripts/tests_build.sh index 3ab2ad26946..6de547d371b 100755 --- a/.github/scripts/tests_build.sh +++ b/.github/scripts/tests_build.sh @@ -1,13 +1,23 @@ #!/bin/bash -target=$1 -chunk_index=$2 -chunk_max=$3 - -if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then - chunk_index=$chunk_max +SCRIPTS_DIR="./.github/scripts" +BUILD_CMD="" + +if [ $# -eq 3 ]; then + chunk_build=1 +elif [ $# -eq 2 ]; then + chunk_build=0 +else + echo "ERROR: Illegal number of parameters" + echo "USAGE: + ${0} + ${0} + " + exit 0 fi +target=$1 + case "$target" in "esp32") fqbn="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app" ;; @@ -22,13 +32,25 @@ if [ -z $fqbn ]; then exit 0 fi -SCRIPTS_DIR="./.github/scripts" -BUILD_SKETCHES="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" - source ${SCRIPTS_DIR}/install-arduino-ide.sh source ${SCRIPTS_DIR}/install-arduino-core-esp32.sh -args="$ARDUINO_IDE_PATH $ARDUINO_USR_PATH" -args+=" \"$fqbn\" $target $PWD/tests $chunk_index $chunk_max" -${BUILD_SKETCHES} ${args} +args="$ARDUINO_IDE_PATH $ARDUINO_USR_PATH \"$fqbn\"" + +if [ $chunk_build -eq 1 ]; then + chunk_index=$2 + chunk_max=$3 + + if [ "$chunk_index" -gt "$chunk_max" ] && [ "$chunk_max" -ge 2 ]; then + chunk_index=$chunk_max + fi + BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh chunk_build" + args+=" $target $PWD/tests $chunk_index $chunk_max" +else + sketchdir=$2 + BUILD_CMD="${SCRIPTS_DIR}/sketch_utils.sh build" + args+=" $PWD/tests/$sketchdir/$sketchdir.ino" +fi + +${BUILD_CMD} ${args} From c61faaf3d954e22204297e750b0ee4bd72556f62 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Tue, 8 Mar 2022 17:20:25 +0100 Subject: [PATCH 7/9] hil.yml: Enable the workflow on scheduled event. Signed-off-by: Abdelatif Guettouche --- .github/workflows/hil.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index 9292c614ff9..eee7364b11a 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -4,8 +4,8 @@ on: pull_request: types: [opened, reopened, synchronize, labeled] -# schedule: -# - cron: '0 2 * * *' + schedule: + - cron: '0 2 * * *' env: MAX_CHUNKS: 15 @@ -16,7 +16,9 @@ concurrency: jobs: gen_chunks: - if: contains(github.event.pull_request.labels.*.name, 'hil_test') + if: | + contains(github.event.pull_request.labels.*.name, 'hil_test') || + github.event_name == 'schedule' name: Generate Chunks matrix runs-on: ubuntu-latest outputs: From 81537da8f7126d403ad37f0090cc269595ac0cd4 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Tue, 8 Mar 2022 18:33:44 +0100 Subject: [PATCH 8/9] tests: Remove the dummy serial test and replace it with a (dummy) Unity test. Signed-off-by: Abdelatif Guettouche --- tests/serial/serial.ino | 12 ------------ tests/serial/test_serial.py | 2 -- tests/unity/test_unity.py | 2 ++ tests/unity/unity.ino | 33 +++++++++++++++++++++++++++++++++ 4 files changed, 35 insertions(+), 14 deletions(-) delete mode 100644 tests/serial/serial.ino delete mode 100644 tests/serial/test_serial.py create mode 100644 tests/unity/test_unity.py create mode 100644 tests/unity/unity.ino diff --git a/tests/serial/serial.ino b/tests/serial/serial.ino deleted file mode 100644 index 7baec2ed0ba..00000000000 --- a/tests/serial/serial.ino +++ /dev/null @@ -1,12 +0,0 @@ -void setup(){ - // Open serial communications and wait for port to open: - Serial.begin(115200); - while (!Serial) { - ; - } - - Serial.println("Hello Serial!"); -} - -void loop(){ -} diff --git a/tests/serial/test_serial.py b/tests/serial/test_serial.py deleted file mode 100644 index 75422e0b934..00000000000 --- a/tests/serial/test_serial.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_serial(dut): - dut.expect('Hello Serial!') diff --git a/tests/unity/test_unity.py b/tests/unity/test_unity.py new file mode 100644 index 00000000000..a5a391cc5af --- /dev/null +++ b/tests/unity/test_unity.py @@ -0,0 +1,2 @@ +def test_unity(dut): + dut.expect_unity_test_output(timeout=240) diff --git a/tests/unity/unity.ino b/tests/unity/unity.ino new file mode 100644 index 00000000000..f367fe8bebc --- /dev/null +++ b/tests/unity/unity.ino @@ -0,0 +1,33 @@ +#include + + +/* These functions are intended to be called before and after each test. */ +void setUp(void) { +} + +void tearDown(void){ +} + + +void test_pass(void){ + TEST_ASSERT_EQUAL(1, 1); +} + +void test_fail(void){ + TEST_ASSERT_EQUAL(1, 0); +} + +void setup() { + Serial.begin(115200); + while (!Serial) { + ; + } + + UNITY_BEGIN(); + RUN_TEST(test_pass); + RUN_TEST(test_fail); + UNITY_END(); +} + +void loop() { +} From 05261ca63fec1e71959b063cc38e67ca75166bb5 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Tue, 8 Mar 2022 18:45:00 +0100 Subject: [PATCH 9/9] .github: Generate XML files for the tests and publish the results as a PR comment. Signed-off-by: Abdelatif Guettouche --- .github/scripts/tests_run.sh | 2 +- .github/workflows/hil.yml | 18 +++++++++++++++++ .github/workflows/publish.yml | 38 +++++++++++++++++++++++++++++++++++ tests/unity/unity.ino | 2 +- 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/publish.yml diff --git a/.github/scripts/tests_run.sh b/.github/scripts/tests_run.sh index 3f77f23cf07..a13f3c00c1d 100755 --- a/.github/scripts/tests_run.sh +++ b/.github/scripts/tests_run.sh @@ -63,7 +63,7 @@ for sketch in $sketches; do fi echo "" echo "Test for Sketch Index $(($sketchnum - 1)) - $sketchdirname" - pytest tests -k test_$sketchdirname + pytest tests -k test_$sketchdirname --junit-xml=tests/$sketchdirname/$sketchdirname.xml result=$? if [ $result -ne 0 ]; then return $result diff --git a/.github/workflows/hil.yml b/.github/workflows/hil.yml index eee7364b11a..b55e686c58e 100644 --- a/.github/workflows/hil.yml +++ b/.github/workflows/hil.yml @@ -100,3 +100,21 @@ jobs: - name: Run Tests run: | bash .github/scripts/tests_run.sh ${{matrix.chip}} ${{matrix.chunks}} ${{env.MAX_CHUNKS}} + + - name: Upload test result artifacts + uses: actions/upload-artifact@v2 + if: always() + with: + name: test_results-${{matrix.chip}}-${{matrix.chunks}} + path: tests/*/*.xml + + event_file: + name: "Event File" + needs: Test + runs-on: ubuntu-latest + steps: + - name: Upload + uses: actions/upload-artifact@v2 + with: + name: Event File + path: ${{github.event_path}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000000..686ce2f2380 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,38 @@ +name: Unit Test Results + +on: + workflow_run: + workflows: [Run tests in hardware] + + types: + - completed + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + + steps: + - name: Debug Action + uses: hmarr/debug-action@v2.0.0 + + unit-test-results: + name: Unit Test Results + runs-on: ubuntu-latest + steps: + - name: Download and Extract Artifacts + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + run: | + mkdir -p artifacts && cd artifacts + artifacts_url=${{ github.event.workflow_run.artifacts_url }} + gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact + do + IFS=$'\t' read name url <<< "$artifact" + gh api $url > "$name.zip" + unzip -d "$name" "$name.zip" + done + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + commit: ${{ github.event.workflow diff --git a/tests/unity/unity.ino b/tests/unity/unity.ino index f367fe8bebc..2a1c131ca74 100644 --- a/tests/unity/unity.ino +++ b/tests/unity/unity.ino @@ -14,7 +14,7 @@ void test_pass(void){ } void test_fail(void){ - TEST_ASSERT_EQUAL(1, 0); + TEST_ASSERT_EQUAL(1, 1); } void setup() {