Skip to content

Commit 4429865

Browse files
committed
ci: Migrate build_check_new_file_license to GitHub Actions
Signed-off-by: Jorge Marques <[email protected]>
1 parent e3917f8 commit 4429865

File tree

4 files changed

+48
-56
lines changed

4 files changed

+48
-56
lines changed

.github/workflows/checks.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ jobs:
2727
source ci/build.sh
2828
apply_prerun
2929
30+
- name: License
31+
run: |
32+
source ci/build.sh
33+
check_license
34+
3035
- name: Check patch
3136
run: |
3237
source ci/build.sh

azure-pipelines.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,6 @@ pool:
2020
stages:
2121
- stage: Build
2222
jobs:
23-
- job: check_new_file_license
24-
condition: eq(variables['Build.Reason'], 'PullRequest')
25-
variables:
26-
BUILD_TYPE: check_new_file_license
27-
TARGET_BRANCH: $[ variables['System.PullRequest.TargetBranch'] ]
28-
steps:
29-
- checkout: self
30-
fetchDepth: 50
31-
clean: true
32-
- script: ./ci/travis/run-build.sh
33-
displayName: 'Check Is New ADI Driver & Dual Licensed'
34-
3523
- job: microblaze_build_test
3624
variables:
3725
BUILD_TYPE: microblaze

ci/build.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,49 @@ check_cppcheck () {
324324
return
325325
}
326326

327+
_bad_licence_error() {
328+
local license_error="
329+
File is being added to Analog Devices Linux tree.%0A
330+
Analog Devices code is being marked dual-licensed... Make sure this is really intended!%0A
331+
If not intended, change MODULE_LICENSE() or the SPDX-License-Identifier accordingly.%0A
332+
This is not as simple as one thinks and upstream might require a lawyer to sign the patches!"
333+
echo "::warning file=$1::check_license: $license_error" | tr -d '\t\n' ; echo
334+
}
335+
336+
check_license() {
337+
local fail=0
338+
339+
echo "check_file_license on range $base_sha..$head_sha"
340+
341+
local added_files=$(git diff --diff-filter=A --name-only "$base_sha..$head_sha")
342+
343+
# Get list of new files in the commit range
344+
for file in $added_files ; do
345+
if git diff $base_sha..$head_sha "$file" 2>/dev/null | grep "^+MODULE_LICENSE" | grep -q "Dual" ; then
346+
_bad_licence_error "$file"
347+
fail=1
348+
elif git diff $base_sha..$head_sha "$file" 2>/dev/null | grep "^+// SPDX-License-Identifier:" | grep -qi " OR " ; then
349+
# The below might catch bad licenses in header files and also helps to make sure dual licenses are
350+
# not in driver (e.g.: sometimes people have MODULE_LICENSE != SPDX-License-Identifier - which is also
351+
# wrong and maybe something to improve in this job).
352+
# For devicetree-related files, allow dual license if GPL-2.0 is one of them.
353+
if [[ "$file" == *.@(yaml|dts|dtsi|dtso) ]]; then
354+
if cat "$file" | grep "^// SPDX-License-Identifier:" | grep -q "GPL-2.0" ; then
355+
continue
356+
fi
357+
fi
358+
_bad_licence_error "$file"
359+
fail=1
360+
fi
361+
done
362+
363+
if [[ "$fail" == "1" ]]; then
364+
set_step_fail "check_file_license"
365+
fi
366+
367+
return
368+
}
369+
327370
compile_devicetree() {
328371
local tmp_log_file=/dev/shm/$run_id.ci_compile_devicetree.log
329372
local err=0

ci/travis/run-build.sh

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -153,50 +153,6 @@ get_ref_branch() {
153153
fi
154154
}
155155

156-
bad_licence_error() {
157-
__echo_red "File '$1' is being added to Analog Devices Linux tree."
158-
__echo_red "Analog Devices code is being marked dual-licensed... Make sure this is really intended!"
159-
__echo_red "If not intended, change MODULE_LICENSE() or the SPDX-License-Identifier accordingly."
160-
__echo_red "This is not as simple as one thinks and upstream might require a lawyer to sign the patches!"
161-
}
162-
163-
build_check_new_file_license() {
164-
local ret
165-
166-
local ref_branch="$(get_ref_branch)"
167-
168-
if [ -z "$ref_branch" ] ; then
169-
__echo_red "Could not get a base_ref for checkpatch"
170-
exit 1
171-
fi
172-
173-
__update_git_ref "${ref_branch}" "${ref_branch}"
174-
175-
COMMIT_RANGE="${ref_branch}.."
176-
177-
__echo_green "Running check_new_adi_file_license for commit range '$COMMIT_RANGE'"
178-
179-
ret=0
180-
# Get list of new files in the commit range
181-
for file in $(git diff --name-status "$COMMIT_RANGE" | grep ^A | cut -d$'\t' -f2) ; do
182-
if git diff "$COMMIT_RANGE" "$file" | grep "+MODULE_LICENSE" | grep -q "Dual" ; then
183-
bad_licence_error "$file"
184-
ret=1
185-
elif git diff "$COMMIT_RANGE" "$file" | grep "SPDX-License-Identifier:" | grep -qi " OR " ; then
186-
# The below might catch bad licenses in header files and also helps to make sure dual licenses are
187-
# not in driver (eg: sometimes people have MODULE_LICENSE != SPDX-License-Identifier - which is also
188-
# wrong and maybe someting to improve in this job)
189-
if echo "$file" | grep -q ".yaml$"; then
190-
continue
191-
fi
192-
bad_licence_error "$file"
193-
ret=1
194-
fi
195-
done
196-
197-
return $ret
198-
}
199-
200156
__setup_dummy_git_account() {
201157
[ "${LOCAL_BUILD}" == "y" ] && return 0
202158
# setup an email account so that we can cherry-pick stuff

0 commit comments

Comments
 (0)