Skip to content

Commit d83c157

Browse files
Merge pull request #10 from MatteoPologruto/add-check-license
Add CI workflow to check the license file
2 parents 477982a + 8fb7c81 commit d83c157

File tree

9 files changed

+121
-915
lines changed

9 files changed

+121
-915
lines changed

.github/workflows/check-license.yml

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-license.md
2+
name: Check License
3+
4+
env:
5+
EXPECTED_LICENSE_FILENAME: LICENSE.txt
6+
# SPDX identifier: https://spdx.org/licenses/
7+
EXPECTED_LICENSE_TYPE: BSD-3-Clause
8+
9+
# See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
10+
on:
11+
create:
12+
push:
13+
paths:
14+
- ".github/workflows/check-license.ya?ml"
15+
# See: https://github.com/licensee/licensee/blob/master/docs/what-we-look-at.md#detecting-the-license-file
16+
- "[cC][oO][pP][yY][iI][nN][gG]*"
17+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
18+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
19+
- "[oO][fF][lL]*"
20+
- "[pP][aA][tT][eE][nN][tT][sS]*"
21+
pull_request:
22+
paths:
23+
- ".github/workflows/check-license.ya?ml"
24+
- "[cC][oO][pP][yY][iI][nN][gG]*"
25+
- "[cC][oO][pP][yY][rR][iI][gG][hH][tH]*"
26+
- "[lL][iI][cC][eE][nN][cCsS][eE]*"
27+
- "[oO][fF][lL]*"
28+
- "[pP][aA][tT][eE][nN][tT][sS]*"
29+
schedule:
30+
# Run periodically to catch breakage caused by external changes.
31+
- cron: "0 6 * * WED"
32+
workflow_dispatch:
33+
repository_dispatch:
34+
35+
jobs:
36+
run-determination:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
result: ${{ steps.determination.outputs.result }}
40+
steps:
41+
- name: Determine if the rest of the workflow should run
42+
id: determination
43+
run: |
44+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
45+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
46+
if [[
47+
"${{ github.event_name }}" != "create" ||
48+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
49+
]]; then
50+
# Run the other jobs.
51+
RESULT="true"
52+
else
53+
# There is no need to run the other jobs.
54+
RESULT="false"
55+
fi
56+
57+
echo "result=$RESULT" >> $GITHUB_OUTPUT
58+
59+
check-license:
60+
needs: run-determination
61+
if: needs.run-determination.outputs.result == 'true'
62+
runs-on: ubuntu-latest
63+
64+
steps:
65+
- name: Checkout repository
66+
uses: actions/checkout@v3
67+
68+
- name: Install Ruby
69+
uses: ruby/setup-ruby@v1
70+
with:
71+
ruby-version: ruby # Install latest version
72+
73+
- name: Install licensee
74+
run: gem install licensee
75+
76+
- name: Check license file
77+
run: |
78+
EXIT_STATUS=0
79+
# See: https://github.com/licensee/licensee
80+
LICENSEE_OUTPUT="$(licensee detect --json --confidence=100)"
81+
82+
DETECTED_LICENSE_FILE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].filename | tr --delete '\r')"
83+
echo "Detected license file: $DETECTED_LICENSE_FILE"
84+
if [ "$DETECTED_LICENSE_FILE" != "\"${EXPECTED_LICENSE_FILENAME}\"" ]; then
85+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license file $DETECTED_LICENSE_FILE doesn't match expected: $EXPECTED_LICENSE_FILENAME"
86+
EXIT_STATUS=1
87+
fi
88+
89+
DETECTED_LICENSE_TYPE="$(echo "$LICENSEE_OUTPUT" | jq .matched_files[0].matched_license | tr --delete '\r')"
90+
echo "Detected license type: $DETECTED_LICENSE_TYPE"
91+
if [ "$DETECTED_LICENSE_TYPE" != "\"${EXPECTED_LICENSE_TYPE}\"" ]; then
92+
echo "::error file=${DETECTED_LICENSE_FILE}::detected license type $DETECTED_LICENSE_TYPE doesn't match expected \"${EXPECTED_LICENSE_TYPE}\""
93+
EXIT_STATUS=1
94+
fi
95+
96+
exit $EXIT_STATUS

LICENSE.txt

+24-739
Large diffs are not rendered by default.

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
[![Test Go status](https://github.com/arduino/go-win32-utils/actions/workflows/test-go-task.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/test-go-task.yml)
66
[![Codecov](https://codecov.io/gh/arduino/go-win32-utils/branch/main/graph/badge.svg)](https://codecov.io/gh/arduino/go-win32-utils)
77
[![Check Go status](https://github.com/arduino/go-win32-utils/actions/workflows/check-go-task.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/check-go-task.yml)
8+
[![Check License status](https://github.com/arduino/go-win32-utils/actions/workflows/check-license.yml/badge.svg)](https://github.com/arduino/go-win32-utils/actions/workflows/check-license.yml)
89

910
This library contains some useful calls to win32 API that are not available on the standard golang library.
1011

devicenotification/devicenotification.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
/*
2-
* This file is part of go-win32-utils.
3-
*
4-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
5-
*
6-
* go-win32-utils is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*
20-
* As a special exception, you may use this file as part of a free software
21-
* library without restriction. Specifically, if other files instantiate
22-
* templates or use macros or inline functions from this file, or you compile
23-
* this file and link it with other files to produce an executable, this
24-
* file does not by itself cause the resulting executable to be covered by
25-
* the GNU General Public License. This exception does not however
26-
* invalidate any other reasons why the executable file might be covered by
27-
* the GNU General Public License.
28-
*/
29-
301
package devicenotification
312

323
import (

doc.go

-31
Original file line numberDiff line numberDiff line change
@@ -1,32 +1 @@
1-
/*
2-
* This file is part of go-win32-utils.
3-
*
4-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
5-
*
6-
* go-win32-utils is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*
20-
* As a special exception, you may use this file as part of a free software
21-
* library without restriction. Specifically, if other files instantiate
22-
* templates or use macros or inline functions from this file, or you compile
23-
* this file and link it with other files to produce an executable, this
24-
* file does not by itself cause the resulting executable to be covered by
25-
* the GNU General Public License. This exception does not however
26-
* invalidate any other reasons why the executable file might be covered by
27-
* the GNU General Public License.
28-
*/
29-
30-
// Package win32 is a collection of useful bindings to Win32 API that are not available in the standard
31-
// golang windows/syscall package.
321
package win32

examples_test.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
/*
2-
* This file is part of go-win32-utils.
3-
*
4-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
5-
*
6-
* go-win32-utils is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*
20-
* As a special exception, you may use this file as part of a free software
21-
* library without restriction. Specifically, if other files instantiate
22-
* templates or use macros or inline functions from this file, or you compile
23-
* this file and link it with other files to produce an executable, this
24-
* file does not by itself cause the resulting executable to be covered by
25-
* the GNU General Public License. This exception does not however
26-
* invalidate any other reasons why the executable file might be covered by
27-
* the GNU General Public License.
28-
*/
29-
301
package win32_test
312

323
import (

shell32_fallback.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
11
//go:build !windows
22

3-
/*
4-
* This file is part of go-win32-utils.
5-
*
6-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
7-
*
8-
* go-win32-utils is free software; you can redistribute it and/or modify
9-
* it under the terms of the GNU General Public License as published by
10-
* the Free Software Foundation; either version 2 of the License, or
11-
* (at your option) any later version.
12-
*
13-
* This program is distributed in the hope that it will be useful,
14-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16-
* GNU General Public License for more details.
17-
*
18-
* You should have received a copy of the GNU General Public License
19-
* along with this program; if not, write to the Free Software
20-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21-
*
22-
* As a special exception, you may use this file as part of a free software
23-
* library without restriction. Specifically, if other files instantiate
24-
* templates or use macros or inline functions from this file, or you compile
25-
* this file and link it with other files to produce an executable, this
26-
* file does not by itself cause the resulting executable to be covered by
27-
* the GNU General Public License. This exception does not however
28-
* invalidate any other reasons why the executable file might be covered by
29-
* the GNU General Public License.
30-
*/
31-
323
package win32
334

345
import (

shell32_windows.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
/*
2-
* This file is part of go-win32-utils.
3-
*
4-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
5-
*
6-
* go-win32-utils is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*
20-
* As a special exception, you may use this file as part of a free software
21-
* library without restriction. Specifically, if other files instantiate
22-
* templates or use macros or inline functions from this file, or you compile
23-
* this file and link it with other files to produce an executable, this
24-
* file does not by itself cause the resulting executable to be covered by
25-
* the GNU General Public License. This exception does not however
26-
* invalidate any other reasons why the executable file might be covered by
27-
* the GNU General Public License.
28-
*/
29-
301
package win32
312

323
import (

syscall_windows.go

-29
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
/*
2-
* This file is part of go-win32-utils.
3-
*
4-
* Copyright 2018-2023 ARDUINO SA (http://www.arduino.cc/)
5-
*
6-
* go-win32-utils is free software; you can redistribute it and/or modify
7-
* it under the terms of the GNU General Public License as published by
8-
* the Free Software Foundation; either version 2 of the License, or
9-
* (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
* GNU General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19-
*
20-
* As a special exception, you may use this file as part of a free software
21-
* library without restriction. Specifically, if other files instantiate
22-
* templates or use macros or inline functions from this file, or you compile
23-
* this file and link it with other files to produce an executable, this
24-
* file does not by itself cause the resulting executable to be covered by
25-
* the GNU General Public License. This exception does not however
26-
* invalidate any other reasons why the executable file might be covered by
27-
* the GNU General Public License.
28-
*/
29-
301
package win32
312

323
import "syscall"

0 commit comments

Comments
 (0)