Skip to content

Commit 1a95d2e

Browse files
authored
chore: add license check (#3)
* chore: add license check * add licenses files
1 parent 6cc1a0c commit 1a95d2e

File tree

14 files changed

+1684
-0
lines changed

14 files changed

+1684
-0
lines changed
Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md
2+
name: Check Go Dependencies
3+
4+
# See: https://docs.github.com/actions/reference/workflows-and-actions/events-that-trigger-workflows
5+
on:
6+
create:
7+
push:
8+
paths:
9+
- ".github/workflows/check-go-dependencies-task.ya?ml"
10+
- ".licenses/**"
11+
- ".licensed.json"
12+
- ".licensed.ya?ml"
13+
- "Taskfile.ya?ml"
14+
- "**/.gitmodules"
15+
- "**/go.mod"
16+
- "**/go.sum"
17+
pull_request:
18+
paths:
19+
- ".github/workflows/check-go-dependencies-task.ya?ml"
20+
- ".licenses/**"
21+
- ".licensed.json"
22+
- ".licensed.ya?ml"
23+
- "Taskfile.ya?ml"
24+
- "**/.gitmodules"
25+
- "**/go.mod"
26+
- "**/go.sum"
27+
schedule:
28+
# Run periodically to catch breakage caused by external changes.
29+
- cron: "0 8 * * WED"
30+
workflow_dispatch:
31+
repository_dispatch:
32+
33+
jobs:
34+
run-determination:
35+
runs-on: ubuntu-latest
36+
permissions: {}
37+
outputs:
38+
result: ${{ steps.determination.outputs.result }}
39+
steps:
40+
- name: Determine if the rest of the workflow should run
41+
id: determination
42+
run: |
43+
RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
44+
# The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
45+
if [[
46+
"${{ github.event_name }}" != "create" ||
47+
"${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
48+
]]; then
49+
# Run the other jobs.
50+
RESULT="true"
51+
else
52+
# There is no need to run the other jobs.
53+
RESULT="false"
54+
fi
55+
56+
echo "result=$RESULT" >>$GITHUB_OUTPUT
57+
58+
check-cache:
59+
needs: run-determination
60+
if: needs.run-determination.outputs.result == 'true'
61+
runs-on: ubuntu-latest
62+
permissions:
63+
contents: read
64+
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v5
68+
with:
69+
submodules: recursive
70+
71+
# This is required to allow licensee/setup-licensed to install Licensed via Ruby gem.
72+
- name: Install Ruby
73+
uses: ruby/setup-ruby@v1
74+
with:
75+
ruby-version: ruby # Install latest version
76+
77+
- name: Install licensed
78+
uses: licensee/setup-licensed@v1.3.2
79+
with:
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
version: 5.x
82+
83+
- name: Install Go
84+
uses: actions/setup-go@v6
85+
with:
86+
go-version-file: go.mod
87+
88+
- name: Update dependencies license metadata cache
89+
run: |
90+
go tool \
91+
github.com/go-task/task/v3/cmd/task \
92+
--silent \
93+
general:cache-dep-licenses
94+
95+
- name: Check for outdated cache
96+
id: diff
97+
run: |
98+
git add .
99+
if
100+
! git diff \
101+
--cached \
102+
--color \
103+
--exit-code
104+
then
105+
echo
106+
echo "::error::Dependency license metadata out of sync. See: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-go-dependencies-task.md#metadata-cache"
107+
exit 1
108+
fi
109+
110+
# Some might find it convenient to have CI generate the cache rather than setting up for it locally
111+
- name: Upload cache to workflow artifact
112+
if: failure() && steps.diff.outcome == 'failure'
113+
uses: actions/upload-artifact@v4
114+
with:
115+
if-no-files-found: error
116+
include-hidden-files: true
117+
name: dep-licenses-cache
118+
path: .licenses/
119+
120+
check-deps:
121+
needs: run-determination
122+
if: needs.run-determination.outputs.result == 'true'
123+
runs-on: ubuntu-latest
124+
permissions:
125+
contents: read
126+
127+
steps:
128+
- name: Checkout repository
129+
uses: actions/checkout@v5
130+
with:
131+
submodules: recursive
132+
133+
# This is required to allow licensee/setup-licensed to install Licensed via Ruby gem.
134+
- name: Install Ruby
135+
uses: ruby/setup-ruby@v1
136+
with:
137+
ruby-version: ruby # Install latest version
138+
139+
- name: Install licensed
140+
uses: licensee/setup-licensed@v1.3.2
141+
with:
142+
github_token: ${{ secrets.GITHUB_TOKEN }}
143+
version: 5.x
144+
145+
- name: Install Go
146+
uses: actions/setup-go@v6
147+
with:
148+
go-version-file: go.mod
149+
150+
- name: Check for dependencies with unapproved licenses
151+
run: |
152+
go tool \
153+
github.com/go-task/task/v3/cmd/task \
154+
--silent \
155+
general:check-dep-licenses

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
build/
2+
3+
# Mac system files
4+
.DS_Store

.licensed.yml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
sources:
2+
go: true
3+
4+
cache_path: .licenses
5+
6+
apps:
7+
- source_path: .
8+
9+
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-dependencies/GPL-3.0/.licensed.yml
10+
allowed:
11+
# The following are based on: https://www.gnu.org/licenses/license-list.html#GPLCompatibleLicenses
12+
- gpl-1.0-or-later
13+
- gpl-1.0+ # Deprecated ID for `gpl-1.0-or-later`
14+
- gpl-2.0-or-later
15+
- gpl-2.0+ # Deprecated ID for `gpl-2.0-or-later`
16+
- gpl-3.0-only
17+
- gpl-3.0 # Deprecated ID for `gpl-3.0-only`
18+
- gpl-3.0-or-later
19+
- gpl-3.0+ # Deprecated ID for `gpl-3.0-or-later`
20+
- lgpl-2.0-or-later
21+
- lgpl-2.0+ # Deprecated ID for `lgpl-2.0-or-later`
22+
- lgpl-2.1-only
23+
- lgpl-2.1 # Deprecated ID for `lgpl-2.1-only`
24+
- lgpl-2.1-or-later
25+
- lgpl-2.1+ # Deprecated ID for `lgpl-2.1-or-later`
26+
- lgpl-3.0-only
27+
- lgpl-3.0 # Deprecated ID for `lgpl-3.0-only`
28+
- lgpl-3.0-or-later
29+
- lgpl-3.0+ # Deprecated ID for `lgpl-3.0-or-later`
30+
- fsfap
31+
- apache-2.0
32+
- artistic-2.0
33+
- clartistic
34+
- sleepycat
35+
- bsl-1.0
36+
- bsd-3-clause
37+
- cecill-2.0
38+
- bsd-3-clause-clear
39+
# "Cryptix General License" - no SPDX ID (https://github.com/spdx/license-list-XML/issues/456)
40+
- ecos-2.0
41+
- ecl-2.0
42+
- efl-2.0
43+
- eudatagrid
44+
- mit
45+
- bsd-2-clause # Subsumed by `bsd-2-clause-views`
46+
- bsd-2-clause-netbsd # Deprecated ID for `bsd-2-clause`
47+
- bsd-2-clause-views # This is the version linked from https://www.gnu.org/licenses/license-list.html#FreeBSD
48+
- bsd-2-clause-freebsd # Deprecated ID for `bsd-2-clause-views`
49+
- ftl
50+
- hpnd
51+
- imatix
52+
- imlib2
53+
- ijg
54+
# "Informal license" - this is a general class of license
55+
- intel
56+
- isc
57+
- mpl-2.0
58+
- ncsa
59+
# "License of Netscape JavaScript" - no SPDX ID
60+
- oldap-2.7
61+
# "License of Perl 5 and below" - possibly `Artistic-1.0-Perl` ?
62+
- cc0-1.0
63+
- cc-pddc
64+
- psf-2.0
65+
- ruby
66+
- sgi-b-2.0
67+
- smlnj
68+
- standardml-nj # Deprecated ID for `smlnj`
69+
- unicode-dfs-2015
70+
- upl-1.0
71+
- unlicense
72+
- vim
73+
- w3c
74+
- wtfpl
75+
- lgpl-2.0-or-later with wxwindows-exception-3.1
76+
- wxwindows # Deprecated ID for `lgpl-2.0-or-later with wxwindows-exception-3.1`
77+
- x11
78+
- xfree86-1.1
79+
- zlib
80+
- zpl-2.0
81+
- zpl-2.1
82+
# The following are based on individual license text
83+
- eupl-1.2
84+
- liliq-r-1.1
85+
- liliq-rplus-1.1

0 commit comments

Comments
 (0)