Skip to content

Commit 06f42f6

Browse files
nashifkartben
authored andcommitted
twister: Move prep stage to a github runner
Speed things up by using GH runners, we do not need the power of our own runners to create the test plan. This also simplifies the workflow considerably. PRs now will get queued immediately, ie. no need to wait for a Zephyr hosted runner to create the plan and then wait again for another round to get more runners for execution. Signed-off-by: Anas Nashif <[email protected]>
1 parent a0d204c commit 06f42f6

File tree

2 files changed

+96
-151
lines changed

2 files changed

+96
-151
lines changed

.github/workflows/twister-prep.yaml

Lines changed: 0 additions & 150 deletions
This file was deleted.

.github/workflows/twister.yaml

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,102 @@ concurrency:
2424

2525
jobs:
2626
twister-build-prep:
27-
uses: ./.github/workflows/twister-prep.yaml
27+
if: github.repository_owner == 'zephyrproject-rtos'
28+
runs-on: ubuntu-24.04
29+
outputs:
30+
subset: ${{ steps.output-services.outputs.subset }}
31+
size: ${{ steps.output-services.outputs.size }}
32+
fullrun: ${{ steps.output-services.outputs.fullrun }}
33+
env:
34+
MATRIX_SIZE: 10
35+
PUSH_MATRIX_SIZE: 20
36+
WEEKLY_MATRIX_SIZE: 200
37+
BSIM_OUT_PATH: /opt/bsim/
38+
BSIM_COMPONENTS_PATH: /opt/bsim/components
39+
TESTS_PER_BUILDER: 900
40+
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
41+
BASE_REF: ${{ github.base_ref }}
42+
steps:
43+
- name: Checkout
44+
if: github.event_name == 'pull_request'
45+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
46+
with:
47+
ref: ${{ github.event.pull_request.head.sha }}
48+
fetch-depth: 0
49+
path: zephyr
50+
persist-credentials: false
51+
52+
- name: Set up Python
53+
if: github.event_name == 'pull_request'
54+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
55+
with:
56+
python-version: 3.12
57+
cache: pip
58+
cache-dependency-path: scripts/requirements-actions.txt
59+
60+
- name: install-packages
61+
working-directory: zephyr
62+
if: github.event_name == 'pull_request'
63+
run: |
64+
pip install -r scripts/requirements-actions.txt --require-hashes
65+
66+
- name: Setup Zephyr project
67+
if: github.event_name == 'pull_request'
68+
uses: zephyrproject-rtos/action-zephyr-setup@f7b70269a8eb01f70c8e710891e4c94972a2f6b4 # v1.0.6
69+
with:
70+
app-path: zephyr
71+
toolchains: all
72+
73+
- name: Environment Setup
74+
working-directory: zephyr
75+
if: github.event_name == 'pull_request'
76+
run: |
77+
git config --global user.email "[email protected]"
78+
git config --global user.name "Zephyr Bot"
79+
rm -fr ".git/rebase-apply"
80+
rm -fr ".git/rebase-merge"
81+
git rebase origin/${BASE_REF}
82+
git clean -f -d
83+
git log --pretty=oneline | head -n 10
84+
85+
- name: Generate Test Plan with Twister
86+
working-directory: zephyr
87+
if: github.event_name == 'pull_request'
88+
id: test-plan
89+
run: |
90+
export ZEPHYR_BASE=${PWD}
91+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
92+
python3 ./scripts/ci/test_plan.py -c origin/${BASE_REF}.. --no-detailed-test-id --pull-request -t $TESTS_PER_BUILDER
93+
if [ -s .testplan ]; then
94+
cat .testplan >> $GITHUB_ENV
95+
else
96+
echo "TWISTER_NODES=${MATRIX_SIZE}" >> $GITHUB_ENV
97+
fi
98+
rm -f testplan.json .testplan
99+
100+
- name: Determine matrix size
101+
id: output-services
102+
run: |
103+
if [ "${{github.event_name}}" = "push" ]; then
104+
subset="[$(seq -s',' 1 ${PUSH_MATRIX_SIZE})]"
105+
size=${MATRIX_SIZE}
106+
elif [ "${{github.event_name}}" = "pull_request" ]; then
107+
if [ -n "${TWISTER_NODES}" ]; then
108+
subset="[$(seq -s',' 1 ${TWISTER_NODES})]"
109+
else
110+
subset="[$(seq -s',' 1 ${MATRIX_SIZE})]"
111+
fi
112+
size=${TWISTER_NODES}
113+
elif [ "${{github.event_name}}" = "schedule" -a "${{github.repository}}" = "zephyrproject-rtos/zephyr" ]; then
114+
subset="[$(seq -s',' 1 ${WEEKLY_MATRIX_SIZE})]"
115+
size=${WEEKLY_MATRIX_SIZE}
116+
else
117+
size=0
118+
fi
119+
120+
echo "subset=${subset}" >> $GITHUB_OUTPUT
121+
echo "size=${size}" >> $GITHUB_OUTPUT
122+
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
28123
29124
twister-build:
30125
runs-on:

0 commit comments

Comments
 (0)