blob: 91e0d4c6fbf1c78417351933098b9aaa77ff4552 [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"
Eric Ball1aa07c02026-04-20 18:16:08 -070063 secrets:
64 GERRIT_SSH_PRIVKEY:
65 description: "SSH Key for the authorized user account"
66 required: true
Eric Ball8f404442026-01-05 21:31:56 -080067
68concurrency:
69 # yamllint disable-line rule:line-length
70 group: verify-unit-tests-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
71 cancel-in-progress: true
72
73jobs:
Eric Ballf7debd22026-04-16 10:28:25 -070074 prepare:
75 runs-on: ubuntu-latest
76 steps:
77 - name: Clear votes
78 # yamllint disable-line rule:line-length
Eric Ball1aa07c02026-04-20 18:16:08 -070079 uses: lfreleng-actions/gerrit-review-action@c4157b2200e1c2464a52f741c01ff85909c62811
Eric Ballf7debd22026-04-16 10:28:25 -070080 with:
81 host: ${{ vars.GERRIT_SERVER }}
82 username: ${{ vars.GERRIT_SSH_USER }}
83 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
84 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
85 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
86 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
87 vote-type: clear
Eric Ball01fcab42026-04-17 15:23:22 -070088 comment-only: false
Eric Ballf7debd22026-04-16 10:28:25 -070089 - name: Allow replication
90 run: sleep 10s
91
Eric Ball8f404442026-01-05 21:31:56 -080092 unit-tests:
Eric Ballf7debd22026-04-16 10:28:25 -070093 needs: prepare
Eric Ball8f404442026-01-05 21:31:56 -080094 runs-on: ubuntu-latest
95 strategy:
96 matrix:
97 target: ${{ fromJSON(inputs.UNIT_TEST_TARGETS) }}
98 steps:
99 - name: Gerrit Checkout
100 # yamllint disable-line rule:line-length
Eric Ball1aa07c02026-04-20 18:16:08 -0700101 uses: lfit/checkout-gerrit-change-action@fc57a3dd3318f31bd34d435d134e30443593eb80 # v1.0.1
Eric Ball8f404442026-01-05 21:31:56 -0800102 with:
103 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
104 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
105 gerrit-url: ${{ vars.GERRIT_URL }}
106 delay: "0s"
107 submodules: "true"
108 fetch-depth: 0
109 # yamllint disable-line rule:line-length
110 - name: Install python
111 uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
112 with:
113 python-version: "3.10"
114 - name: Install virtualenv
115 run: pip install virtualenv
116 - name: Install Go
117 uses: actions/setup-go@v5
118 with:
119 go-version-file: go.mod
Eric Ballf7debd22026-04-16 10:28:25 -0700120 - name: Check License Headers
121 uses: ./.github/actions/license-check-action
Eric Ball8f404442026-01-05 21:31:56 -0800122 - name: Run unit tests
123 env:
124 DEST_GOPATH: ${{ inputs.DEST_GOPATH }}
125 UNIT_TEST_TARGETS: ${{ matrix.target }}
126 GOPROXY: ${{ inputs.GOPROXY }}
127 TEST_PROJECT: ${{ github.repository }}
128 WORKSPACE: ${{ github.workspace }}
129 run: |
130 make SHELL="/bin/bash" ${{ matrix.target }}
Eric Ballf7debd22026-04-16 10:28:25 -0700131
Eric Ball01fcab42026-04-17 15:23:22 -0700132 vote:
133 if: ${{ always() }}
134 # yamllint enable rule:line-length
135 needs: [prepare, unit-tests]
136 runs-on: ubuntu-latest
137 steps:
138 - name: Get conclusion
139 # yamllint disable-line rule:line-length
140 uses: im-open/workflow-conclusion@e4f7c4980600fbe0818173e30931d3550801b992 # v2.2.3
141 - name: Set vote
142 # yamllint disable-line rule:line-length
Eric Ball1aa07c02026-04-20 18:16:08 -0700143 uses: lfreleng-actions/gerrit-review-action@c4157b2200e1c2464a52f741c01ff85909c62811
Eric Ball01fcab42026-04-17 15:23:22 -0700144 with:
145 host: ${{ vars.GERRIT_SERVER }}
146 username: ${{ vars.GERRIT_SSH_USER }}
147 key: ${{ secrets.GERRIT_SSH_PRIVKEY }}
148 known_hosts: ${{ vars.GERRIT_KNOWN_HOSTS }}
149 gerrit-change-number: ${{ inputs.GERRIT_CHANGE_NUMBER }}
150 gerrit-patchset-number: ${{ inputs.GERRIT_PATCHSET_NUMBER }}
151 vote-type: ${{ env.WORKFLOW_CONCLUSION }}
152 comment-only: false