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: POSIX 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 expects-linux: 49 runs-on: ubuntu-20.04 50 env: 51 CFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15 52 CXXFLAGS: -DCLI_COAP_SECURE_USE_COAP_DEFAULT_HANDLER=1 -DOPENTHREAD_CONFIG_MLE_MAX_CHILDREN=15 53 steps: 54 - name: Harden Runner 55 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 56 with: 57 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 58 59 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 60 - name: Bootstrap 61 run: | 62 sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat 63 pip install bleak 64 - name: Run RCP Mode 65 run: | 66 ulimit -c unlimited 67 ./script/test prepare_coredump_upload 68 OT_OPTIONS='-DOT_READLINE=OFF -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED' VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test build expect 69 - name: Run ot-fct 70 run: | 71 OT_CMAKE_NINJA_TARGET="ot-fct" script/cmake-build posix 72 tests/scripts/expect/ot-fct.exp 73 - name: Check Crash 74 if: ${{ failure() }} 75 run: | 76 CRASHED=$(./script/test check_crash | tail -1) 77 [[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed." 78 echo "CRASHED_RCP=$CRASHED" >> $GITHUB_ENV 79 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 80 if: ${{ failure() && env.CRASHED_RCP == '1' }} 81 with: 82 name: core-expect-rcp 83 path: | 84 ./ot-core-dump/* 85 - name: Generate Coverage 86 run: | 87 ./script/test generate_coverage gcc 88 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 89 with: 90 name: cov-expects-linux-1 91 path: tmp/coverage.info 92 retention-days: 1 93 - name: Run TUN Mode 94 run: | 95 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 96 echo 0 | sudo tee /proc/sys/net/ipv6/conf/all/disable_ipv6 97 sudo apt-get install --no-install-recommends -y bind9-host ntp socat 98 sudo systemctl restart ntp 99 sudo socat 'UDP6-LISTEN:53,fork,reuseaddr,bind=[::1]' UDP:127.0.0.53:53 & 100 socat 'TCP6-LISTEN:2000,fork,reuseaddr' TCP:127.0.0.53:53 & 101 host ipv6.google.com 127.0.0.53 102 host ipv6.google.com ::1 103 ulimit -c unlimited 104 ./script/test prepare_coredump_upload 105 OT_OPTIONS='-DOT_READLINE=OFF -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED' OT_NATIVE_IP=1 VIRTUAL_TIME=0 OT_NODE_TYPE=rcp ./script/test clean build expect 106 - name: Check Crash 107 if: ${{ failure() }} 108 run: | 109 CRASHED=$(./script/test check_crash | tail -1) 110 [[ $CRASHED -eq "1" ]] && echo "Crashed!" || echo "Not crashed." 111 echo "CRASHED_TUN=$CRASHED" >> $GITHUB_ENV 112 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 113 if: ${{ failure() && env.CRASHED_TUN == '1' }} 114 with: 115 name: core-expect-linux 116 path: | 117 ./ot-core-dump/* 118 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 119 if: ${{ failure() }} 120 with: 121 name: syslog-expect-linux 122 path: /var/log/syslog 123 - name: Generate Coverage 124 run: | 125 ./script/test generate_coverage gcc 126 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 127 with: 128 name: cov-expects-linux-2 129 path: tmp/coverage.info 130 retention-days: 1 131 132 thread-cert: 133 runs-on: ubuntu-20.04 134 env: 135 COVERAGE: 1 136 PYTHONUNBUFFERED: 1 137 THREAD_VERSION: 1.1 138 VIRTUAL_TIME: 1 139 steps: 140 - name: Harden Runner 141 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 142 with: 143 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 144 145 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 146 with: 147 submodules: true 148 - name: Bootstrap 149 run: | 150 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 151 sudo apt-get --no-install-recommends install -y lcov ninja-build python3-setuptools python3-wheel 152 python3 -m pip install -r tests/scripts/thread-cert/requirements.txt 153 - name: Build 154 run: | 155 OT_NODE_TYPE=rcp ./script/test build 156 - name: Run 157 run: | 158 MAX_JOBS=$(getconf _NPROCESSORS_ONLN) ./script/test cert_suite ./tests/scripts/thread-cert/Cert_*.py ./tests/scripts/thread-cert/test_*.py 159 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 160 if: ${{ failure() }} 161 with: 162 name: thread-cert 163 path: ot_testing 164 - name: Generate Coverage 165 run: | 166 ./script/test generate_coverage gcc 167 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 168 with: 169 name: cov-thread-cert 170 path: tmp/coverage.info 171 172 pty-linux: 173 name: pty-linux OT_DAEMON=${{ matrix.OT_DAEMON }} 174 runs-on: ubuntu-20.04 175 strategy: 176 fail-fast: false 177 matrix: 178 OT_DAEMON: ['off', 'on'] 179 env: 180 COVERAGE: 1 181 OT_DAEMON: ${{ matrix.OT_DAEMON }} 182 OT_READLINE: 'readline' 183 steps: 184 - name: Harden Runner 185 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 186 with: 187 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 188 189 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 190 - name: Bootstrap 191 run: | 192 sudo rm /etc/apt/sources.list.d/* && sudo apt-get update 193 sudo apt-get --no-install-recommends install -y socat expect lcov net-tools ninja-build 194 cd /tmp 195 wget https://github.com/obgm/libcoap/archive/bsd-licensed.tar.gz 196 tar xvf bsd-licensed.tar.gz 197 cd libcoap-bsd-licensed 198 ./autogen.sh 199 ./configure --prefix= --exec-prefix=/usr --with-boost=internal --disable-tests --disable-documentation 200 make -j2 201 sudo make install 202 - name: Build 203 run: | 204 script/check-posix-pty build 205 - name: Run 206 run: | 207 script/check-posix-pty check 208 - name: Run (OT_DAEMON_ALLOW_ALL) 209 if: matrix.OT_DAEMON == 'on' 210 env: 211 OT_DAEMON_ALLOW_ALL: 1 212 run: | 213 script/check-posix-pty check 214 - name: Generate Coverage 215 run: | 216 ./script/test generate_coverage gcc 217 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 218 with: 219 name: cov-pty-linux-${{ matrix.OT_DAEMON }} 220 path: tmp/coverage.info 221 retention-days: 1 222 223 pty-macos: 224 name: pty-macos OT_DAEMON=${{ matrix.OT_DAEMON }} 225 runs-on: macos-12 226 strategy: 227 fail-fast: false 228 matrix: 229 OT_DAEMON: ['off', 'on'] 230 env: 231 OT_DAEMON: ${{ matrix.OT_DAEMON }} 232 OT_READLINE: 'off' 233 steps: 234 - name: Harden Runner 235 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 236 with: 237 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 238 239 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 240 - name: Bootstrap 241 run: | 242 rm -f /usr/local/bin/2to3 243 rm -f /usr/local/bin/2to3-3.11 244 rm -f /usr/local/bin/idle3 245 rm -f /usr/local/bin/idle3.11 246 rm -f /usr/local/bin/pydoc3 247 rm -f /usr/local/bin/pydoc3.11 248 rm -f /usr/local/bin/python3 249 rm -f /usr/local/bin/python3.11 250 rm -f /usr/local/bin/python3-config 251 rm -f /usr/local/bin/python3.11-config 252 brew update 253 brew install ninja socat 254 - name: Build 255 run: | 256 script/check-posix-pty build 257 - name: Run 258 run: | 259 script/check-posix-pty check 260 261 rcp-stack-reset: 262 runs-on: ubuntu-20.04 263 steps: 264 - name: Harden Runner 265 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 266 with: 267 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 268 269 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 270 - name: Bootstrap 271 env: 272 GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" 273 run: | 274 sudo apt-get --no-install-recommends install -y expect ninja-build lcov socat 275 sudo python3 -m pip install git+https://github.com/openthread/pyspinel 276 - name: Build 277 run: | 278 script/cmake-build simulation -DOT_CSL_RECEIVER=ON -DOT_FULL_LOGS=ON -DOT_LOG_OUTPUT=PLATFORM_DEFINED 279 - name: Run 280 run: | 281 python3 tests/scripts/misc/test_rcp_reset.py build/simulation/examples/apps/ncp/ot-rcp 282 - name: Generate Coverage 283 run: | 284 ./script/test generate_coverage gcc 285 - uses: actions/upload-artifact@834a144ee995460fba8ed112a2fc961b36a5ec5a # v4.3.6 286 with: 287 name: cov-rcp-stack-reset 288 path: tmp/coverage.info 289 retention-days: 1 290 291 upload-coverage: 292 needs: 293 - expects-linux 294 - pty-linux 295 - thread-cert 296 runs-on: ubuntu-20.04 297 steps: 298 - name: Harden Runner 299 uses: step-security/harden-runner@5c7944e73c4c2a096b17a9cb74d65b6c2bbafbde # v2.9.1 300 with: 301 egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs 302 303 - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 304 with: 305 submodules: true 306 - name: Bootstrap 307 run: | 308 sudo apt-get --no-install-recommends install -y lcov 309 - uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7 310 with: 311 path: coverage/ 312 pattern: cov-* 313 merge-multiple: true 314 - name: Combine Coverage 315 run: | 316 script/test combine_coverage 317 - name: Upload Coverage 318 uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0 319 env: 320 CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} 321 with: 322 files: final.info 323 fail_ci_if_error: true 324