Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GH Action to check SPDX license headers in new files. #4166

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

OhmSpectator
Copy link
Member

  • Created a workflow to automatically check for SPDX license headers in new files when a PR is opened or changes are pushed to master or version-stable branches.
  • Added tools/spdx-check.sh script that scans new files with specific extensions and certain filenames for the SPDX-License-Identifier header.
  • The script excludes files in vendor/ directories from the check.
  • The workflow will fail if any of the new files are missing the required SPDX license header.

@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch 2 times, most recently from c638549 to b46fa32 Compare August 26, 2024 23:50
@OhmSpectator OhmSpectator changed the title github: Add GH Action to check SPDX license headers in new files. [WIP] Add GH Action to check SPDX license headers in new files. Aug 26, 2024
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch 2 times, most recently from 0f7974e to 7defec1 Compare August 26, 2024 23:55
@OhmSpectator OhmSpectator changed the title [WIP] Add GH Action to check SPDX license headers in new files. Add GH Action to check SPDX license headers in new files. Aug 26, 2024
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from 7defec1 to a283af4 Compare August 27, 2024 00:00
@OhmSpectator OhmSpectator self-assigned this Aug 27, 2024
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from a283af4 to 3467ec6 Compare August 27, 2024 00:03
@OhmSpectator OhmSpectator marked this pull request as ready for review August 27, 2024 00:05
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from 3467ec6 to 4e1c7e9 Compare August 27, 2024 00:18
# SPDX-License-Identifier: Apache-2.0

# List of files to check, excluding vendor directories
files=$(git diff --name-only --diff-filter=A origin/master..HEAD | grep -v "vendor/")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if origin/master..HEAD is going to work for backports (once this script becomes part of some LTS branch).
Maybe we could pass ${{ github.event.pull_request.base.ref }} as an input argument to this script (or github.base_ref, I don't know which one is the correct in this case).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, good suggestion! I'll change to base.ref

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like he fixed version works

@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from 4e1c7e9 to 2035698 Compare August 27, 2024 09:07
@OhmSpectator OhmSpectator marked this pull request as draft August 27, 2024 09:08
@OhmSpectator OhmSpectator marked this pull request as ready for review August 27, 2024 09:09
tools/spdx-check.sh Outdated Show resolved Hide resolved
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from 2035698 to c9614d8 Compare August 27, 2024 18:21
@OhmSpectator OhmSpectator requested a review from rene August 28, 2024 20:28
@OhmSpectator
Copy link
Member Author

I want to add .proto files to the list...

@OhmSpectator OhmSpectator marked this pull request as draft August 28, 2024 21:42
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from c9614d8 to 508937e Compare August 28, 2024 23:23
@OhmSpectator OhmSpectator marked this pull request as ready for review August 28, 2024 23:23
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch 2 times, most recently from 5a231a6 to 9d78904 Compare August 28, 2024 23:27
@OhmSpectator
Copy link
Member Author

@rene, could you recheck please?

Created a workflow to automatically check for SPDX license headers in
new files when a PR is opened or changes are pushed to `master` or
version-stable branches.

Added `tools/spdx-check.sh` script that scans new files with specific
extensions and certain filenames for the `SPDX-License-Identifier`
header.

The script excludes files in `vendor/` directories from the check.

The workflow will fail if any of the new files are missing the required
SPDX license header.

Signed-off-by: Nikolay Martyanov <nikolay@zededa.com>
@OhmSpectator OhmSpectator force-pushed the feature/add-spdx-check branch from 9d78904 to e68eca1 Compare August 29, 2024 11:26
@OhmSpectator OhmSpectator enabled auto-merge (rebase) August 29, 2024 12:17
Copy link
Contributor

@rene rene left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@OhmSpectator for now it's ok, we do care about Apache 2.0, but please, consider add Apache 2.0 compatible licenses in the future....

@OhmSpectator OhmSpectator merged commit 50576f5 into lf-edge:master Aug 30, 2024
21 checks passed
@OhmSpectator
Copy link
Member Author

@OhmSpectator for now it's ok, we do care about Apache 2.0, but please, consider add Apache 2.0 compatible licenses in the future....

@rene, do you find this list fine for it?

MIT License: MIT
BSD 2-Clause License: BSD-2-Clause
BSD 3-Clause License: BSD-3-Clause
ISC License: ISC
Python Software Foundation License (PSFL): Python-2.0
PostgreSQL License: PostgreSQL
Zlib License: Zlib
Boost Software License: BSL-1.0
Creative Commons Zero (CC0): CC0-1.0
WTFPL: WTFPL Very important one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants