Skip to content

Commit 31af4ea

Browse files
committed
ci: twister: split publishing results out of main workflow
Move publishing data to ES to a workflow_run step. This way we can change the main workflow to use pull_request instead of pull_request_target. Signed-off-by: Anas Nashif <[email protected]>
1 parent 0006ba8 commit 31af4ea

File tree

2 files changed

+60
-33
lines changed

2 files changed

+60
-33
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Twister Test Results
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Run tests with twister"]
6+
branches:
7+
- main
8+
- v*
9+
types:
10+
- completed
11+
12+
jobs:
13+
upload-to-elasticsearch:
14+
if: github.repository == 'zephyrproject-rtos/zephyr'
15+
env:
16+
ELASTICSEARCH_KEY: ${{ secrets.ELASTICSEARCH_KEY }}
17+
ELASTICSEARCH_SERVER: "https://elasticsearch.zephyrproject.io:443"
18+
runs-on: ubuntu-22.04
19+
steps:
20+
# Needed for elasticearch and upload script
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
with:
24+
fetch-depth: 0
25+
persist-credentials: false
26+
27+
- name: Download Artifacts
28+
uses: dawidd6/action-download-artifact@v6
29+
with:
30+
path: artifacts
31+
workflow: twister.yml
32+
run_id: ${{ github.event.workflow_run.id }}
33+
34+
- name: Upload to elasticsearch
35+
run: |
36+
pip3 install elasticsearch
37+
# set run date on upload to get consistent and unified data across the matrix.
38+
run_date=`date --iso-8601=minutes`
39+
if [ "${{github.event_name}}" = "push" ]; then
40+
python3 ./scripts/ci/upload_test_results_es.py -r ${run_date} \
41+
--run-attempt ${{github.run_attempt}} \
42+
--index zephyr-main-ci-push-1 artifacts/*/*/twister.json
43+
elif [ "${{github.event_name}}" = "schedule" ]; then
44+
python3 ./scripts/ci/upload_test_results_es.py -r ${run_date} \
45+
--run-attempt ${{github.run_attempt}} \
46+
--index zephyr-main-ci-weekly-1 artifacts/*/*/twister.json
47+
fi

.github/workflows/twister.yaml

Lines changed: 13 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- main
77
- v*-branch
88
- collab-*
9+
- topic/ci/upload_results
910
pull_request_target:
1011
branches:
1112
- main
@@ -22,11 +23,11 @@ concurrency:
2223
jobs:
2324
twister-build-prep:
2425
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'
26+
runs-on:
27+
group: zephyr-runner-v2-linux-x64-4xlarge
28+
container:
29+
image: ghcr.io/zephyrproject-rtos/ci-repo-cache:v0.27.4.20241026
30+
options: '--entrypoint /bin/bash'
3031
outputs:
3132
subset: ${{ steps.output-services.outputs.subset }}
3233
size: ${{ steps.output-services.outputs.size }}
@@ -230,11 +231,12 @@ jobs:
230231

231232
- if: github.event_name == 'push'
232233
name: Run Tests with Twister (Push)
234+
id: run_twister
233235
run: |
234236
export ZEPHYR_BASE=${PWD}
235237
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
236-
./scripts/twister --subset ${{matrix.subset}}/${{ strategy.job-total }} ${TWISTER_COMMON} ${PUSH_OPTIONS}
237-
if [ "${{matrix.subset}}" = "1" ]; then
238+
./scripts/twister -T tests/kernel/threads -p qemu_x86 --subset ${{matrix.subset}}/${{ strategy.job-total }} ${TWISTER_COMMON} ${PUSH_OPTIONS}
239+
if [ "${{matrix.subset}}" = "11" ]; then
238240
./scripts/zephyr_module.py --twister-out module_tests.args
239241
if [ -s module_tests.args ]; then
240242
./scripts/twister +module_tests.args --outdir module_tests ${TWISTER_COMMON} ${PUSH_OPTIONS}
@@ -243,6 +245,7 @@ jobs:
243245

244246
- if: github.event_name == 'pull_request_target'
245247
name: Run Tests with Twister (Pull Request)
248+
id: run_twister_pr
246249
run: |
247250
rm -f testplan.json
248251
export ZEPHYR_BASE=${PWD}
@@ -258,6 +261,7 @@ jobs:
258261

259262
- if: github.event_name == 'schedule'
260263
name: Run Tests with Twister (Daily)
264+
id: run_twister_sched
261265
run: |
262266
export ZEPHYR_BASE=${PWD}
263267
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
@@ -306,42 +310,18 @@ jobs:
306310

307311
twister-test-results:
308312
name: "Publish Unit Tests Results"
309-
env:
310-
ELASTICSEARCH_KEY: ${{ secrets.ELASTICSEARCH_KEY }}
311-
ELASTICSEARCH_SERVER: "https://elasticsearch.zephyrproject.io:443"
312-
needs: twister-build
313+
needs:
314+
- twister-build
313315
runs-on: ubuntu-22.04
314316
# the build-and-test job might be skipped, we don't need to run this job then
315317
if: success() || failure()
316318

317319
steps:
318-
# Needed for elasticearch and upload script
319-
- if: github.event_name == 'push' || github.event_name == 'schedule'
320-
name: Checkout
321-
uses: actions/checkout@v4
322-
with:
323-
fetch-depth: 0
324-
persist-credentials: false
325-
326320
- name: Download Artifacts
327321
uses: actions/download-artifact@v4
328322
with:
329323
path: artifacts
330324

331-
- if: github.event_name == 'push' || github.event_name == 'schedule'
332-
name: Upload to elasticsearch
333-
run: |
334-
pip3 install elasticsearch
335-
# set run date on upload to get consistent and unified data across the matrix.
336-
run_date=`date --iso-8601=minutes`
337-
if [ "${{github.event_name}}" = "push" ]; then
338-
python3 ./scripts/ci/upload_test_results_es.py -r ${run_date} \
339-
--index zephyr-main-ci-push-1 artifacts/*/*/twister.json
340-
elif [ "${{github.event_name}}" = "schedule" ]; then
341-
python3 ./scripts/ci/upload_test_results_es.py -r ${run_date} \
342-
--index zephyr-main-ci-weekly-1 artifacts/*/*/twister.json
343-
fi
344-
345325
- name: Merge Test Results
346326
run: |
347327
pip3 install junitparser junit2html

0 commit comments

Comments
 (0)