1#
2#  Copyright (c) 2021, 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: Border Router
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  backbone-router:
49    runs-on: ubuntu-22.04
50    env:
51      REFERENCE_DEVICE: 1
52      VIRTUAL_TIME: 0
53      PACKET_VERIFICATION: 1
54      THREAD_VERSION: 1.4
55      INTER_OP: 1
56      COVERAGE: 1
57      MULTIPLY: 1
58      PYTHONUNBUFFERED: 1
59      VERBOSE: 1
60      # The Border Routing and DUA feature can coexist, but current wireshark
61      # packet verification can't handle it because of the order of context ID
62      # of OMR prefix and Domain prefix is not deterministic.
63      BORDER_ROUTING: 0
64    steps:
65    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
66      with:
67        submodules: true
68    - name: Build OTBR Docker
69      env:
70        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
71      run: |
72        ./script/test build_otbr_docker
73    - name: Bootstrap
74      run: |
75        sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
76        sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build socat lcov
77        python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
78    - name: Build
79      run: |
80        ./script/test build
81    - name: Get Thread-Wireshark
82      run: |
83        ./script/test get_thread_wireshark
84    - name: Run
85      run: |
86        export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
87        echo "CI_ENV=${CI_ENV}"
88        sudo -E ./script/test cert_suite ./tests/scripts/thread-cert/backbone/*.py || (sudo chmod a+r ot_testing/* && false)
89    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
90      with:
91        name: cov-thread-1-3-backbone-docker
92        path: /tmp/coverage/
93        retention-days: 1
94    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
95      if: ${{ failure() }}
96      with:
97        name: thread-1-3-backbone-results
98        path: |
99          ot_testing/*.pcap
100          ot_testing/*.json
101          ot_testing/*.log
102          ot_testing/coredump_*
103          ot_testing/otbr-agent_*
104    - name: Generate Coverage
105      run: |
106        ./script/test generate_coverage gcc
107    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
108      with:
109        name: cov-thread-1-3-backbone
110        path: tmp/coverage.info
111        retention-days: 1
112
113  thread-border-router:
114    runs-on: ubuntu-22.04
115    strategy:
116      fail-fast: false
117      matrix:
118        include:
119          - otbr_mdns: "mDNSResponder"
120            otbr_trel: 0
121            cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
122            packet_verification: 1
123            nat64: 0
124            description: ""
125          - otbr_mdns: "mDNSResponder"
126            otbr_trel: 1
127            cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
128            packet_verification: 2
129            nat64: 0
130            description: ""
131          - otbr_mdns: "mDNSResponder"
132            otbr_trel: 0
133            cert_scripts: ./tests/scripts/thread-cert/border_router/MATN/*.py
134            packet_verification: 1
135            nat64: 0
136            description: "MATN"
137          - otbr_mdns: "mDNSResponder"
138            otbr_trel: 0
139            cert_scripts: ./tests/scripts/thread-cert/border_router/LowPower/*.py
140            packet_verification: 1
141            nat64: 0
142            description: "LowPower"
143          - otbr_mdns: "mDNSResponder"
144            otbr_trel: 0
145            cert_scripts: ./tests/scripts/thread-cert/border_router/internet/*.py
146            packet_verification: 1
147            nat64: 1
148            description: "internet access"
149          - otbr_mdns: "avahi"
150            otbr_trel: 0
151            cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
152            packet_verification: 1
153            nat64: 0
154            description: ""
155          - otbr_mdns: "avahi"
156            otbr_trel: 1
157            cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
158            packet_verification: 2
159            nat64: 0
160            description: ""
161          - otbr_mdns: "avahi"
162            otbr_trel: 0
163            cert_scripts: ./tests/scripts/thread-cert/border_router/*.py
164            packet_verification: 1
165            nat64: 0
166            use_core_firewall: 1
167            description: "core-firewall"
168    name: BR ${{ matrix.description }} (${{ matrix.otbr_mdns }}, TREL=${{matrix.otbr_trel}})
169    env:
170      REFERENCE_DEVICE: 1
171      VIRTUAL_TIME: 0
172      PACKET_VERIFICATION: ${{ matrix.packet_verification }}
173      THREAD_VERSION: 1.4
174      INTER_OP: 1
175      COVERAGE: 1
176      MULTIPLY: 1
177      OTBR_MDNS: ${{ matrix.otbr_mdns }}
178      PYTHONUNBUFFERED: 1
179      VERBOSE: 1
180      BORDER_ROUTING: 1
181      NAT64: ${{ matrix.nat64 }}
182      MAX_JOBS: 3
183    steps:
184    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
185    - name: Set firewall environment variables
186      if: ${{ matrix.use_core_firewall }}
187      run: |
188        echo "FIREWALL=0" >> $GITHUB_ENV
189    - name: Build OTBR Docker
190      env:
191        GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
192        TREL: ${{ matrix.otbr_trel }}
193      run: |
194        ./script/test build_otbr_docker
195    - name: Bootstrap
196      run: |
197        sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
198        sudo apt-get --no-install-recommends install -y python3-setuptools python3-wheel ninja-build socat lcov
199        python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
200    - name: Build
201      run: |
202        ./script/test build
203    - name: Get Thread-Wireshark
204      run: |
205        ./script/test get_thread_wireshark
206    - name: Run
207      run: |
208        export CI_ENV="$(bash <(curl -s https://codecov.io/env)) -e GITHUB_ACTIONS -e COVERAGE"
209        echo "CI_ENV=${CI_ENV}"
210        sudo -E ./script/test cert_suite ${{ matrix.cert_scripts }} || (sudo chmod a+r ot_testing/* && false)
211    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
212      with:
213        name: cov-br-docker-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
214        path: /tmp/coverage/
215        retention-days: 1
216    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
217      if: ${{ failure() }}
218      with:
219        name: br-results-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
220        path: |
221          ot_testing/*.pcap
222          ot_testing/*.json
223          ot_testing/*.log
224          ot_testing/coredump_*
225          ot_testing/otbr-agent_*
226    - name: Generate Coverage
227      run: |
228        ./script/test generate_coverage gcc
229    - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3
230      with:
231        name: cov-br-${{ matrix.description }}-${{ matrix.otbr_mdns }}-${{matrix.otbr_trel}}
232        path: tmp/coverage.info
233        retention-days: 1
234
235  upload-coverage:
236    needs:
237    - backbone-router
238    - thread-border-router
239    runs-on: ubuntu-22.04
240    steps:
241    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
242      with:
243        submodules: true
244    - name: Bootstrap
245      run: |
246        sudo apt-get --no-install-recommends install -y lcov
247    - uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8
248      with:
249        path: coverage/
250        pattern: cov-*
251        merge-multiple: true
252    - name: Combine Coverage
253      continue-on-error: true
254      run: |
255        script/test combine_coverage
256    - name: Upload Coverage
257      continue-on-error: true
258      uses: codecov/codecov-action@e28ff129e5465c2c0dcc6f003fc735cb6ae0c673 # v4.5.0
259      env:
260        CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
261      with:
262        files: final.info
263        fail_ci_if_error: true
264