blob: 98f126406b836d7855514c2882e5ca927124fb84 [file] [log] [blame]
Eric Ball236f1272026-01-05 21:55:25 -08001---
2# SPDX-License-Identifier: Apache-2.0
3# SPDX-FileCopyrightText: 2026 The Linux Foundation
4name: Gerrit Verify - License Check
5
6# yamllint disable-line rule:truthy
7on:
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
48concurrency:
49 # yamllint disable-line rule:line-length
50 group: verify-license-check-${{ github.workflow }}-${{ github.event.inputs.GERRIT_CHANGE_ID || github.run_id }}
51 cancel-in-progress: true
52
53jobs:
54 maven-verify:
55 runs-on: ubuntu-latest
56 steps:
57 # yamllint disable-line rule:line-length
58 - uses: lfreleng-actions/checkout-gerrit-change-action@54d751e8bd167bc91f7d665dabe33fae87aaaa63 # v0.9
59 with:
60 gerrit-refspec: ${{ inputs.GERRIT_REFSPEC }}
61 gerrit-project: ${{ inputs.GERRIT_PROJECT }}
62 gerrit-url: ${{ vars.GERRIT_URL }}
63 delay: "0s"
64 - name: Run licensecheck.sh
65 shell: bash
66 run: |
67 set +e -u -o pipefail
68 fail_licensecheck=0
69
70 while IFS= read -r -d '' f
71 do
72 grep -q "Copyright\|Apache License" "${f}"
73 rc=$?
74 if [[ $rc != 0 ]]; then
75 echo "ERROR: $f does not contain License Header"
76 fail_licensecheck=1
77 fi
78 done < <(find . -name ".git" -prune -o -type f \
79 -name "*.*" \
80 ! -name "*.PNG" \
81 ! -name "*.asc" \
82 ! -name "*.bat" \
83 ! -name "*.bin" \
84 ! -name "*.cert" \
85 ! -name "*.cfg" \
86 ! -name "*.cnf" \
87 ! -name "*.conf" \
88 ! -name "*.cql" \
89 ! -name "*.crt" \
90 ! -name "*.csar" \
91 ! -name "*.csr" \
92 ! -name "*.csv" \
93 ! -name "*.ctmpl" \
94 ! -name "*.curl" \
95 ! -name "*.db" \
96 ! -name "*.der" \
97 ! -name "*.desc" \
98 ! -name "*.diff" \
99 ! -name "*.dnsmasq" \
100 ! -name "*.do" \
101 ! -name "*.docx" \
102 ! -name "*.eot" \
103 ! -name "*.gif" \
104 ! -name "*.gpg" \
105 ! -name "*.graffle" \
106 ! -name "*.ico" \
107 ! -name "*.iml" \
108 ! -name "*.in" \
109 ! -name "*.inc" \
110 ! -name "*.install" \
111 ! -name "*.j2" \
112 ! -name "*.jar" \
113 ! -name "*.jks" \
114 ! -name "*.jpg" \
115 ! -name "*.json" \
116 ! -name "*.jsonld" \
117 ! -name "*.JSON" \
118 ! -name "*.key" \
119 ! -name "*.list" \
120 ! -name "*.local" \
121 ! -path "*.lock" \
122 ! -name "*.log" \
123 ! -name "*.mak" \
124 ! -name "*.md" \
125 ! -name "*.MF" \
126 ! -name "*.mk" \
127 ! -name "*.oar" \
128 ! -name "*.p12" \
129 ! -name "*.patch" \
130 ! -name "*.pb.go" \
131 ! -name "*.pb.gw.go" \
132 ! -name "*.pdf" \
133 ! -name "*.pcap" \
134 ! -name "*.pem" \
135 ! -name "*.png" \
136 ! -name "*.properties" \
137 ! -name "*.proto" \
138 ! -name "*.protoset" \
139 ! -name "*.pyc" \
140 ! -name "*.repo" \
141 ! -name "*.robot" \
142 ! -name "*.rst" \
143 ! -name "*.rules" \
144 ! -name "*.service" \
145 ! -name "*.svg" \
146 ! -name "*.swp" \
147 ! -name "*.tar" \
148 ! -name "*.tar.gz" \
149 ! -name "*.toml" \
150 ! -name "*.ttf" \
151 ! -name "*.txt" \
152 ! -name "*.woff" \
153 ! -name "*.xproto" \
154 ! -name "*.xtarget" \
155 ! -name "*ignore" \
156 ! -name "*rc" \
157 ! -name "*_pb2.py" \
158 ! -name "*_pb2_grpc.py" \
159 ! -name "Dockerfile" \
160 ! -name "Dockerfile.*" \
161 ! -name "go.mod" \
162 ! -name "go.sum" \
163 ! -name "Makefile" \
164 ! -name "Makefile.*" \
165 ! -name "README" \
166 ! -path "*/vendor/*" \
167 ! -path "*conf*" \
168 ! -path "*git*" \
169 ! -path "*swagger*" \
170 ! -path "*.drawio" \
171 ! -name "*.pb.h" \
172 ! -name "*.pb.cc" \
173 ! -name "*/docs/*" \
174 -print0 )
175
176 exit ${fail_licensecheck}