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