[libcamera-ci,4/4] Add lint job to check licenses
diff mbox series

Message ID 20260405192211.1210985-5-laurent.pinchart@ideasonboard.com
State New
Headers show
Series
  • Catch missing license information in CI
Related show

Commit Message

Laurent Pinchart April 5, 2026, 7:22 p.m. UTC
libcamera uses REUSE to hhelp with license compliance. Every file in the
source tree is required to have an SPDX license identifier, directly
within the file or through REUSE.toml. Add a lint job that verifies this
using the reuse lint tool.

We need to add SPDX license identifiers to the meson native files as
they are being copied to the source tree and the reuse tool doesn't have
an option to specify files to ignore. For the same reason, remove the
.work/ci-config/ directory after setting up the build environment.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 .gitlab-ci/lint-reuse.sh          | 26 ++++++++++++++++++++++++++
 .gitlab-ci/meson/libc++.native    |  2 ++
 .gitlab-ci/meson/libstdc++.native |  2 ++
 .gitlab-ci/setup-container.sh     |  2 +-
 gitlab-ci.yml                     | 15 ++++++++++++++-
 5 files changed, 45 insertions(+), 2 deletions(-)
 create mode 100755 .gitlab-ci/lint-reuse.sh

Patch
diff mbox series

diff --git a/.gitlab-ci/lint-reuse.sh b/.gitlab-ci/lint-reuse.sh
new file mode 100755
index 000000000000..2439d47d2c78
--- /dev/null
+++ b/.gitlab-ci/lint-reuse.sh
@@ -0,0 +1,26 @@ 
+#!/bin/bash
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: © 2026 Laurent Pinchart <laurent.pinchart@ideasonboard.com>
+#
+# Verify that every file contains a valid license
+
+set -e
+
+source "$(dirname "$0")/lib.sh"
+
+libcamera_reuse() {
+	echo "Running reuse for $CI_COMMIT_REF_NAME ($CI_COMMIT_SHA)"
+
+        local files=$(reuse lint -j | jq -r '.non_compliant.missing_licensing_info[]')
+
+        if [ -n "$files" ] ; then
+                echo "The following files are missing license information:"
+                echo "$files"
+                exit 1
+        fi
+
+        echo "All files contain license information"
+}
+
+run libcamera_reuse
diff --git a/.gitlab-ci/meson/libc++.native b/.gitlab-ci/meson/libc++.native
index 9c99d5a7f8b2..c850a20b6903 100644
--- a/.gitlab-ci/meson/libc++.native
+++ b/.gitlab-ci/meson/libc++.native
@@ -1,3 +1,5 @@ 
+# SPDX-License-Identifier: CC0-1.0
+
 [built-in options]
 cpp_args = ['-stdlib=libc++']
 cpp_link_args = ['-stdlib=libc++']
diff --git a/.gitlab-ci/meson/libstdc++.native b/.gitlab-ci/meson/libstdc++.native
index 3116043fc116..e7b596e76089 100644
--- a/.gitlab-ci/meson/libstdc++.native
+++ b/.gitlab-ci/meson/libstdc++.native
@@ -1,3 +1,5 @@ 
+# SPDX-License-Identifier: CC0-1.0
+
 [built-in options]
 cpp_args = ['-stdlib=libstdc++']
 cpp_link_args = ['-stdlib=libstdc++']
diff --git a/.gitlab-ci/setup-container.sh b/.gitlab-ci/setup-container.sh
index 103cc61169c3..64cb7f2b9abe 100755
--- a/.gitlab-ci/setup-container.sh
+++ b/.gitlab-ci/setup-container.sh
@@ -133,7 +133,7 @@  case $FDO_DISTRIBUTION_VERSION in
 		texlive-latex-extra
 	)
 	# Tools requires by the lint jobs.
-	PKGS_LIBCAMERA_RUNTIME+=( clang-format python3-autopep8 shellcheck )
+	PKGS_LIBCAMERA_RUNTIME+=( clang-format jq python3-autopep8 reuse shellcheck )
 	# libclang-rt-dev for the clang ASan runtime.
 	PKGS_LIBCAMERA_RUNTIME_MULTIARCH+=( libclang-rt-19-dev )
 	# For the Android camera HAL and the virtual pipeline handler.
diff --git a/gitlab-ci.yml b/gitlab-ci.yml
index 6679cf853c7a..96dc7600c9b1 100644
--- a/gitlab-ci.yml
+++ b/gitlab-ci.yml
@@ -74,7 +74,7 @@  include:
 .libcamera-ci.debian:13:
   variables:
     FDO_DISTRIBUTION_VERSION: 'trixie'
-    FDO_DISTRIBUTION_TAG: '2026-04-05.0'
+    FDO_DISTRIBUTION_TAG: '2026-04-05.1'
 
 .container-debian:
   extends:
@@ -122,6 +122,7 @@  container-debian:13:
     - LIBCAMERA_CI_URL="${CI_SERVER_URL}/${CI_CONFIG_PATH/*@/}"
     - git clone --depth 1 --single-branch $LIBCAMERA_CI_URL .work/ci-config
     - mv .work/ci-config/.gitlab-ci/ $CI_PROJECT_DIR
+    - rm -rf .work/ci-config/
 
 #
 # Build libcamera with a different compilers, using stock Debian images to
@@ -305,6 +306,18 @@  build-package:debug:
 # Lint stage - Run checkstyle.py and check merge suitability
 # ------------------------------------------------------------------------------
 
+license:
+  extends:
+    - .fdo.distribution-image@debian
+    - .libcamera-ci.debian:13
+    - .libcamera-ci.scripts
+  stage: lint
+  needs:
+    - job: container-debian:13
+      artifacts: false
+  script:
+    - $CI_PROJECT_DIR/.gitlab-ci/lint-reuse.sh
+
 lint:
   extends:
     - .fdo.distribution-image@debian