File: test.yml

package info (click to toggle)
fastrpc 1.0.2-2
  • links: PTS, VCS
  • area: contrib
  • in suites: forky, sid
  • size: 2,816 kB
  • sloc: ansic: 30,070; makefile: 230; sh: 31
file content (118 lines) | stat: -rw-r--r-- 5,046 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
name: test
description: |
  Run tests on LAVA for a specified target using a Docker image.
  This reusable GitHub Actions workflow executes FastRPC tests on LAVA infrastructure.
  It leverages a Docker image for test execution and supports multi-target builds via a matrix strategy.
  The workflow automates job creation, submission, and result validation on LAVA,
  providing a streamlined testing process.
  Designed to be triggered by other workflows, it offers a summary of test outcomes
  with direct links to LAVA job results, enhancing traceability and debugging.

on:
  workflow_call:
    inputs:
      docker_image:
        description: Docker image
        type: string
        required: true
        default: fastrpc-image:latest

      build_matrix:
        description: Build matrix for multi target builds
        type: string
        required: true

jobs:
  test:
    runs-on:
      group: GHA-fastrpc-Prd-SelfHosted-RG
      labels: [ self-hosted, fastrpc-prd-u2404-x64-large-od-ephem ]
    strategy:
      fail-fast: false
      matrix:
        build_matrix: ${{ fromJson(inputs.build_matrix) }}
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          ref: ${{ github.ref }}
          fetch-depth: 0

      - name: Build fastrpc docker image
        uses: qualcomm/fastrpc/.github/actions/build_docker_image@development
        with:
          image: ${{ inputs.docker_image }}

      - name: Download URLs list
        uses: actions/download-artifact@v4
        with:
          name: presigned_urls_${{ matrix.build_matrix.deviceTree }}.json
          merge-multiple: true
          path: ${{ github.workspace }}

      - name: Clone lava job render scripts
        run: cd .. && git clone https://github.com/qualcomm-linux/job_render

      - name: Create fastrpc - lava job definition
        uses: qualcomm/fastrpc/.github/actions/lava_job_render@development
        id: create_job_definition
        with:
          docker_image: ${{ inputs.docker_image }}
        env:
          FIRMWARE: ${{ matrix.build_matrix.linuxFirmware }}
          DEVICE_TREE: ${{ matrix.build_matrix.deviceTree }}
          LAVA_DEVICE_NAME: ${{ matrix.build_matrix.lavaDeviceName }}

      - name: Submit lava job
        id: submit_job
        run: |
          cd ../job_render
          job_id=$(docker run -i --rm --workdir="$PWD" -v "$(dirname $PWD)":"$(dirname $PWD)" ${{ inputs.docker_image }} sh -c "lavacli identities add --token ${{ secrets.LAVA_OSS_TOKEN }} --uri https://lava-oss.qualcomm.com/RPC2 --username ${{ secrets.LAVA_OSS_USER }} production && lavacli -i production jobs submit ./renders/lava_job_definition.yaml")
          job_url="https://lava-oss.qualcomm.com/scheduler/job/$job_id"
          echo "job_id=$job_id" >> $GITHUB_OUTPUT
          echo "job_url=$job_url" >> $GITHUB_OUTPUT
          echo "Lava Job: $job_url"
          echo "JOB_ID=$job_id" >> $GITHUB_ENV

      - name: Check lava job results
        id: check_job
        run: |
          STATE=""
          while [ "$STATE" != "Finished" ]; do
            state=$(docker run -i --rm --workdir="$PWD" -v "$(dirname $PWD)":"$(dirname $PWD)" ${{ inputs.docker_image }} sh -c "lavacli identities add --token ${{ secrets.LAVA_OSS_TOKEN }} --uri https://lava-oss.qualcomm.com/RPC2 --username ${{ secrets.LAVA_OSS_USER }} production && lavacli -i production jobs show $JOB_ID" | grep state)
            STATE=$(echo "$state" | cut -d':' -f2 | sed 's/^ *//;s/ *$//')
            echo "Current status: $STATE"
            sleep 30
          done
          health=$(docker run -i --rm --workdir="$PWD" -v "$(dirname $PWD)":"$(dirname $PWD)" ${{ inputs.docker_image }} sh -c "lavacli identities add --token ${{ secrets.LAVA_OSS_TOKEN }} --uri https://lava-oss.qualcomm.com/RPC2 --username ${{ secrets.LAVA_OSS_USER }} production && lavacli -i production jobs show $JOB_ID" | grep Health)
          HEALTH=$(echo "$health" | cut -d':' -f2 | sed 's/^ *//;s/ *$//')
          if [[ "$HEALTH" == "Complete" ]]; then
            echo "Lava job passed."
            summary=":heavy_check_mark: Lava job passed."
            echo "summary=$summary" >> $GITHUB_OUTPUT
            exit 0
          else
            echo "Lava job failed."
            summary=":x: Lava job failed."
            echo "summary=$summary" >> $GITHUB_OUTPUT
            exit 1
          fi

      - name: Update summary
        if: success() || failure()
        shell: bash
        run: |
          if [ "${{ steps.create_job_definition.conclusion }}" == 'failure' ]; then
            status=":x: Test job failed"
          else
            status="${{ steps.check_job.outputs.summary }}"
            job_url="${{ steps.submit_job.outputs.job_url }}"
            job_id="${{ steps.submit_job.outputs.job_id }}"
          fi
          SUMMARY='
          <details><summary><i>'${status}'</i></summary>
          <br>
          JOB ID: <a href="${job_url}">'${job_id}'</a>
          </details>
          '
          echo -e "$SUMMARY" >> $GITHUB_STEP_SUMMARY