1name: BabbleSim Tests 2 3on: 4 pull_request: 5 paths: 6 - ".github/workflows/bsim-tests.yaml" 7 - ".github/workflows/bsim-tests-publish.yaml" 8 - "west.yml" 9 - "subsys/bluetooth/**" 10 - "tests/bsim/**" 11 - "boards/nordic/nrf5*/*dt*" 12 - "dts/*/nordic/**" 13 - "tests/bluetooth/common/testlib/**" 14 - "samples/bluetooth/**" 15 - "boards/native/**" 16 - "soc/native/**" 17 - "arch/posix/**" 18 - "include/zephyr/arch/posix/**" 19 - "scripts/native_simulator/**" 20 - "samples/net/sockets/echo_*/**" 21 - "modules/hal_nordic/**" 22 - "modules/mbedtls/**" 23 - "modules/openthread/**" 24 - "subsys/net/l2/openthread/**" 25 - "include/zephyr/net/openthread.h" 26 - "drivers/ieee802154/**" 27 - "include/zephyr/net/ieee802154*" 28 - "drivers/serial/*nrfx*" 29 - "tests/drivers/uart/**" 30 31concurrency: 32 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} 33 cancel-in-progress: true 34 35jobs: 36 bsim-test: 37 if: github.repository_owner == 'zephyrproject-rtos' 38 runs-on: 39 group: zephyr-runner-v2-linux-x64-4xlarge 40 container: 41 image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026 42 options: '--entrypoint /bin/bash' 43 env: 44 ZEPHYR_TOOLCHAIN_VARIANT: zephyr 45 BSIM_OUT_PATH: /opt/bsim/ 46 BSIM_COMPONENTS_PATH: /opt/bsim/components 47 EDTT_PATH: ../tools/edtt 48 steps: 49 - name: Apply container owner mismatch workaround 50 run: | 51 # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not 52 # match the container user UID because of the way GitHub 53 # Actions runner is implemented. Remove this workaround when 54 # GitHub comes up with a fundamental fix for this problem. 55 git config --global --add safe.directory ${GITHUB_WORKSPACE} 56 57 - name: Print cloud service information 58 run: | 59 echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}" 60 echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}" 61 echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}" 62 63 - name: Clone cached Zephyr repository 64 continue-on-error: true 65 run: | 66 git clone --shared /repo-cache/zephyrproject/zephyr . 67 git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} 68 69 - name: Checkout 70 uses: actions/checkout@v4 71 with: 72 fetch-depth: 0 73 74 - name: Environment Setup 75 env: 76 BASE_REF: ${{ github.base_ref }} 77 run: | 78 git config --global user.email "bot@zephyrproject.org" 79 git config --global user.name "Zephyr Bot" 80 rm -fr ".git/rebase-apply" 81 rm -fr ".git/rebase-merge" 82 git rebase origin/${BASE_REF} 83 git clean -f -d 84 git log --pretty=oneline | head -n 10 85 west init -l . || true 86 west config manifest.group-filter -- +ci 87 west config --global update.narrow true 88 west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject) 89 west forall -c 'git reset --hard HEAD' 90 91 echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV 92 93 - name: Check common triggering files 94 uses: tj-actions/changed-files@v45 95 id: check-common-files 96 with: 97 files: | 98 .github/workflows/bsim-tests.yaml 99 .github/workflows/bsim-tests-publish.yaml 100 west.yml 101 boards/native/ 102 soc/native/ 103 arch/posix/ 104 include/zephyr/arch/posix/ 105 scripts/native_simulator/ 106 tests/bsim/* 107 boards/nordic/nrf5*/*dt* 108 dts/*/nordic/ 109 modules/mbedtls/** 110 modules/hal_nordic/** 111 112 - name: Check if Bluethooth files changed 113 uses: tj-actions/changed-files@v45 114 id: check-bluetooth-files 115 with: 116 files: | 117 tests/bsim/bluetooth/ 118 samples/bluetooth/ 119 subsys/bluetooth/ 120 121 - name: Check if Networking files changed 122 uses: tj-actions/changed-files@v45 123 id: check-networking-files 124 with: 125 files: | 126 tests/bsim/net/ 127 samples/net/sockets/echo_*/ 128 modules/openthread/ 129 subsys/net/l2/openthread/ 130 include/zephyr/net/openthread.h 131 drivers/ieee802154/ 132 include/zephyr/net/ieee802154* 133 134 - name: Check if UART files changed 135 uses: tj-actions/changed-files@v45 136 id: check-uart-files 137 with: 138 files: | 139 tests/bsim/drivers/uart/ 140 drivers/serial/*nrfx* 141 tests/drivers/uart/ 142 143 - name: Update BabbleSim to manifest revision 144 if: > 145 steps.check-bluetooth-files.outputs.any_modified == 'true' 146 || steps.check-networking-files.outputs.any_modified == 'true' 147 || steps.check-uart-files.outputs.any_modified == 'true' 148 || steps.check-common-files.outputs.any_modified == 'true' 149 run: | 150 export BSIM_VERSION=$( west list bsim -f {revision} ) 151 echo "Manifest points to bsim sha $BSIM_VERSION" 152 cd /opt/bsim_west/bsim 153 git fetch -n origin ${BSIM_VERSION} 154 git -c advice.detachedHead=false checkout ${BSIM_VERSION} 155 west update 156 make everything -s -j 8 157 158 - name: Run Bluetooth Tests with BSIM 159 if: steps.check-bluetooth-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true' 160 run: | 161 tests/bsim/ci.bt.sh 162 163 - name: Run Networking Tests with BSIM 164 if: steps.check-networking-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true' 165 run: | 166 tests/bsim/ci.net.sh 167 168 - name: Run UART Tests with BSIM 169 if: steps.check-uart-files.outputs.any_modified == 'true' || steps.check-common-files.outputs.any_modified == 'true' 170 run: | 171 tests/bsim/ci.uart.sh 172 173 - name: Merge Test Results 174 run: | 175 pip install junitparser junit2html 176 junitparser merge --glob "./bsim_*/*bsim_results.*.xml" "./twister-out/twister.xml" junit.xml 177 junit2html junit.xml junit.html 178 179 - name: Upload Unit Test Results in HTML 180 if: always() 181 uses: actions/upload-artifact@v4 182 with: 183 name: HTML Unit Test Results 184 if-no-files-found: ignore 185 path: | 186 junit.html 187 188 - name: Publish Unit Test Results 189 uses: EnricoMi/publish-unit-test-result-action@v2 190 with: 191 check_name: Bsim Test Results 192 files: "junit.xml" 193 comment_mode: off 194 195 - name: Upload Event Details 196 if: always() 197 uses: actions/upload-artifact@v4 198 with: 199 name: event 200 path: | 201 ${{ github.event_path }} 202