| Eric Ball | 8f40444 | 2026-01-05 21:31:56 -0800 | [diff] [blame^] | 1 | --- |
| 2 | # SPDX-License-Identifier: Apache-2.0 |
| 3 | # SPDX-FileCopyrightText: 2026 The Linux Foundation |
| 4 | name: Gerrit Verify - Unit Tests |
| 5 | |
| 6 | # yamllint disable-line rule:truthy |
| 7 | on: |
| 8 | workflow_dispatch: |
| 9 | inputs: |
| 10 | # Gerrit-to-Github defaults |
| 11 | GERRIT_BRANCH: |
| 12 | description: "Branch that change is against" |
| 13 | required: true |
| 14 | type: string |
| 15 | GERRIT_CHANGE_ID: |
| 16 | description: "The ID for the change" |
| 17 | required: true |
| 18 | type: string |
| 19 | GERRIT_CHANGE_NUMBER: |
| 20 | description: "The Gerrit number" |
| 21 | required: true |
| 22 | type: string |
| 23 | GERRIT_CHANGE_URL: |
| 24 | description: "URL to the change" |
| 25 | required: true |
| 26 | type: string |
| 27 | GERRIT_EVENT_TYPE: |
| 28 | description: "Type of Gerrit event" |
| 29 | required: true |
| 30 | type: string |
| 31 | GERRIT_PATCHSET_NUMBER: |
| 32 | description: "The patch number for the change" |
| 33 | required: true |
| 34 | type: string |
| 35 | GERRIT_PATCHSET_REVISION: |
| 36 | description: "The revision sha" |
| 37 | required: true |
| 38 | type: string |
| 39 | GERRIT_PROJECT: |
| 40 | description: "Project in Gerrit" |
| 41 | required: true |
| 42 | type: string |
| 43 | GERRIT_REFSPEC: |
| 44 | description: "Gerrit refspec of change" |
| 45 | required: true |
| 46 | type: string |
| 47 | # Workflow-specific inputs |
| 48 | UNIT_TEST_TARGETS: |
| 49 | description: "List of targets in json-formatted string" |
| 50 | required: false |
| 51 | type: string |
| 52 | default: '["lint", "sca", "test"]' |
| 53 | DEST_GOPATH: |
| 54 | description: "Specifies part of the GOPATH. Usually set to Github org." |
| 55 | required: false |
| 56 | type: string |
| 57 | default: "github.com/opencord" |
| 58 | GOPROXY: |
| 59 | description: "Url for Go proxy" |
| 60 | required: false |
| 61 | type: string |
| 62 | default: "https://proxy.golang.org" |
| 63 | |
| 64 | concurrency: |
| 65 | # yamllint disable-line rule:line-length |
| 66 | group: verify-unit-tests-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }} |
| 67 | cancel-in-progress: true |
| 68 | |
| 69 | jobs: |
| 70 | unit-tests: |
| 71 | runs-on: ubuntu-latest |
| 72 | strategy: |
| 73 | matrix: |
| 74 | target: ${{ fromJSON(inputs.UNIT_TEST_TARGETS) }} |
| 75 | steps: |
| 76 | - name: Gerrit Checkout |
| 77 | # yamllint disable-line rule:line-length |
| 78 | uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9 |
| 79 | with: |
| 80 | gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }} |
| 81 | gerrit-project: ${{ inputs.GERRIT_PROJECT }} |
| 82 | gerrit-url: ${{ vars.GERRIT_URL }} |
| 83 | delay: "0s" |
| 84 | submodules: "true" |
| 85 | fetch-depth: 0 |
| 86 | # yamllint disable-line rule:line-length |
| 87 | - name: Install python |
| 88 | uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 |
| 89 | with: |
| 90 | python-version: "3.10" |
| 91 | - name: Install virtualenv |
| 92 | run: pip install virtualenv |
| 93 | - name: Install Go |
| 94 | uses: actions/setup-go@v5 |
| 95 | with: |
| 96 | go-version-file: go.mod |
| 97 | - name: Run unit tests |
| 98 | env: |
| 99 | DEST_GOPATH: ${{ inputs.DEST_GOPATH }} |
| 100 | UNIT_TEST_TARGETS: ${{ matrix.target }} |
| 101 | GOPROXY: ${{ inputs.GOPROXY }} |
| 102 | TEST_PROJECT: ${{ github.repository }} |
| 103 | WORKSPACE: ${{ github.workspace }} |
| 104 | run: | |
| 105 | make SHELL="/bin/bash" ${{ matrix.target }} |