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 - "samples/bluetooth/**" 12 - "boards/posix/**" 13 - "soc/posix/**" 14 - "arch/posix/**" 15 - "include/zephyr/arch/posix/**" 16 - "scripts/native_simulator/**" 17 - "samples/net/sockets/echo_*/**" 18 - "modules/openthread/**" 19 - "subsys/net/l2/openthread/**" 20 - "include/zephyr/net/openthread.h" 21 - "drivers/ieee802154/**" 22 - "include/zephyr/net/ieee802154*" 23 - "drivers/serial/*nrfx*" 24 - "tests/drivers/uart/**" 25 26concurrency: 27 group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }} 28 cancel-in-progress: true 29 30jobs: 31 bsim-test: 32 if: github.repository_owner == 'zephyrproject-rtos' 33 runs-on: zephyr-runner-linux-x64-4xlarge 34 container: 35 image: ghcr.io/zephyrproject-rtos/ci:v0.26.7 36 options: '--entrypoint /bin/bash' 37 volumes: 38 - /repo-cache/zephyrproject:/github/cache/zephyrproject 39 env: 40 ZEPHYR_TOOLCHAIN_VARIANT: zephyr 41 BSIM_OUT_PATH: /opt/bsim/ 42 BSIM_COMPONENTS_PATH: /opt/bsim/components 43 EDTT_PATH: ../tools/edtt 44 bsim_bt_52_test_results_file: ./bsim_bt/52_bsim_results.xml 45 bsim_bt_53_test_results_file: ./bsim_bt/53_bsim_results.xml 46 bsim_bt_53split_test_results_file: ./bsim_bt/53_bsim_split_results.xml 47 bsim_net_52_test_results_file: ./bsim_net/52_bsim_results.xml 48 bsim_uart_test_results_file: ./bsim_uart/uart_bsim_results.xml 49 steps: 50 - name: Apply container owner mismatch workaround 51 run: | 52 # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not 53 # match the container user UID because of the way GitHub 54 # Actions runner is implemented. Remove this workaround when 55 # GitHub comes up with a fundamental fix for this problem. 56 git config --global --add safe.directory ${GITHUB_WORKSPACE} 57 58 - name: Clone cached Zephyr repository 59 continue-on-error: true 60 run: | 61 git clone --shared /github/cache/zephyrproject/zephyr . 62 git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY} 63 64 - name: Checkout 65 uses: actions/checkout@v4 66 with: 67 fetch-depth: 0 68 69 - name: Environment Setup 70 env: 71 BASE_REF: ${{ github.base_ref }} 72 run: | 73 git config --global user.email "bot@zephyrproject.org" 74 git config --global user.name "Zephyr Bot" 75 rm -fr ".git/rebase-apply" 76 git rebase origin/${BASE_REF} 77 git log --pretty=oneline | head -n 10 78 west init -l . || true 79 west config manifest.group-filter -- +ci 80 west config --global update.narrow true 81 west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /github/cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /github/cache/zephyrproject) 82 west forall -c 'git reset --hard HEAD' 83 84 echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV 85 86 - name: Check common triggering files 87 uses: tj-actions/changed-files@v41 88 id: check-common-files 89 with: 90 files: | 91 .github/workflows/bsim-tests.yaml 92 .github/workflows/bsim-tests-publish.yaml 93 west.yml 94 boards/posix/** 95 soc/posix/** 96 arch/posix/** 97 include/zephyr/arch/posix/** 98 scripts/native_simulator/** 99 tests/bsim/* 100 101 - name: Check if Bluethooth files changed 102 uses: tj-actions/changed-files@v41 103 id: check-bluetooth-files 104 with: 105 files: | 106 tests/bsim/bluetooth/** 107 samples/bluetooth/** 108 subsys/bluetooth/** 109 110 - name: Check if Networking files changed 111 uses: tj-actions/changed-files@v41 112 id: check-networking-files 113 with: 114 files: | 115 tests/bsim/net/** 116 samples/net/sockets/echo_*/** 117 modules/openthread/** 118 subsys/net/l2/openthread/** 119 include/zephyr/net/openthread.h 120 drivers/ieee802154/** 121 include/zephyr/net/ieee802154* 122 123 - name: Check if UART files changed 124 uses: tj-actions/changed-files@v41 125 id: check-uart-files 126 with: 127 files: | 128 tests/bsim/drivers/uart/** 129 drivers/serial/*nrfx* 130 tests/drivers/uart/** 131 132 - name: Update BabbleSim to manifest revision 133 if: > 134 steps.check-bluetooth-files.outputs.any_changed == 'true' 135 || steps.check-networking-files.outputs.any_changed == 'true' 136 || steps.check-uart-files.outputs.any_changed == 'true' 137 || steps.check-common-files.outputs.any_changed == 'true' 138 run: | 139 export BSIM_VERSION=$( west list bsim -f {revision} ) 140 echo "Manifest points to bsim sha $BSIM_VERSION" 141 cd /opt/bsim_west/bsim 142 git fetch -n origin ${BSIM_VERSION} 143 git config --global advice.detachedHead false 144 git checkout ${BSIM_VERSION} 145 west update 146 make everything -s -j 8 147 148 - name: Run Bluetooth Tests with BSIM 149 if: steps.check-bluetooth-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true' 150 run: | 151 export ZEPHYR_BASE=${PWD} 152 export WORK_DIR=${ZEPHYR_BASE}/bsim_bt 153 # Build and run the BT tests for nrf52_bsim: 154 nice tests/bsim/bluetooth/compile.sh 155 RESULTS_FILE=${ZEPHYR_BASE}/${bsim_bt_52_test_results_file} \ 156 TESTS_FILE=tests/bsim/bluetooth/tests.nrf52bsim.txt tests/bsim/run_parallel.sh 157 # Build and run the BT controller tests also for the nrf5340bsim_nrf5340_cpunet 158 BOARD=nrf5340bsim_nrf5340_cpunet \ 159 nice tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpunet.sh 160 BOARD=nrf5340bsim_nrf5340_cpunet \ 161 RESULTS_FILE=${ZEPHYR_BASE}/${bsim_bt_53_test_results_file} \ 162 TESTS_FILE=tests/bsim/bluetooth/tests.nrf5340bsim_nrf5340_cpunet.txt \ 163 tests/bsim/run_parallel.sh 164 # Build and run the nrf5340 split stack tests set 165 BOARD=nrf5340bsim_nrf5340_cpuapp \ 166 nice tests/bsim/bluetooth/compile.nrf5340bsim_nrf5340_cpuapp.sh 167 BOARD=nrf5340bsim_nrf5340_cpuapp \ 168 RESULTS_FILE=${ZEPHYR_BASE}/${bsim_bt_53split_test_results_file} \ 169 TESTS_FILE=tests/bsim/bluetooth/tests.nrf5340bsim_nrf5340_cpuapp.txt \ 170 tests/bsim/run_parallel.sh 171 172 - name: Run Networking Tests with BSIM 173 if: steps.check-networking-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true' 174 run: | 175 export ZEPHYR_BASE=${PWD} 176 WORK_DIR=${ZEPHYR_BASE}/bsim_net nice tests/bsim/net/compile.sh 177 RESULTS_FILE=${ZEPHYR_BASE}/${bsim_net_52_test_results_file} \ 178 SEARCH_PATH=tests/bsim/net/ tests/bsim/run_parallel.sh 179 180 - name: Run UART Tests with BSIM 181 if: steps.check-uart-files.outputs.any_changed == 'true' || steps.check-common-files.outputs.any_changed == 'true' 182 run: | 183 echo "UART: Single device tests" 184 ./scripts/twister -T tests/drivers/uart/ --force-color --inline-logs -v -M -p nrf52_bsim \ 185 --fixture gpio_loopback -- -uart0_loopback 186 echo "UART: Multi device tests" 187 export ZEPHYR_BASE=${PWD} 188 WORK_DIR=${ZEPHYR_BASE}/bsim_uart nice tests/bsim/drivers/uart/compile.sh 189 RESULTS_FILE=${ZEPHYR_BASE}/${bsim_uart_test_results_file} \ 190 SEARCH_PATH=tests/bsim/drivers/uart/ tests/bsim/run_parallel.sh 191 192 - name: Upload Test Results 193 if: always() 194 uses: actions/upload-artifact@v4 195 with: 196 name: bsim-test-results 197 path: | 198 ./bsim_bt/52_bsim_results.xml 199 ./bsim_bt/53_bsim_results.xml 200 ./bsim_bt/53_bsim_split_results.xml 201 ./bsim_net/52_bsim_results.xml 202 ./bsim_uart/uart_bsim_results.xml 203 ./twister-out/twister.xml 204 ./twister-out/twister.json 205 ${{ github.event_path }} 206 if-no-files-found: warn 207 208 - name: Upload Event Details 209 if: always() 210 uses: actions/upload-artifact@v4 211 with: 212 name: event 213 path: | 214 ${{ github.event_path }} 215