From 8b6917f8c6433794f9d8d4349ff2da797631f4fc Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Mon, 12 Feb 2024 10:08:46 +0100 Subject: [PATCH] ci: Add license pre-commit check --- .pre-commit-config.yaml | 6 ++++++ check_copyright_config.yaml | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 check_copyright_config.yaml diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0ac75174..6b6edfd1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,6 +11,12 @@ repos: - id: codespell args: [-w, "--ignore-words=codespell-ignore-list"] +- repo: https://github.com/espressif/check-copyright/ + rev: v1.0.3 + hooks: + - id: check-copyright + args: ['-r', '--config', 'check_copyright_config.yaml'] + - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.3.0 hooks: diff --git a/check_copyright_config.yaml b/check_copyright_config.yaml new file mode 100644 index 00000000..e3829f27 --- /dev/null +++ b/check_copyright_config.yaml @@ -0,0 +1,43 @@ +DEFAULT: + perform_check: yes # should the check be performed? + # Sections setting this to 'no' don't need to include any other options as they are ignored + # When a file is using a section with the option set to 'no', no checks are performed. + + # what licenses (or license expressions) are allowed for files in this section + # when setting this option in a section, you need to list all the allowed licenses + allowed_licenses: + - Apache-2.0 + license_for_new_files: Apache-2.0 # license to be used when inserting a new copyright notice + new_notice_c: | # notice for new C, CPP, H, HPP and LD files + /* + * SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: {license} + */ + new_notice_python: | # notice for new python files + # SPDX-FileCopyrightText: {years} Espressif Systems (Shanghai) CO LTD + # SPDX-License-Identifier: {license} + + # comment lines matching: + # SPDX-FileCopyrightText: year[-year] Espressif Systems + # or + # SPDX-FileContributor: year[-year] Espressif Systems + # are replaced with this template prefixed with the correct comment notation (# or // or *) and SPDX- notation + espressif_copyright: '{years} Espressif Systems (Shanghai) CO LTD' + +# You can create your own rules for files or group of files +libuvc: + include: + - 'host/class/uvc/usb_host_uvc/**' + allowed_licenses: + - Apache-2.0 + - LGPL-2.1-or-later + license_for_new_files: Apache-2.0 + +tinyusb: + include: + - ' device/esp_tinyusb/**' + allowed_licenses: + - Apache-2.0 + - MIT + license_for_new_files: Apache-2.0