Skip to content

Commit 0a8b166

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 903b7cf commit 0a8b166

File tree

2 files changed

+52
-26
lines changed

2 files changed

+52
-26
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Publish 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: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ jobs:
230230
231231
- if: github.event_name == 'push'
232232
name: Run Tests with Twister (Push)
233+
id: run_twister
233234
run: |
234235
export ZEPHYR_BASE=${PWD}
235236
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
@@ -243,6 +244,7 @@ jobs:
243244
244245
- if: github.event_name == 'pull_request_target'
245246
name: Run Tests with Twister (Pull Request)
247+
id: run_twister_pr
246248
run: |
247249
rm -f testplan.json
248250
export ZEPHYR_BASE=${PWD}
@@ -258,6 +260,7 @@ jobs:
258260
259261
- if: github.event_name == 'schedule'
260262
name: Run Tests with Twister (Daily)
263+
id: run_twister_sched
261264
run: |
262265
export ZEPHYR_BASE=${PWD}
263266
export ZEPHYR_TOOLCHAIN_VARIANT=zephyr
@@ -306,42 +309,18 @@ jobs:
306309
307310
twister-test-results:
308311
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
312+
needs:
313+
- twister-build
313314
runs-on: ubuntu-22.04
314315
# the build-and-test job might be skipped, we don't need to run this job then
315316
if: success() || failure()
316317

317318
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-
326319
- name: Download Artifacts
327320
uses: actions/download-artifact@v4
328321
with:
329322
path: artifacts
330323

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-
345324
- name: Merge Test Results
346325
run: |
347326
pip3 install junitparser junit2html

0 commit comments

Comments
 (0)