Skip to content

scripts: ci: runci: use defaults and forward arguments to twister #195

scripts: ci: runci: use defaults and forward arguments to twister

scripts: ci: runci: use defaults and forward arguments to twister #195

Workflow file for this run

name: Run tests with twister
on:
push:
branches:
- main
- v*-branch
pull_request:
types:
- opened
- reopened
- synchronize
branches:
- main
- v*-branch
# Disabled for now until a self-hosted runner is available
# schedule:
# # Run at 02:00 UTC on every Sunday
# - cron: '0 2 * * 0'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true
env:
MANIFEST_PATH: modules/lib/posix
ZEPHYR_BASE: ${{ github.workspace }}/zephyr
PLATFORMS: >-
-p mps2/an385
-p native_sim
-p qemu_cortex_a53
-p qemu_riscv64
-p qemu_x86
-p qemu_x86_64
ROOTS: >-
-T ${{ github.workspace }}/modules/lib/posix/samples/posix
-T ${{ github.workspace }}/modules/lib/posix/tests/benchmarks/posix
-T ${{ github.workspace }}/modules/lib/posix/tests/posix
-T ${{ github.workspace }}/zephyr/samples/net
-T ${{ github.workspace }}/zephyr/samples/subsys/shell/shell_module
-T ${{ github.workspace }}/zephyr/tests/net
-T ${{ github.workspace }}/zephyr/tests/lib/c_lib
-T ${{ github.workspace }}/zephyr/kernel/threads/thread_apis
-T ${{ github.workspace }}/zephyr/kernel/signal
jobs:
twister-build:
strategy:
fail-fast: false
runs-on: ubuntu-24.04
steps:
- name: Set up environment
shell: bash
run: |
WEST_INIT_PATH="$(mktemp -d)"
rmdir $WEST_INIT_PATH
WEST_INIT_PATH="$(basename "$WEST_INIT_PATH")"
echo "WEST_INIT_PATH=${WEST_INIT_PATH}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v5
with:
# need history in order to be able to run 'scripts/ci/test_plan.py -c origin/main..'
fetch-depth: 0
# note: checkout to posix-next and then rename to modules/lib/posix as a workaround for the
# assumed west workspace location via 'west init -l modules/lib/posix'. See output of
# 'west init --help' for details.
path: ${{ env.WEST_INIT_PATH }}
- name: Set up Zephyr project
uses: zephyrproject-rtos/action-zephyr-setup@v1.0.9
with:
app-path: ${{ env.WEST_INIT_PATH }}
toolchains: aarch64-zephyr-elf:arm-zephyr-eabi:riscv64-zephyr-elf:x86_64-zephyr-elf
# note: correct location of lib/.west/ to .west/
- name: Re-home module
shell: bash
run: |
MANIFEST_PATH_BASE="$(basename "${{ env.MANIFEST_PATH }}")"
MANIFEST_PATH_DIR="$(dirname "${{ github.workspace }}/${{ env.MANIFEST_PATH }}")"
mkdir -p "$MANIFEST_PATH_DIR"
mv "${{ env.WEST_INIT_PATH }}" "$MANIFEST_PATH_DIR/$MANIFEST_PATH_BASE"
west config -d manifest.path
west config manifest.path "${{ env.MANIFEST_PATH }}"
# Verify binary blobs (skipped, no blobs needed)
- name: Apply patches
shell: bash
run: |
west -v patch apply
- name: Run Tests with Twister (Pull Request)
if: github.event_name == 'pull_request'
shell: bash
working-directory: ${{ env.ZEPHYR_BASE }}
run: |
# copy west.yml to west_old.yml to allow test_plan.py to detect changes
cp ${{ github.workspace }}/${{ env.MANIFEST_PATH }}/west.yml \
${{ github.workspace }}/${{ env.MANIFEST_PATH }}/west_old.yml
# must be run from ZEPHYR_BASE. generates testplan.json
./scripts/ci/test_plan.py -r ${{ github.workspace }}/${{ env.MANIFEST_PATH }} \
-c origin/${{ github.base_ref }}.. --pull-request \
${{ env.PLATFORMS }} \
${{ env.ROOTS }}
# run twister with the generated testplan
# there are about 625 tests that get pulled into this run with the specified platforms
# and roots. for now, hard-coded limit of first 25th of shuffled tests to reduce
# on-diff CI time
./scripts/twister -i -c \
--subset 1/25 --shuffle-tests \
--load-tests testplan.json \
${{ env.PLATFORMS }} \
${{ env.ROOTS }}
- name: Run Tests with Twister (Nightly)
if: github.event_name == 'schedule'
shell: bash
working-directory: ${{ env.ZEPHYR_BASE }}
run: |
west twister -c -i ${{ env.PLATFORMS }} ${{ env.ROOTS }}