From 1e6504e70818b3d440fff98fab4840962e78fd47 Mon Sep 17 00:00:00 2001 From: Konrad Breitsprecher Date: Wed, 2 Dec 2026 12:23:56 +0100 Subject: [PATCH] ci: only require the SPDX license identifier in the license check New files only need `SPDX-License-Identifier: MIT` (in the comment syntax of the file type); no SPDX-FileCopyrightText author list. Authorship is recorded by the git history. The license check now accepts files that licensecheck reports as UNKNOWN if they carry the identifier in their header. CONTRIBUTING.md documents the policy. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Konrad Breitsprecher --- CONTRIBUTING.md | 17 +++++++++++++++++ SilKit/ci/check_licenses.sh | 34 +++++++++++++++++++++++++++++++--- 2 files changed, 48 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8f923888d..6c066cf88 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -12,3 +12,20 @@ Until then, we would kindly ask you to not open pull requests. We will update this document when we are ready for your submissions. Thank you and stay tuned! + +## License Headers + +New source files only carry the SPDX license identifier as their first line, +using the comment syntax of the file type, for example: + +```cpp +// SPDX-License-Identifier: MIT +``` + +```cmake +# SPDX-License-Identifier: MIT +``` + +Do not add `SPDX-FileCopyrightText` lines or other author / copyright lists to new files. +The original author of a file and all later contributors are recorded in the git history. +The CI license check only requires the `SPDX-License-Identifier`. diff --git a/SilKit/ci/check_licenses.sh b/SilKit/ci/check_licenses.sh index cf20a4e78..a5b10e617 100644 --- a/SilKit/ci/check_licenses.sh +++ b/SilKit/ci/check_licenses.sh @@ -28,15 +28,43 @@ result="$(licensecheck --check='\.c.*$|\.h.*$|\.py|CMakeLists.txt|\.sh' \ numfiles=$(echo "$result" | wc -l) echo "Scanned $numfiles files" -violations=$(echo "$result" | grep "UNKNOWN") +# Policy: a file only needs an SPDX license identifier, e.g. +# // SPDX-License-Identifier: MIT +# No SPDX-FileCopyrightText (author/copyright list) is required; authorship is +# recorded by the git history. licensecheck reports files carrying only the +# identifier line as UNKNOWN, so accept those here. +has_spdx_identifier() +{ + head -n 30 "$1" | grep -q 'SPDX-License-Identifier: MIT' +} + +violations="" +unknown=$(echo "$result" | grep "UNKNOWN") +if [ -n "$unknown" ] ; then + tmp=$(mktemp) + printf "%s\n" "$unknown" > "$tmp" + while IFS= read -r line; + do + file="$(echo "$line" | cut -d ':' -f 1)" + if ! has_spdx_identifier "$file" ; then + violations="${violations}${line} +" + fi + done < "$tmp" + rm -f "$tmp" + violations=$(printf "%s" "$violations") +fi + if [ -n "$violations" ] ; then numviolations=$(echo "$violations" | wc -l) echo "FAILURE: Found $numviolations files without proper license info!" echo "$violations" mfiles="$(assemble_file_string "$violations")" reuseMessage=$(cat << EOM -You can add the correct SPDX header to these files by running: -reuse addheader --copyright="Vector Informatik GmbH" --license="MIT" -- $mfiles +Add the SPDX license identifier as the first line of each of these files, e.g.: +// SPDX-License-Identifier: MIT (C/C++) +# SPDX-License-Identifier: MIT (CMake, Python, shell) +Files: $mfiles EOM )