Skip to content

Commit 9b6c3ac

Browse files
committed
add check license workflow
1 parent 8544133 commit 9b6c3ac

File tree

3 files changed

+218
-4
lines changed

3 files changed

+218
-4
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

go.mod

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ require (
6060
github.com/AlecAivazis/survey/v2 v2.3.7 // indirect
6161
github.com/Azure/go-ansiterm v0.0.0-20250102033503-faa5f7b0171c // indirect
6262
github.com/DefangLabs/secret-detector v0.0.0-20250403165618-22662109213e // indirect
63+
github.com/Ladicle/tabwriter v1.0.0 // indirect
6364
github.com/Masterminds/semver/v3 v3.4.0 // indirect
6465
github.com/Microsoft/go-winio v0.6.2 // indirect
6566
github.com/ProtonMail/go-crypto v1.3.0 // indirect
6667
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
68+
github.com/alecthomas/chroma/v2 v2.19.0 // indirect
6769
github.com/apapsch/go-jsonmerge/v2 v2.0.0 // indirect
6870
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
6971
github.com/arduino/go-properties-orderedmap v1.8.1 // indirect
@@ -88,6 +90,7 @@ require (
8890
github.com/buger/goterm v1.0.4 // indirect
8991
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
9092
github.com/cespare/xxhash/v2 v2.3.0 // indirect
93+
github.com/chainguard-dev/git-urls v1.0.2 // indirect
9194
github.com/cloudflare/circl v1.6.1 // indirect
9295
github.com/cmaglie/pb v1.0.27 // indirect
9396
github.com/codeclysm/extract/v4 v4.0.0 // indirect
@@ -106,6 +109,7 @@ require (
106109
github.com/distribution/reference v0.6.0 // indirect
107110
github.com/djherbis/buffer v1.2.0 // indirect
108111
github.com/djherbis/nio/v3 v3.0.1 // indirect
112+
github.com/dlclark/regexp2 v1.11.5 // indirect
109113
github.com/docker/buildx v0.26.1 // indirect
110114
github.com/docker/cli-docs-tool v0.10.0 // indirect
111115
github.com/docker/distribution v2.8.3+incompatible // indirect
@@ -114,9 +118,11 @@ require (
114118
github.com/docker/go-connections v0.5.0 // indirect
115119
github.com/docker/go-metrics v0.0.1 // indirect
116120
github.com/docker/go-units v0.5.0 // indirect
121+
github.com/dominikbraun/graph v0.23.0 // indirect
117122
github.com/dprotaso/go-yit v0.0.0-20220510233725-9ba8df137936 // indirect
118123
github.com/ebitengine/purego v0.8.4 // indirect
119124
github.com/eiannone/keyboard v0.0.0-20220611211555-0d226195f203 // indirect
125+
github.com/elliotchance/orderedmap/v3 v3.1.0 // indirect
120126
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
121127
github.com/emirpasic/gods v1.18.1 // indirect
122128
github.com/felixge/httpsnoop v1.0.4 // indirect
@@ -134,6 +140,9 @@ require (
134140
github.com/go-openapi/jsonpointer v0.21.0 // indirect
135141
github.com/go-openapi/jsonreference v0.20.2 // indirect
136142
github.com/go-openapi/swag v0.23.0 // indirect
143+
github.com/go-task/slim-sprig/v3 v3.0.0 // indirect
144+
github.com/go-task/task/v3 v3.44.1 // indirect
145+
github.com/go-task/template v0.2.0 // indirect
137146
github.com/go-viper/mapstructure/v2 v2.4.0 // indirect
138147
github.com/gofrs/uuid/v5 v5.3.2 // indirect
139148
github.com/gogo/protobuf v1.3.2 // indirect
@@ -156,13 +165,15 @@ require (
156165
github.com/inconshreveable/mousetrap v1.1.0 // indirect
157166
github.com/inhies/go-bytesize v0.0.0-20220417184213-4913239db9cf // indirect
158167
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
168+
github.com/joho/godotenv v1.5.1 // indirect
159169
github.com/jonboulle/clockwork v0.5.0 // indirect
160170
github.com/josharian/intern v1.0.0 // indirect
161171
github.com/json-iterator/go v1.1.12 // indirect
162172
github.com/juju/errors v1.0.0 // indirect
163173
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect
164174
github.com/kevinburke/ssh_config v1.2.0 // indirect
165175
github.com/klauspost/compress v1.18.0 // indirect
176+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
166177
github.com/lufia/plan9stats v0.0.0-20250317134145-8bc96cf8fc35 // indirect
167178
github.com/mailru/easyjson v0.9.0 // indirect
168179
github.com/marcinbor85/gohex v0.0.0-20210308104911-55fb1c624d84 // indirect
@@ -213,8 +224,10 @@ require (
213224
github.com/prometheus/client_model v0.6.1 // indirect
214225
github.com/prometheus/common v0.62.0 // indirect
215226
github.com/prometheus/procfs v0.15.1 // indirect
227+
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
216228
github.com/rivo/uniseg v0.4.7 // indirect
217229
github.com/sagikazarmark/locafero v0.7.0 // indirect
230+
github.com/sajari/fuzzy v1.0.0 // indirect
218231
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
219232
github.com/schollz/closestmatch v2.1.0+incompatible // indirect
220233
github.com/secure-systems-lab/go-securesystemslib v0.6.0 // indirect
@@ -230,6 +243,7 @@ require (
230243
github.com/spf13/cast v1.7.1 // indirect
231244
github.com/spf13/pflag v1.0.9 // indirect
232245
github.com/spf13/viper v1.20.1 // indirect
246+
github.com/stretchr/objx v0.5.2 // indirect
233247
github.com/subosito/gotenv v1.6.0 // indirect
234248
github.com/swaggest/refl v1.4.0 // indirect
235249
github.com/theupdateframework/notary v0.7.0 // indirect
@@ -252,6 +266,7 @@ require (
252266
github.com/xhit/go-str2duration/v2 v2.1.0 // indirect
253267
github.com/yusufpapurcu/wmi v1.2.4 // indirect
254268
github.com/zclconf/go-cty v1.16.2 // indirect
269+
github.com/zeebo/xxh3 v1.0.2 // indirect
255270
go.bug.st/downloader/v2 v2.2.0 // indirect
256271
go.bug.st/serial v1.6.4 // indirect
257272
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
@@ -294,10 +309,14 @@ require (
294309
k8s.io/klog/v2 v2.130.1 // indirect
295310
k8s.io/kube-openapi v0.0.0-20241105132330-32ad38e42d3f // indirect
296311
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
312+
mvdan.cc/sh/v3 v3.12.0 // indirect
297313
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
298314
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
299315
sigs.k8s.io/yaml v1.4.0 // indirect
300316
tags.cncf.io/container-device-interface v1.0.1 // indirect
301317
)
302318

303-
tool github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
319+
tool (
320+
github.com/go-task/task/v3/cmd/task
321+
github.com/oapi-codegen/oapi-codegen/v2/cmd/oapi-codegen
322+
)

0 commit comments

Comments
 (0)