1# Copyright (c) 2023 Intel Corporation.
2# SPDX-License-Identifier: Apache-2.0
3
4name: Twister BlackBox TestSuite
5
6on:
7  pull_request:
8    branches:
9    - main
10    - collab-*
11    - v*-branch
12    paths:
13    - 'scripts/pylib/twister/**'
14    - 'scripts/twister'
15    - 'scripts/tests/twister_blackbox/**'
16    - '.github/workflows/twister_tests_blackbox.yml'
17
18jobs:
19  twister-tests:
20    name: Twister Black Box Tests
21    runs-on: ${{ matrix.os }}
22    strategy:
23      matrix:
24        python-version: ['3.10', '3.11', '3.12', '3.13']
25        os: [ubuntu-22.04]
26    container:
27      image: ghcr.io/zephyrproject-rtos/ci:v0.27.4
28
29    steps:
30    - name: Apply Container Owner Mismatch Workaround
31      run: |
32        # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
33        #        match the container user UID because of the way GitHub
34        #        Actions runner is implemented. Remove this workaround when
35        #        GitHub comes up with a fundamental fix for this problem.
36        git config --global --add safe.directory ${GITHUB_WORKSPACE}
37
38    - name: Checkout
39      uses: actions/checkout@v4
40
41    - name: Environment Setup
42      run: |
43        echo "$HOME/.local/bin" >> $GITHUB_PATH
44
45        west init -l . || true
46        # we do not depend on any hals, tools or bootloader, save some time and space...
47        west config manifest.group-filter -- -hal,-tools,-bootloader,-babblesim
48        west config manifest.project-filter -- -nrf_hw_models
49        west config --global update.narrow true
50        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)
51        west forall -c 'git reset --hard HEAD'
52
53        echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
54
55    - name: Set Up Python ${{ matrix.python-version }}
56      uses: actions/setup-python@v5
57      with:
58        python-version: ${{ matrix.python-version }}
59
60    - name: Go Into Venv
61      shell: bash
62      run: |
63        python3 -m pip install --user virtualenv
64        python3 -m venv env
65        source env/bin/activate
66        echo "$(which python)"
67
68    - name: Install Packages
69      run: |
70        python3 -m pip install -U -r scripts/requirements-base.txt -r scripts/requirements-build-test.txt -r scripts/requirements-run-test.txt
71
72    - name: Run Pytest For Twister Black Box Tests
73      shell: bash
74      env:
75        ZEPHYR_BASE: ./
76        ZEPHYR_TOOLCHAIN_VARIANT: zephyr
77      run: |
78        echo "Run twister tests"
79        source zephyr-env.sh
80        PYTHONPATH="./scripts/tests" pytest ./scripts/tests/twister_blackbox
81