diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 93d2cd1..a1d0433 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,9 +18,6 @@ jobs: - Linux - PSoC - # which combination of sample code and boards should run - # for this example of 2 sample codes and 3 boards a total of 2x3=6 runners have to work. - # if we have only 4 runner then these 4 are started and the last 2 are waiting until they can start strategy: matrix: @@ -31,7 +28,6 @@ jobs: # board packages we want to run # attention the matrix spans over the fqbn not platform so that we can choose different boards - # this example compiles each sample code for Arduino Uno, XMC2Go and XMC4700 boards fqbn: [ "infineon:psoc:cy8ckit_062s2_ai" ] @@ -70,22 +66,6 @@ jobs: kill $(cat server.pid) rm server.pid - - name: Remove latest installed platform version - run: | - cd ~/.arduino15/packages/infineon/hardware/psoc - rm -rf * - - - name: copy/link repository to arduino path - run: | - mkdir ~/.arduino15/packages/infineon/hardware/psoc/0.0.0 - cp -a ./* ~/.arduino15/packages/infineon/hardware/psoc/0.0.0 - cd ~/.arduino15/packages/infineon/hardware/psoc/0.0.0 - - - name: copy/link arduino core api path - run: | - mkdir ~/.arduino15/packages/infineon/hardware/psoc/0.0.0/cores/psoc/api - cp -a ~/.arduino15/packages/infineon/hardware/psoc/0.0.0/extras/arduino-core-api/api/* ~/.arduino15/packages/infineon/hardware/psoc/0.0.0/cores/psoc/api - # Compile the sample code for the selected board and board support package with the arduino compiler - name: Compile Sketch run: | diff --git a/.github/workflows/hil_unity_checks.yml b/.github/workflows/hil_unity_checks.yml new file mode 100644 index 0000000..1013f35 --- /dev/null +++ b/.github/workflows/hil_unity_checks.yml @@ -0,0 +1,165 @@ +name: Hil unity library checks + +# on which event should we start push, pull request or schedule dispatches +on: + - push + - pull_request + +env: + TEST_VERSION: 1.0.0 + +jobs: + + # The build job compiles the sample code for different boards + tests: + + ############################################################################# + # This action sets common variables for the flow and + # identifies the libs to compile + runs-on: + - self-hosted + - X64 + - Linux + - PSoC + + # which combination of sample code and boards should run + # for this example of 2 sample codes and 3 boards a total of 2x3=6 runners have to work. + # if we have only 4 runner then these 4 are started and the last 2 are waiting until they can start + strategy: + + matrix: + # List of all examples in the lib to compile + example: [ + examples/testSketch/testSketch.ino + ] + + # board packages we want to run + # attention the matrix spans over the fqbn not platform so that we can choose different boards + # this example compiles each sample code for Arduino Uno, XMC2Go and XMC4700 boards + fqbn: [ + "infineon:psoc:cy8ckit_062s2_ai" + ] + + # include additional information for each fqbn, in this case the platform name to install + include: + - fqbn: "infineon:psoc:cy8ckit_062s2_ai" + platform: "infineon:psoc" + + # These are the steps which should run for each combination of fqbn and example code + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + with: + submodules: true + + - name: Generate package json + run: | + python ./tools/release.py build-local + + - name: Start local HTTP server + run: | + cd pkg_build + nohup python -m http.server 8000 & echo $! > server.pid + + - name: Install/Update Arduino Platform + run: | + arduino-cli core update-index + arduino-cli core install ${{ matrix.platform }} --additional-urls http://localhost:8000/package_psoc_index.json + arduino-cli core list + + - name: Kill local HTTP server + run: | + cd pkg_build + kill $(cat server.pid) + rm server.pid + + - name: Remove latest installed platform version + run: | + cd ~/.arduino15/packages/infineon/hardware/psoc + rm -rf * + + - name: copy/link repository to arduino path + run: | + mkdir ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION + cp -a ./* ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION + cd ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION + + - name: copy/link arduino core api path + run: | + mkdir ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/cores/psoc/api + cp -a ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/extras/arduino-core-api/api/* ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/cores/psoc/api + + # Fetch variables and move them to the GITHUB_OUTPUT and fetch HIL information + - id: startup + run: | + # switch on the HIL + cd /opt/runner_support/ + + # set the hil-unity-checks + hil=$(./py_checkusb.py --readyaml ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/tests/unity/hil-unity-checklist.yaml --json) + echo "hil=${hil}" >> $GITHUB_OUTPUT + echo "hil=${hil}" + + # fetch unity libraries + readarray -t data < <(echo $hil | jq -r '.|keys[]') + export dev=$(jq --compact-output --null-input '$ARGS.positional' --args -- "${data[@]}") + echo "devices=${dev}" >> $GITHUB_OUTPUT + echo "devices=${dev}" + + # setup environment + - name: Environment + run: | + hil=${{ toJson(steps.startup.outputs.hil) }} + REPO="$(basename "$GITHUB_REPOSITORY")" + DEVICE=${{ steps.startup.outputs.devices }} + DEVICE=$(echo $DEVICE | tr -d '[]') + FQBN=$(echo $DEVICE | tr -d '[]') + DEVICE=`tr ':' '.' <<<"${DEVICE}"` + + echo "repo=$REPO" >> $GITHUB_ENV + echo "device=$DEVICE" >> $GITHUB_ENV + echo "version=$TEST_VERSION" >> $GITHUB_ENV + echo "fqbn=$FQBN" >> $GITHUB_ENV + + echo "Repo " $REPO + echo "Device " $DEVICE + echo "FQBN " $FQBN + echo "Version " ${TEST_VERSION} + + - name: Build + run: | + export TMPDIR=$HOME/tmp + mkdir -p $TMPDIR + rm -rf $HOME/artefact + mkdir -p $HOME/artefact + + cd ~/.arduino15/packages/infineon/hardware/psoc/$TEST_VERSION/tests/unity/ + echo "==============================================================================================================" + echo "Run Tests" + echo "==============================================================================================================" + make FQBN=${{ env.fqbn }} PORT=/dev/ttyACM0 single_hardware_connected + mkdir -p ~/artefact/unit_tests/${{ env.device }} + mv ./build/* ~/artefact/unit_tests/. + echo "==============================================================================================================" + + + + echo "==============================================================================================================" + echo "Monitor" + timeout 1m \ + /opt/runner_support/py_console.py \ + --port /dev/ttyACM0 \ + --baud 115200 \ + --report ~/artefact/unit_tests/${{ env.device }}/report.json + + echo "==============================================================================================================" + + + # Upload the compiled HEX files to the GitHub server + - name: Artefact + uses: actions/upload-artifact@v4 + with: + name: ${{ env.device }} + path: ~/artefact/* + if-no-files-found: ignore \ No newline at end of file diff --git a/Makefile.arduino.mk b/tests/unity/Makefile similarity index 86% rename from Makefile.arduino.mk rename to tests/unity/Makefile index e3f9af0..09fa9a4 100644 --- a/Makefile.arduino.mk +++ b/tests/unity/Makefile @@ -1,15 +1,16 @@ FQBN ?= PORT ?= TESTS ?= +UNITY_PATH ?= ../../extras/unity +BAUD_RATE ?= 115200 $(info FQBN : $(FQBN)) $(info PORT : $(PORT)) - -UNITY_PATH = ./extras/unity +$(info UNITY_PATH : $(UNITY_PATH)) +$(info BAUD_RATE : $(BAUD_RATE)) TESTS_SINGLE_HARDWARE_CONNECTED=-DTEST_SINGLE_HARDWARE_CONNECTED - TESTS_MULTI_HARDWARE_CONNECTED=-DTEST_MULTI_HARDWARE_CONNECTED @@ -44,8 +45,8 @@ ifeq ($(UNITY_PATH),) $(error "Must set variable UNITY_PATH in order to be able to compile Arduino unit tests !") else find $(UNITY_PATH) -name '*.[hc]' \( -path '*extras*' -a -path '*src*' -or -path '*src*' -a \! -path '*example*' \) -exec \cp {} build \; - find test/unit -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \; - cp test/unit/src/test_main.ino build/build.ino + find src -name '*.[hc]*' -a \! -path '*mtb*' -a \! -path '*applibs*' -exec \cp {} build \; + cp src/test_main.ino build/build.ino endif @@ -57,7 +58,7 @@ ifeq ($(FQBN),) $(error "Must set variable FQBN in order to be able to compile Arduino sketches !") else # CAUTION : only use '=' when assigning values to vars, not '+=' - arduino-cli compile --clean --log --warnings all --fqbn $(FQBN) --build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \ + arduino-cli compile --clean --verbose --log --warnings all --fqbn $(FQBN) --build-property "compiler.c.extra_flags=\"-DUNITY_INCLUDE_CONFIG_H=1\"" \ --build-property compiler.cpp.extra_flags="$(TESTS)" build endif @@ -79,19 +80,22 @@ else endif -upload: +upload: compile ifeq ($(PORT),) $(error "Must set variable PORT (Windows port naming convention, ie COM16) in order to be able to flash Arduino sketches !") endif ifeq ($(FQBN),) $(error "Must set variable FQBN in order to be able to flash Arduino sketches !") else - arduino-cli upload -p $(PORT) --fqbn $(FQBN) build + arduino-cli upload \ + -p $(PORT) \ + --fqbn $(FQBN) \ + --verbose \ + build endif flash: compile upload -flashLTO: compileLTO upload monitor: @@ -101,6 +105,9 @@ endif ifeq ($(FQBN),) $(error "Must set variable FQBN in order to be able to flash Arduino sketches !") else - arduino-cli monitor -c baudrate=115200 -p $(PORT) --fqbn $(FQBN) + arduino-cli monitor \ + -c baudrate=$(BAUD_RATE) \ + -p $(PORT) \ + --fqbn $(FQBN) endif diff --git a/Makefile.test b/tests/unity/Makefile.test similarity index 76% rename from Makefile.test rename to tests/unity/Makefile.test index 64539f3..360aaed 100644 --- a/Makefile.test +++ b/tests/unity/Makefile.test @@ -4,6 +4,6 @@ ######################### tests runnable with a single board "talking to itself" ######################### -make -f Makefile.arduino.mk FQBN=infineon:psoc:cy8ckit_062s2_ai PORT=/dev/ttyACM0 single_hardware_connected monitor +make FQBN=infineon:psoc:cy8ckit_062s2_ai PORT=/dev/ttyACM0 single_hardware_connected monitor ######################### tests runnable with 2 boards and some wires ######################### diff --git a/tests/unity/hil-unity-checklist.yaml b/tests/unity/hil-unity-checklist.yaml new file mode 100644 index 0000000..f2afc9d --- /dev/null +++ b/tests/unity/hil-unity-checklist.yaml @@ -0,0 +1,7 @@ +infineon:psoc:cy8ckit_062s2_ai: + math: + 1: + - "math" + + + \ No newline at end of file diff --git a/test/unit/src/features/test_math.cpp b/tests/unity/src/corelibs/math/test_math.cpp similarity index 100% rename from test/unit/src/features/test_math.cpp rename to tests/unity/src/corelibs/math/test_math.cpp diff --git a/test/unit/src/features/test_math.hpp b/tests/unity/src/corelibs/math/test_math.hpp similarity index 100% rename from test/unit/src/features/test_math.hpp rename to tests/unity/src/corelibs/math/test_math.hpp diff --git a/test/unit/src/test_includes.hpp b/tests/unity/src/test_includes.hpp similarity index 100% rename from test/unit/src/test_includes.hpp rename to tests/unity/src/test_includes.hpp diff --git a/test/unit/src/test_main.ino b/tests/unity/src/test_main.ino similarity index 100% rename from test/unit/src/test_main.ino rename to tests/unity/src/test_main.ino diff --git a/test/unit/src/utils/unity_ifx.cpp b/tests/unity/src/utils/unity_ifx.cpp similarity index 100% rename from test/unit/src/utils/unity_ifx.cpp rename to tests/unity/src/utils/unity_ifx.cpp diff --git a/test/unit/src/utils/unity_ifx.h b/tests/unity/src/utils/unity_ifx.h similarity index 100% rename from test/unit/src/utils/unity_ifx.h rename to tests/unity/src/utils/unity_ifx.h diff --git a/test/unit/src/utils/utilities.cpp b/tests/unity/src/utils/utilities.cpp similarity index 100% rename from test/unit/src/utils/utilities.cpp rename to tests/unity/src/utils/utilities.cpp diff --git a/test/unit/src/utils/utilities.hpp b/tests/unity/src/utils/utilities.hpp similarity index 100% rename from test/unit/src/utils/utilities.hpp rename to tests/unity/src/utils/utilities.hpp diff --git a/test/unit/unity_config.h b/tests/unity/unity_config.h similarity index 100% rename from test/unit/unity_config.h rename to tests/unity/unity_config.h