-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add CI workflow to check the license file #10
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
Merged
MatteoPologruto
merged 2 commits into
arduino:master
from
MatteoPologruto:add-check-license
Mar 28, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md | ||
name: Check License | ||
|
||
env: | ||
EXPECTED_LICENSE_FILENAME: LICENSE.txt | ||
# SPDX identifier: https://spdx.org/licenses/ | ||
EXPECTED_LICENSE_TYPE: BSD-3-Clause | ||
|
||
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows | ||
on: | ||
create: | ||
push: | ||
paths: | ||
- ".github/workflows/check-license.ya?ml" | ||
# See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file | ||
- "[cC][oO][pP][yY][iI][nN][gG]*" | ||
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*" | ||
- "[lL][iI][cC][eE][nN][cCsS][eE]*" | ||
- "[oO][fF][lL]*" | ||
- "[pP][aA][tT][eE][nN][tT][sS]*" | ||
pull_request: | ||
paths: | ||
- ".github/workflows/check-license.ya?ml" | ||
- "[cC][oO][pP][yY][iI][nN][gG]*" | ||
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*" | ||
- "[lL][iI][cC][eE][nN][cCsS][eE]*" | ||
- "[oO][fF][lL]*" | ||
- "[pP][aA][tT][eE][nN][tT][sS]*" | ||
schedule: | ||
# Run periodically to catch breakage caused by external changes. | ||
- cron: "0 6 * * WED" | ||
workflow_dispatch: | ||
repository_dispatch: | ||
|
||
jobs: | ||
run-determination: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
result: ${{ steps.determination.outputs.result }} | ||
steps: | ||
- name: Determine if the rest of the workflow should run | ||
id: determination | ||
run: | | ||
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" | ||
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. | ||
if [[ | ||
"${{ github.event_name }}" != "create" || | ||
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX | ||
]]; then | ||
# Run the other jobs. | ||
RESULT="true" | ||
else | ||
# There is no need to run the other jobs. | ||
RESULT="false" | ||
fi | ||
|
||
echo "result=$RESULT" >> $GITHUB_OUTPUT | ||
|
||
check-license: | ||
needs: run-determination | ||
if: needs.run-determination.outputs.result == 'true' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: ruby # Install latest version | ||
|
||
- name: Install licensee | ||
run: gem install licensee | ||
|
||
- name: Check license file | ||
run: | | ||
EXIT_STATUS=0 | ||
# See: https://github.com/licensee/licensee | ||
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)" | ||
|
||
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')" | ||
echo "Detected license file: $DETECTED_LICENSE_FILE" | ||
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then | ||
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME" | ||
EXIT_STATUS=1 | ||
fi | ||
|
||
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')" | ||
echo "Detected license type: $DETECTED_LICENSE_TYPE" | ||
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then | ||
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\"" | ||
EXIT_STATUS=1 | ||
fi | ||
|
||
exit $EXIT_STATUS |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1 @@ | ||
/* | ||
* This file is part of go-win32-utils. | ||
* | ||
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/) | ||
* | ||
* go-win32-utils is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation; either version 2 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* As a special exception, you may use this file as part of a free software | ||
* library without restriction. Specifically, if other files instantiate | ||
* templates or use macros or inline functions from this file, or you compile | ||
* this file and link it with other files to produce an executable, this | ||
* file does not by itself cause the resulting executable to be covered by | ||
* the GNU General Public License. This exception does not however | ||
* invalidate any other reasons why the executable file might be covered by | ||
* the GNU General Public License. | ||
*/ | ||
|
||
// Package win32 is a collection of useful bindings to Win32 API that are not available in the standard | ||
// golang windows/syscall package. | ||
Comment on lines
-30
to
-31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the package description, it should not be removed. |
||
package win32 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change removes the license header from the files.
I think that there must be a license header like: