1# 2# Copyright (c) 2020, The OpenThread Authors. 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are met: 7# 1. Redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer. 9# 2. Redistributions in binary form must reproduce the above copyright 10# notice, this list of conditions and the following disclaimer in the 11# documentation and/or other materials provided with the distribution. 12# 3. Neither the name of the copyright holder nor the 13# names of its contributors may be used to endorse or promote products 14# derived from this software without specific prior written permission. 15# 16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 20# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26# POSSIBILITY OF SUCH DAMAGE. 27# 28 29name: Simulation 1.1 30 31on: 32 push: 33 branches-ignore: 34 - 'dependabot/**' 35 pull_request: 36 branches: 37 - 'main' 38 39concurrency: 40 group: ${{ github.workflow }}-${{ github.event.pull_request.number || (github.repository == 'openthread/openthread' && github.run_id) || github.ref }} 41 cancel-in-progress: true 42 43permissions: 44 contents: read 45 46jobs: 47 48 packet-verification: 49 runs-on: ubuntu-20.04 50 env: 51 PACKET_VERIFICATION: 1 52 REFERENCE_DEVICE: 1 53 THREAD_VERSION: 1.1 54 VIRTUAL_TIME: 1 55 MULTIPLY: 3 56 steps: 57 - name: Harden Runner 58 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 59 with: 60 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 61 62 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 63 with: 64 submodules: true 65 - name: Bootstrap 66 run: | 67 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 68 sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build lcov 69 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 70 - name: Build 71 run: | 72 ./script/test build 73 - name: Get Thread-Wireshark 74 run: | 75 ./script/test get_thread_wireshark 76 - name: Run 77 run: | 78 ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 79 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 80 if: ${{ failure() }} 81 with: 82 name: packet-verification-pcaps 83 path: | 84 *.pcap 85 *.json 86 - name: Generate Coverage 87 run: | 88 ./script/test generate_coverage gcc 89 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 90 with: 91 name: cov-packet-verification 92 path: tmp/coverage.info 93 retention-days: 1 94 95 cli-ftd: 96 runs-on: ubuntu-20.04 97 env: 98 CFLAGS: -m32 99 CXXFLAGS: -m32 100 LDFLAGS: -m32 101 COVERAGE: 1 102 REFERENCE_DEVICE: 1 103 THREAD_VERSION: 1.1 104 VIRTUAL_TIME: 1 105 steps: 106 - name: Harden Runner 107 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 108 with: 109 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 110 111 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 112 with: 113 submodules: true 114 - name: Bootstrap 115 run: | 116 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 117 sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib python3-setuptools python3-wheel 118 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 119 - name: Build 120 run: | 121 ./script/test build 122 - name: Run 123 run: | 124 ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 125 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 126 if: ${{ failure() }} 127 with: 128 name: cli-ftd-thread-cert 129 path: ot_testing 130 - name: Generate Coverage 131 run: | 132 ./script/test generate_coverage gcc 133 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 134 with: 135 name: cov-cli-ftd 136 path: tmp/coverage.info 137 retention-days: 1 138 139 cli-mtd: 140 name: cli-mtd MESSAGE_USE_HEAP=${{ matrix.message_use_heap }} 141 runs-on: ubuntu-20.04 142 strategy: 143 fail-fast: false 144 matrix: 145 message_use_heap: [0, 1] 146 env: 147 CFLAGS: -m32 148 CXXFLAGS: -m32 149 LDFLAGS: -m32 150 COVERAGE: 1 151 REFERENCE_DEVICE: 1 152 THREAD_VERSION: 1.1 153 USE_MTD: 1 154 VIRTUAL_TIME: 1 155 MESSAGE_USE_HEAP: ${{ matrix.message_use_heap }} 156 steps: 157 - name: Harden Runner 158 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 159 with: 160 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 161 162 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 163 with: 164 submodules: true 165 - name: Bootstrap 166 run: | 167 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 168 sudo apt-get --no-install-recommends install -y lcov ninja-build g++-multilib python3-setuptools python3-wheel 169 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 170 - name: Build 171 run: | 172 ./script/test build 173 - name: Run 174 run: | 175 ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 176 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 177 if: ${{ failure() }} 178 with: 179 name: cli-mtd-thread-cert 180 path: ot_testing 181 - name: Generate Coverage 182 run: | 183 ./script/test generate_coverage gcc 184 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 185 with: 186 name: cov-cli-mtd-${{ matrix.message_use_heap }} 187 path: tmp/coverage.info 188 retention-days: 1 189 190 cli-time-sync: 191 runs-on: ubuntu-20.04 192 env: 193 CFLAGS: -m32 194 CXXFLAGS: -m32 195 LDFLAGS: -m32 196 COVERAGE: 1 197 REFERENCE_DEVICE: 1 198 THREAD_VERSION: 1.1 199 VIRTUAL_TIME: 1 200 steps: 201 - name: Harden Runner 202 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 203 with: 204 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 205 206 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 207 with: 208 submodules: true 209 - name: Bootstrap 210 run: | 211 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 212 sudo apt-get --no-install-recommends install -y g++-multilib lcov ninja-build python3-setuptools python3-wheel 213 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 214 - name: Build 215 run: | 216 OT_OPTIONS="-DOT_TIME_SYNC=ON" ./script/test build 217 - name: Run 218 run: | 219 ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 220 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 221 if: ${{ failure() }} 222 with: 223 name: cli-time-sync-thread-cert 224 path: ot_testing 225 - name: Generate Coverage 226 run: | 227 ./script/test generate_coverage gcc 228 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 229 with: 230 name: cov-cli-time-sync 231 path: tmp/coverage.info 232 retention-days: 1 233 234 expects: 235 runs-on: ubuntu-20.04 236 env: 237 CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15 238 CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15 239 THREAD_VERSION: 1.1 240 steps: 241 - name: Harden Runner 242 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 243 with: 244 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 245 246 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 247 - name: Bootstrap 248 run: | 249 sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat 250 pip install bleak 251 - name: Run 252 run: | 253 ulimit -c unlimited 254 ./script/test prepare_coredump_upload 255 OT_OPTIONS='-DOT_TIME_SYNC=ON -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED' VIRTUAL_TIME=0 ./script/test build expect 256 - name: Check Crash 257 if: ${{ failure() }} 258 run: | 259 CRASHED=$(./script/test check_crash | tail -1) 260 [[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed." 261 echo "CRASHED_CLI=$CRASHED" >> $GITHUB_ENV 262 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 263 if: ${{ failure() && env.CRASHED_CLI == '1' }} 264 with: 265 name: core-expect-cli 266 path: | 267 ./ot-core-dump/* 268 - name: Generate Coverage 269 run: | 270 ./script/test generate_coverage gcc 271 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 272 with: 273 name: cov-expects 274 path: tmp/coverage.info 275 retention-days: 1 276 277 ot-commissioner: 278 runs-on: ubuntu-22.04 279 env: 280 THREAD_VERSION: 1.1 281 steps: 282 - name: Harden Runner 283 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 284 with: 285 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 286 287 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 288 with: 289 submodules: true 290 - name: Bootstrap 291 env: 292 GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 293 run: | 294 sudo rm /etc/apt/sources.list.d/* 295 sudo apt-get update 296 sudo apt-get install -y avahi-daemon avahi-utils lcov 297 script/git-tool clone https://github.com/openthread/ot-commissioner.git /tmp/ot-commissioner --depth 1 --branch main 298 - name: Build 299 run: | 300 cd /tmp/ot-commissioner 301 script/bootstrap.sh 302 cmake -GNinja \ 303 -DCMAKE_CXX_STANDARD=11 \ 304 -DCMAKE_CXX_STANDARD_REQUIRED=ON \ 305 -DCMAKE_BUILD_TYPE=Release \ 306 -DCMAKE_INSTALL_PREFIX=/usr/local \ 307 -DOT_COMM_COVERAGE=ON \ 308 -DOT_COMM_CCM=OFF \ 309 -S . -B build 310 cmake --build build 311 sudo cmake --install build 312 - name: Run 313 run: | 314 export OT_COMM_OPENTHREAD="$(pwd)" 315 cd /tmp/ot-commissioner/tests/integration 316 ./bootstrap.sh 317 ./run_tests.sh 318 - name: Generate Coverage 319 run: | 320 ./script/test generate_coverage gcc 321 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 322 with: 323 name: cov-ot-commissioner 324 path: tmp/coverage.info 325 retention-days: 1 326 327 multiple-instance: 328 runs-on: ubuntu-20.04 329 env: 330 COVERAGE: 1 331 THREAD_VERSION: 1.1 332 VIRTUAL_TIME: 1 333 CXXFLAGS: "-DOPENTHREAD_CONFIG_LOG_PREPEND_UPTIME=0" 334 steps: 335 - name: Harden Runner 336 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 337 with: 338 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 339 340 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 341 with: 342 submodules: true 343 - name: Bootstrap 344 run: | 345 sudo apt-get --no-install-recommends install -y lcov ninja-build python3-setuptools python3-wheel 346 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 347 - name: Build 348 run: | 349 OT_OPTIONS="-DOT_MULTIPLE_INSTANCE=ON" ./script/test build 350 - name: Run 351 run: | 352 ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 353 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 354 if: ${{ failure() }} 355 with: 356 name: ot_testing 357 path: build/simulation/tests/scripts/thread-cert 358 - name: Generate Coverage 359 run: | 360 ./script/test generate_coverage gcc 361 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 362 with: 363 name: cov-multiple-instance 364 path: tmp/coverage.info 365 retention-days: 1 366 367 simulation-local-host: 368 runs-on: ubuntu-20.04 369 env: 370 COVERAGE: 1 371 steps: 372 - name: Harden Runner 373 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 374 with: 375 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 376 377 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 378 with: 379 submodules: true 380 - name: Bootstrap 381 run: | 382 sudo apt-get --no-install-recommends install -y expect ninja-build lcov 383 - name: Run 384 run: | 385 ./script/check-simulation-local-host 386 - name: Generate Coverage 387 run: | 388 ./script/test generate_coverage gcc 389 - uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 390 with: 391 name: cov-simulation-local-host 392 path: tmp/coverage.info 393 retention-days: 1 394 395 upload-coverage: 396 needs: 397 - packet-verification 398 - cli-ftd 399 - cli-mtd 400 - cli-time-sync 401 - expects 402 - ot-commissioner 403 - multiple-instance 404 runs-on: ubuntu-20.04 405 steps: 406 - name: Harden Runner 407 uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 408 with: 409 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 410 411 - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2 412 with: 413 submodules: true 414 - name: Bootstrap 415 run: | 416 sudo apt-get --no-install-recommends install -y lcov 417 - uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427 # v4.1.4 418 with: 419 path: coverage/ 420 pattern: cov-* 421 merge-multiple: true 422 - name: Combine Coverage 423 run: | 424 script/test combine_coverage 425 - name: Upload Coverage 426 uses: codecov/codecov-action@0cfda1dd0a4ad9efc75517f399d859cd1ea4ced1 # v4.0.2 427 env: 428 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 429 with: 430 files: final.info 431 fail_ci_if_error: true 432