diff --git a/.github/workflows/ifx_package_core.yml b/.github/workflows/ifx_package_core.yml index 6c8e4373e..86db16901 100644 --- a/.github/workflows/ifx_package_core.yml +++ b/.github/workflows/ifx_package_core.yml @@ -68,6 +68,9 @@ jobs: SUB_ARCHES: ${{ env.SUB_ARCHES }} # URL of the latest ci-builds index for this branch, if any CI_BUILDS_URL: ${{ env.CI_BUILDS_URL }} + # Subset of ALL_BOARD_DATA for boards that have a tests/test_config.h + # block (i.e. arduino-core-tests/Unity pin config is ready for them) + ARDUINO_CORE_TESTS_BOARDS: ${{ env.ARDUINO_CORE_TESTS_BOARDS }} steps: - name: Install OS dependencies @@ -120,6 +123,24 @@ jobs: echo "ARTIFACTS=$(jq -c '["zephyr"] + (map(.artifact) | unique)' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV" echo "SUB_ARCHES=$(jq -c 'map(.subarch) | unique' <<< ${ALL_BOARD_DATA})" >> "$GITHUB_ENV" + - name: Discover boards with arduino-core-tests (Unity) config + # Cross-references tests/test_config.h's "#if defined(ARDUINO_)" + # blocks against boards.txt's ".build.board=" field, so + # test-arduino-core-tests only runs for boards that actually have pin + # config ready. A no-op (empty list) on branches without tests/test_config.h. + run: | + BOARDS="[]" + if [ -f tests/test_config.h ] ; then + for DEFINE in $(grep -oP 'ARDUINO_\K[A-Z0-9_]+' tests/test_config.h | sort -u) ; do + BOARD_ID=$(grep -E "^[a-zA-Z0-9_]+\.build\.board=${DEFINE}$" boards.txt | cut -d. -f1) + [ -z "$BOARD_ID" ] && continue + ENTRY=$(jq -c --arg b "$BOARD_ID" '.[] | select(.board==$b)' <<< "${ALL_BOARD_DATA}") + [ -z "$ENTRY" ] && continue + BOARDS=$(jq -c --argjson e "${ENTRY}" '. + [$e]' <<< "${BOARDS}") + done + fi + echo "ARDUINO_CORE_TESTS_BOARDS=${BOARDS}" >> "$GITHUB_ENV" + - name: Cache west modules and blobs uses: actions/cache@v5 with: @@ -580,6 +601,61 @@ jobs: + # Compile-only check for the arduino-core-tests (Unity) suite vendored at + # tests/arduino_core_tests. Only runs for boards with a tests/test_config.h + # block (see build-env's "Discover boards with arduino-core-tests" step). + # No hardware is available in CI, so this only validates that each enabled + # test still compiles+links against the current source, it does not flash + # or run anything on real hardware. + + test-arduino-core-tests: + name: Compile arduino-core-tests for ${{ matrix.board }}:${{ matrix.link_mode }} + runs-on: ubuntu-latest + needs: + - build-env + if: ${{ !cancelled() && needs.build-env.result == 'success' && needs.build-env.outputs.ARDUINO_CORE_TESTS_BOARDS != '[]' }} + strategy: + matrix: + include: ${{ fromJSON( needs.build-env.outputs.ARDUINO_CORE_TESTS_BOARDS ) }} + link_mode: [static, dynamic] + fail-fast: false + env: + FQBN: arduino:${{ matrix.subarch }}:${{ matrix.board }}:link_mode=${{ matrix.link_mode }} + CI_BUILDS_URL: ${{ needs.build-env.outputs.CI_BUILDS_URL }} + # Tests enumerated here are known to have their required + # TEST_PIN_*/etc. macros defined in tests/test_config.h for this board. + # Add more test_* names as tests/test_config.h gains board config for them. + ENABLED_TESTS: test_digitalio_single + steps: + - uses: actions/checkout@v6 + with: + submodules: 'recursive' + persist-credentials: false + + - uses: arduino/setup-arduino-cli@v2 + + - name: Install core tools, use this checkout as the platform + run: | + ADDITIONAL_URLS=() + [ -n "${CI_BUILDS_URL}" ] && ADDITIONAL_URLS=(--additional-urls "${CI_BUILDS_URL}") + arduino-cli core update-index "${ADDITIONAL_URLS[@]}" + arduino-cli core install "arduino:${{ matrix.subarch }}" "${ADDITIONAL_URLS[@]}" + # replace the installed hardware files with this checkout, same as + # local development does (see tests/README.md) + VERSION_DIR=$(ls -d ~/.arduino15/packages/arduino/hardware/${{ matrix.subarch }}/*/ | head -1) + rm -rf "${VERSION_DIR}" + ln -s "${GITHUB_WORKSPACE}" "${VERSION_DIR%/}" + + - name: Compile enabled tests + run: | + for TEST in ${ENABLED_TESTS}; do + UPPER=$(echo "${TEST}" | tr '[:lower:]' '[:upper:]') + make -C tests/arduino_core_tests FQBN=${FQBN} UNITY_PATH=Unity \ + TESTS=-D${UPPER} prepare_test_environment compile + done + + + # Collect all build and test reports, analyze them and produce a summary. # See ci_collect_data.py and ci_generate_report.py for details. diff --git a/.gitmodules b/.gitmodules index e69de29bb..ed69927d6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "tests/arduino_core_tests"] + path = tests/arduino_core_tests + url = https://github.com/Infineon/arduino-core-tests.git diff --git a/tests/arduino_core_tests b/tests/arduino_core_tests new file mode 160000 index 000000000..0f52c0291 --- /dev/null +++ b/tests/arduino_core_tests @@ -0,0 +1 @@ +Subproject commit 0f52c0291cc344206846c01cfbc8590fab0844f7 diff --git a/tests/test_config.h b/tests/test_config.h new file mode 100644 index 000000000..d33bb1a53 --- /dev/null +++ b/tests/test_config.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) Infineon Technologies AG + * + * SPDX-License-Identifier: Apache-2.0 + * + * Board-specific test pin definitions for tests/arduino_core_tests. + * + * Each board adds its own #if defined(ARDUINO_) block below (see + * tests/README.md). This file intentionally has no board blocks of its own: + * board-specific content belongs to the branch that owns that board. + */ +#ifndef TEST_CONFIG_H +#define TEST_CONFIG_H + +/* + * Infineon KIT-PSE84-AI (PSOC Edge E84). + * + * D0 (P17_5) and D1 (P17_7) must be connected with a jumper when running + * test_digitalio_single. Both pins are exposed as digital GPIOs on the board + * expansion header and are mapped by the Arduino variant overlay + * (variants/kit_pse84_ai_pse846gps2dbzc4a_m33, digital-pin-gpios). + */ +#if defined(ARDUINO_KIT_PSE84_AI) +#define TEST_PIN_DIGITAL_IO_OUTPUT 0 +#define TEST_PIN_DIGITAL_IO_INPUT 1 +#endif + +#endif // TEST_CONFIG_H