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 paths: 11 - 'scripts/pylib/twister/**' 12 - 'scripts/twister' 13 - 'scripts/tests/twister_blackbox/**' 14 - '.github/workflows/twister_tests_blackbox.yml' 15 16jobs: 17 twister-tests: 18 name: Twister Black Box Tests 19 runs-on: ${{ matrix.os }} 20 strategy: 21 matrix: 22 python-version: [3.8, 3.9, '3.10', '3.11', '3.12'] 23 os: [ubuntu-22.04] 24 container: 25 image: ghcr.io/zephyrproject-rtos/ci:v0.26.7 26 27 steps: 28 - name: Apply Container Owner Mismatch Workaround 29 run: | 30 # FIXME: The owner UID of the GITHUB_WORKSPACE directory may not 31 # match the container user UID because of the way GitHub 32 # Actions runner is implemented. Remove this workaround when 33 # GitHub comes up with a fundamental fix for this problem. 34 git config --global --add safe.directory ${GITHUB_WORKSPACE} 35 36 - name: Checkout 37 uses: actions/checkout@v4 38 39 - name: Environment Setup 40 run: | 41 echo "$HOME/.local/bin" >> $GITHUB_PATH 42 43 west init -l . || true 44 west config --global update.narrow true 45 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) 46 west forall -c 'git reset --hard HEAD' 47 48 echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV 49 50 - name: Set Up Python ${{ matrix.python-version }} 51 uses: actions/setup-python@v4 52 with: 53 python-version: ${{ matrix.python-version }} 54 55 - name: Go Into Venv 56 shell: bash 57 run: | 58 python3 -m pip install --user virtualenv 59 python3 -m venv env 60 source env/bin/activate 61 echo "$(which python)" 62 63 - name: Install Packages 64 run: | 65 python3 -m pip install -U -r scripts/requirements-base.txt -r scripts/requirements-build-test.txt -r scripts/requirements-run-test.txt 66 67 - name: Run Pytest For Twister Black Box Tests 68 shell: bash 69 env: 70 ZEPHYR_BASE: ./ 71 ZEPHYR_TOOLCHAIN_VARIANT: zephyr 72 run: | 73 echo "Run twister tests" 74 source zephyr-env.sh 75 PYTHONPATH="./scripts/tests" pytest ./scripts/tests/twister_blackbox 76 77 - name: Upload Unit Test Results 78 if: success() || failure() 79 uses: actions/upload-artifact@v2 80 with: 81 name: Black Box Test Results (Python ${{ matrix.python-version }}) 82 path: | 83 twister-out*/twister.log 84 twister-out*/twister.json 85 twister-out*/testplan.log 86 retention-days: 14 87 88 - name: Clear Workspace 89 if: success() || failure() 90 run: | 91 rm -rf twister-out*/ 92