Skip to content

Commit 6f99f23

Browse files
committed
workflow_call
Signed-off-by: Anas Nashif <[email protected]>
1 parent 04d7412 commit 6f99f23

File tree

3 files changed

+285
-102
lines changed

3 files changed

+285
-102
lines changed

.github/workflows/twister-pr.yaml

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
name: Prep PR
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
subset:
7+
description: subset
8+
value: ${{ jobs.prep.outputs.subset }}
9+
size:
10+
description: size
11+
value: ${{ jobs.prep.outputs.size }}
12+
fullrun:
13+
description: fullrun
14+
value: ${{ jobs.prep.outputs.fullrun }}
15+
16+
jobs:
17+
prep:
18+
if: github.repository_owner == 'zephyrproject-rtos'
19+
runs-on:
20+
group: zephyr-runner-v2-linux-x64-4xlarge
21+
container:
22+
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
23+
options: '--entrypoint /bin/bash'
24+
outputs:
25+
subset: ${{ steps.output-services.outputs.subset }}
26+
size: ${{ steps.output-services.outputs.size }}
27+
fullrun: ${{ steps.output-services.outputs.fullrun }}
28+
env:
29+
MATRIX_SIZE: 10
30+
PUSH_MATRIX_SIZE: 20
31+
DAILY_MATRIX_SIZE: 80
32+
BSIM_OUT_PATH: /opt/bsim/
33+
BSIM_COMPONENTS_PATH: /opt/bsim/components
34+
TESTS_PER_BUILDER: 700
35+
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
36+
BASE_REF: ${{ github.base_ref }}
37+
steps:
38+
- name: Apply container owner mismatch workaround
39+
run: |
40+
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
41+
# match the container user UID because of the way GitHub
42+
# Actions runner is implemented. Remove this workaround when
43+
# GitHub comes up with a fundamental fix for this problem.
44+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
45+
46+
- name: Print cloud service information
47+
run: |
48+
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
49+
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
50+
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
51+
52+
- name: Clone cached Zephyr repository
53+
continue-on-error: true
54+
run: |
55+
git clone --shared /repo-cache/zephyrproject/zephyr .
56+
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
57+
58+
- name: Checkout
59+
uses: actions/checkout@v4
60+
with:
61+
ref: ${{ github.event.pull_request.head.sha }}
62+
fetch-depth: 0
63+
persist-credentials: false
64+
65+
- name: Environment Setup
66+
run: |
67+
git config --global user.email "[email protected]"
68+
git config --global user.name "Zephyr Bot"
69+
rm -fr ".git/rebase-apply"
70+
git rebase origin/${BASE_REF}
71+
git clean -f -d
72+
git log --pretty=oneline | head -n 10
73+
west init -l . || true
74+
west config manifest.group-filter -- +ci,+optional
75+
west config --global update.narrow true
76+
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
77+
west forall -c 'git reset --hard HEAD'
78+
79+
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
80+
81+
- name: Generate Test Plan with Twister
82+
id: test-plan
83+
run: |
84+
export ZEPHYR_BASE=${PWD}
85+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
86+
python3 ./scripts/ci/test_plan.py -c origin/${BASE_REF}.. --pull-request -t $TESTS_PER_BUILDER
87+
if [ -s .testplan ]; then
88+
cat .testplan >> $GITHUB_ENV
89+
else
90+
echo "TWISTER_NODES=${MATRIX_SIZE}" >> $GITHUB_ENV
91+
fi
92+
rm -f testplan.json .testplan
93+
94+
- name: Determine matrix size
95+
id: output-services
96+
run: |
97+
if [ "${{github.event_name}}" = "pull_request_target" ]; then
98+
if [ -n "${TWISTER_NODES}" ]; then
99+
subset="[$(seq -s',' 1 ${TWISTER_NODES})]"
100+
else
101+
subset="[$(seq -s',' 1 ${MATRIX_SIZE})]"
102+
fi
103+
size=${TWISTER_NODES}
104+
elif [ "${{github.event_name}}" = "push" ]; then
105+
subset="[$(seq -s',' 1 ${PUSH_MATRIX_SIZE})]"
106+
size=${MATRIX_SIZE}
107+
elif [ "${{github.event_name}}" = "schedule" -a "${{github.repository}}" = "zephyrproject-rtos/zephyr" ]; then
108+
subset="[$(seq -s',' 1 ${DAILY_MATRIX_SIZE})]"
109+
size=${DAILY_MATRIX_SIZE}
110+
else
111+
size=0
112+
fi
113+
echo "subset=${subset}" >> $GITHUB_OUTPUT
114+
echo "size=${size}" >> $GITHUB_OUTPUT
115+
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
name: Prep
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
subset:
7+
description: subset
8+
value: ${{ jobs.prep_push.outputs.subset }} || ${{ jobs.prep_pr.outputs.subset }}
9+
size:
10+
description: size
11+
value: ${{ jobs.prep_push.outputs.size }} || ${{ jobs.prep_pr.outputs.size }}
12+
fullrun:
13+
description: fullrun
14+
value: ${{ jobs.prep_push.outputs.fullrun }} || ${{ jobs.prep_pr.outputs.size }}
15+
16+
jobs:
17+
prep_pr:
18+
if: github.repository_owner == 'zephyrproject-rtos' && github.event_name == 'pull_request_target'
19+
runs-on:
20+
group: zephyr-runner-v2-linux-x64-4xlarge
21+
container:
22+
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
23+
options: '--entrypoint /bin/bash'
24+
outputs:
25+
subset: ${{ steps.output-services.outputs.subset }}
26+
size: ${{ steps.output-services.outputs.size }}
27+
fullrun: ${{ steps.output-services.outputs.fullrun }}
28+
env:
29+
MATRIX_SIZE: 10
30+
PUSH_MATRIX_SIZE: 20
31+
DAILY_MATRIX_SIZE: 80
32+
BSIM_OUT_PATH: /opt/bsim/
33+
BSIM_COMPONENTS_PATH: /opt/bsim/components
34+
TESTS_PER_BUILDER: 700
35+
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
36+
BASE_REF: ${{ github.base_ref }}
37+
steps:
38+
- name: Apply container owner mismatch workaround
39+
run: |
40+
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
41+
# match the container user UID because of the way GitHub
42+
# Actions runner is implemented. Remove this workaround when
43+
# GitHub comes up with a fundamental fix for this problem.
44+
git config --global --add safe.directory ${GITHUB_WORKSPACE}
45+
46+
- name: Print cloud service information
47+
run: |
48+
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
49+
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
50+
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
51+
52+
- name: Clone cached Zephyr repository
53+
if: github.event_name == 'pull_request_target'
54+
continue-on-error: true
55+
run: |
56+
git clone --shared /repo-cache/zephyrproject/zephyr .
57+
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
58+
59+
- name: Checkout
60+
if: github.event_name == 'pull_request_target'
61+
uses: actions/checkout@v4
62+
with:
63+
ref: ${{ github.event.pull_request.head.sha }}
64+
fetch-depth: 0
65+
persist-credentials: false
66+
67+
- name: Environment Setup
68+
if: github.event_name == 'pull_request_target'
69+
run: |
70+
git config --global user.email "[email protected]"
71+
git config --global user.name "Zephyr Bot"
72+
rm -fr ".git/rebase-apply"
73+
git rebase origin/${BASE_REF}
74+
git clean -f -d
75+
git log --pretty=oneline | head -n 10
76+
west init -l . || true
77+
west config manifest.group-filter -- +ci,+optional
78+
west config --global update.narrow true
79+
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
80+
west forall -c 'git reset --hard HEAD'
81+
82+
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
83+
84+
- name: Generate Test Plan with Twister
85+
if: github.event_name == 'pull_request_target'
86+
id: test-plan
87+
run: |
88+
export ZEPHYR_BASE=${PWD}
89+
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
90+
python3 ./scripts/ci/test_plan.py -c origin/${BASE_REF}.. --pull-request -t $TESTS_PER_BUILDER
91+
if [ -s .testplan ]; then
92+
cat .testplan >> $GITHUB_ENV
93+
else
94+
echo "TWISTER_NODES=${MATRIX_SIZE}" >> $GITHUB_ENV
95+
fi
96+
rm -f testplan.json .testplan
97+
98+
- name: Determine matrix size
99+
id: output-services
100+
run: |
101+
if [ "${{github.event_name}}" = "pull_request_target" ]; then
102+
if [ -n "${TWISTER_NODES}" ]; then
103+
subset="[$(seq -s',' 1 ${TWISTER_NODES})]"
104+
else
105+
subset="[$(seq -s',' 1 ${MATRIX_SIZE})]"
106+
fi
107+
size=${TWISTER_NODES}
108+
elif [ "${{github.event_name}}" = "push" ]; then
109+
subset="[$(seq -s',' 1 ${PUSH_MATRIX_SIZE})]"
110+
size=${MATRIX_SIZE}
111+
elif [ "${{github.event_name}}" = "schedule" -a "${{github.repository}}" = "zephyrproject-rtos/zephyr" ]; then
112+
subset="[$(seq -s',' 1 ${DAILY_MATRIX_SIZE})]"
113+
size=${DAILY_MATRIX_SIZE}
114+
else
115+
size=0
116+
fi
117+
echo "subset=${subset}" >> $GITHUB_OUTPUT
118+
echo "size=${size}" >> $GITHUB_OUTPUT
119+
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
120+
121+
prep_push:
122+
if: github.repository_owner == 'zephyrproject-rtos' && github.event_name == 'push'
123+
runs-on: ubuntu-22.04
124+
outputs:
125+
subset: ${{ steps.output-services.outputs.subset }}
126+
size: ${{ steps.output-services.outputs.size }}
127+
fullrun: ${{ steps.output-services.outputs.fullrun }}
128+
env:
129+
MATRIX_SIZE: 10
130+
PUSH_MATRIX_SIZE: 20
131+
DAILY_MATRIX_SIZE: 80
132+
BSIM_OUT_PATH: /opt/bsim/
133+
BSIM_COMPONENTS_PATH: /opt/bsim/components
134+
TESTS_PER_BUILDER: 700
135+
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
136+
BASE_REF: ${{ github.base_ref }}
137+
steps:
138+
- name: Print cloud service information
139+
run: |
140+
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
141+
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
142+
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
143+
144+
- name: Determine matrix size
145+
id: output-services
146+
run: |
147+
if [ "${{github.event_name}}" = "pull_request_target" ]; then
148+
if [ -n "${TWISTER_NODES}" ]; then
149+
subset="[$(seq -s',' 1 ${TWISTER_NODES})]"
150+
else
151+
subset="[$(seq -s',' 1 ${MATRIX_SIZE})]"
152+
fi
153+
size=${TWISTER_NODES}
154+
elif [ "${{github.event_name}}" = "push" ]; then
155+
subset="[$(seq -s',' 1 ${PUSH_MATRIX_SIZE})]"
156+
size=${MATRIX_SIZE}
157+
elif [ "${{github.event_name}}" = "schedule" -a "${{github.repository}}" = "zephyrproject-rtos/zephyr" ]; then
158+
subset="[$(seq -s',' 1 ${DAILY_MATRIX_SIZE})]"
159+
size=${DAILY_MATRIX_SIZE}
160+
else
161+
size=0
162+
fi
163+
echo ${subset}
164+
echo ${size}
165+
166+
echo "subset=${subset}" >> $GITHUB_OUTPUT
167+
echo "size=${size}" >> $GITHUB_OUTPUT
168+
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
169+

.github/workflows/twister.yaml

Lines changed: 1 addition & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -21,108 +21,7 @@ concurrency:
2121

2222
jobs:
2323
twister-build-prep:
24-
if: github.repository_owner == 'zephyrproject-rtos'
25-
runs-on:
26-
group: zephyr-runner-v2-linux-x64-4xlarge
27-
container:
28-
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
29-
options: '--entrypoint /bin/bash'
30-
outputs:
31-
subset: ${{ steps.output-services.outputs.subset }}
32-
size: ${{ steps.output-services.outputs.size }}
33-
fullrun: ${{ steps.output-services.outputs.fullrun }}
34-
env:
35-
MATRIX_SIZE: 10
36-
PUSH_MATRIX_SIZE: 20
37-
DAILY_MATRIX_SIZE: 80
38-
BSIM_OUT_PATH: /opt/bsim/
39-
BSIM_COMPONENTS_PATH: /opt/bsim/components
40-
TESTS_PER_BUILDER: 700
41-
COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
42-
BASE_REF: ${{ github.base_ref }}
43-
steps:
44-
- name: Apply container owner mismatch workaround
45-
run: |
46-
# FIXME: The owner UID of the GITHUB_WORKSPACE directory may not
47-
# match the container user UID because of the way GitHub
48-
# Actions runner is implemented. Remove this workaround when
49-
# GitHub comes up with a fundamental fix for this problem.
50-
git config --global --add safe.directory ${GITHUB_WORKSPACE}
51-
52-
- name: Print cloud service information
53-
run: |
54-
echo "ZEPHYR_RUNNER_CLOUD_PROVIDER = ${ZEPHYR_RUNNER_CLOUD_PROVIDER}"
55-
echo "ZEPHYR_RUNNER_CLOUD_NODE = ${ZEPHYR_RUNNER_CLOUD_NODE}"
56-
echo "ZEPHYR_RUNNER_CLOUD_POD = ${ZEPHYR_RUNNER_CLOUD_POD}"
57-
58-
- name: Clone cached Zephyr repository
59-
if: github.event_name == 'pull_request_target'
60-
continue-on-error: true
61-
run: |
62-
git clone --shared /repo-cache/zephyrproject/zephyr .
63-
git remote set-url origin ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}
64-
65-
- name: Checkout
66-
if: github.event_name == 'pull_request_target'
67-
uses: actions/checkout@v4
68-
with:
69-
ref: ${{ github.event.pull_request.head.sha }}
70-
fetch-depth: 0
71-
persist-credentials: false
72-
73-
- name: Environment Setup
74-
if: github.event_name == 'pull_request_target'
75-
run: |
76-
git config --global user.email "[email protected]"
77-
git config --global user.name "Zephyr Bot"
78-
rm -fr ".git/rebase-apply"
79-
git rebase origin/${BASE_REF}
80-
git clean -f -d
81-
git log --pretty=oneline | head -n 10
82-
west init -l . || true
83-
west config manifest.group-filter -- +ci,+optional
84-
west config --global update.narrow true
85-
west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || west update --path-cache /repo-cache/zephyrproject 2>&1 1> west.update.log || ( rm -rf ../modules ../bootloader ../tools && west update --path-cache /repo-cache/zephyrproject)
86-
west forall -c 'git reset --hard HEAD'
87-
88-
echo "ZEPHYR_SDK_INSTALL_DIR=/opt/toolchains/zephyr-sdk-$( cat SDK_VERSION )" >> $GITHUB_ENV
89-
90-
- name: Generate Test Plan with Twister
91-
if: github.event_name == 'pull_request_target'
92-
id: test-plan
93-
run: |
94-
export ZEPHYR_BASE=${PWD}
95-
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
96-
python3 ./scripts/ci/test_plan.py -c origin/${BASE_REF}.. --pull-request -t $TESTS_PER_BUILDER
97-
if [ -s .testplan ]; then
98-
cat .testplan >> $GITHUB_ENV
99-
else
100-
echo "TWISTER_NODES=${MATRIX_SIZE}" >> $GITHUB_ENV
101-
fi
102-
rm -f testplan.json .testplan
103-
104-
- name: Determine matrix size
105-
id: output-services
106-
run: |
107-
if [ "${{github.event_name}}" = "pull_request_target" ]; then
108-
if [ -n "${TWISTER_NODES}" ]; then
109-
subset="[$(seq -s',' 1 ${TWISTER_NODES})]"
110-
else
111-
subset="[$(seq -s',' 1 ${MATRIX_SIZE})]"
112-
fi
113-
size=${TWISTER_NODES}
114-
elif [ "${{github.event_name}}" = "push" ]; then
115-
subset="[$(seq -s',' 1 ${PUSH_MATRIX_SIZE})]"
116-
size=${MATRIX_SIZE}
117-
elif [ "${{github.event_name}}" = "schedule" -a "${{github.repository}}" = "zephyrproject-rtos/zephyr" ]; then
118-
subset="[$(seq -s',' 1 ${DAILY_MATRIX_SIZE})]"
119-
size=${DAILY_MATRIX_SIZE}
120-
else
121-
size=0
122-
fi
123-
echo "subset=${subset}" >> $GITHUB_OUTPUT
124-
echo "size=${size}" >> $GITHUB_OUTPUT
125-
echo "fullrun=${TWISTER_FULL}" >> $GITHUB_OUTPUT
24+
uses: ./.github/workflows/twister-push.yaml
12625

12726
twister-build:
12827
runs-on:

0 commit comments

Comments
 (0)