blob: 26034c356d210d20913ef22424a4fff098c42b12 [file] [log] [blame]
Eric Ball8f404442026-01-05 21:31:56 -08001---
2# SPDX-License-Identifier: Apache-2.0
3# SPDX-FileCopyrightText: 2026 The Linux Foundation
4name: Gerrit Verify - Unit Tests
5
6# yamllint disable-line rule:truthy
7on:
Eric Balla4700f02026-04-20 17:34:07 -07008 workflow_call:
Eric Ball8f404442026-01-05 21:31:56 -08009 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
64concurrency:
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
69jobs:
Eric Ballf7debd22026-04-16 10:28:25 -070070 prepare:
71 runs-on: ubuntu-latest
72 steps:
73 - name: Clear votes
74 # yamllint disable-line rule:line-length
75 uses: lfreleng-actions/gerrit-review-action@537251ec667665b386f70b330b05446e3fc29087 # v0.9
76 with:
77 host: ${{ vars.GERRIT_SERVER }}
78 username: ${{ vars.GERRIT_SSH_USER }}
79 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
80 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
81 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
82 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
83 vote-type: clear
Eric Ball01fcab42026-04-17 15:23:22 -070084 comment-only: false
Eric Ballf7debd22026-04-16 10:28:25 -070085 - name: Allow replication
86 run: sleep 10s
87
Eric Ball8f404442026-01-05 21:31:56 -080088 unit-tests:
Eric Ballf7debd22026-04-16 10:28:25 -070089 needs: prepare
Eric Ball8f404442026-01-05 21:31:56 -080090 runs-on: ubuntu-latest
91 strategy:
92 matrix:
93 target: ${{ fromJSON(inputs.UNIT_TEST_TARGETS) }}
94 steps:
95 - name: Gerrit Checkout
96 # yamllint disable-line rule:line-length
97 uses: lfit/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
98 with:
99 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
100 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
101 gerrit-url: ${{ vars.GERRIT_URL }}
102 delay: "0s"
103 submodules: "true"
104 fetch-depth: 0
105 # yamllint disable-line rule:line-length
106 - name: Install python
107 uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
108 with:
109 python-version: "3.10"
110 - name: Install virtualenv
111 run: pip install virtualenv
112 - name: Install Go
113 uses: actions/setup-go@v5
114 with:
115 go-version-file: go.mod
Eric Ballf7debd22026-04-16 10:28:25 -0700116 - name: Check License Headers
117 uses: ./.github/actions/license-check-action
Eric Ball8f404442026-01-05 21:31:56 -0800118 - name: Run unit tests
119 env:
120 DEST_GOPATH: ${{ inputs.DEST_GOPATH }}
121 UNIT_TEST_TARGETS: ${{ matrix.target }}
122 GOPROXY: ${{ inputs.GOPROXY }}
123 TEST_PROJECT: ${{ github.repository }}
124 WORKSPACE: ${{ github.workspace }}
125 run: |
126 make SHELL="/bin/bash" ${{ matrix.target }}
Eric Ballf7debd22026-04-16 10:28:25 -0700127
Eric Ball01fcab42026-04-17 15:23:22 -0700128 vote:
129 if: ${{ always() }}
130 # yamllint enable rule:line-length
131 needs: [prepare, unit-tests]
132 runs-on: ubuntu-latest
133 steps:
134 - name: Get conclusion
135 # yamllint disable-line rule:line-length
136 uses: im-open/workflow-conclusion@e4f7c4980600fbe0818173e30931d3550801b992 # v2.2.3
137 - name: Set vote
138 # yamllint disable-line rule:line-length
139 uses: lfreleng-actions/gerrit-review-action@537251ec667665b386f70b330b05446e3fc29087 # v0.9
140 with:
141 host: ${{ vars.GERRIT_SERVER }}
142 username: ${{ vars.GERRIT_SSH_USER }}
143 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
144 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
145 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
146 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
147 vote-type: ${{ env.WORKFLOW_CONCLUSION }}
148 comment-only: false