Skip to content

Commit 6e2e5a5

Browse files
authored
Check allowed licenses in GitHub CI (#441)
This PR adds a new `make` target `make check_licenses` to ensure all Go dependencies has compatible licenses using [`go-licenses`](https://github.com/google/go-licenses) tool. Also adds this new target to our unit test GitHub workflow. --- By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice. Signed-off-by: Burak Varlı <burakvar@amazon.co.uk>
1 parent ea435c8 commit 6e2e5a5

4 files changed

Lines changed: 716 additions & 0 deletions

File tree

.github/workflows/unit-tests.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- name: Check style
2323
run: make check_style
2424

25+
- name: Check licenses
26+
run: make check_licenses
27+
2528
- name: Install Go Test Coverage
2629
run: make install-go-test-coverage
2730

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ ALL_OS_ARCH_OSVERSION=$(foreach os, $(ALL_OS), ${ALL_OS_ARCH_OSVERSION_${os}})
4747

4848
PLATFORM?=linux/amd64,linux/arm64
4949

50+
# List of allowed licenses in the CSI Driver's dependencies.
51+
# See https://github.com/google/licenseclassifier/blob/e6a9bb99b5a6f71d5a34336b8245e305f5430f99/license_type.go#L28 for list of cannonical names for licenses.
52+
ALLOWED_LICENSES="Apache-2.0,BSD-2-Clause,BSD-3-Clause,ISC,MIT"
53+
5054
# region is expected to be the same where cluster is created
5155
E2E_REGION?=us-east-1
5256
E2E_COMMIT_ID?=local
@@ -170,6 +174,10 @@ e2e: e2e-controller
170174
check_style:
171175
test -z "$$(gofmt -d . | tee /dev/stderr)"
172176

177+
.PHONY: check_licenses
178+
check_licenses:
179+
go mod download && go tool github.com/google/go-licenses check --allowed_licenses ${ALLOWED_LICENSES} ./...
180+
173181
.PHONY: clean
174182
clean:
175183
rm -rf bin/ && docker system prune

go.mod

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ require (
3838
github.com/cespare/xxhash/v2 v2.3.0 // indirect
3939
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
4040
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
41+
github.com/emirpasic/gods v1.12.0 // indirect
4142
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
4243
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
4344
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
@@ -49,33 +50,51 @@ require (
4950
github.com/gogo/protobuf v1.3.2 // indirect
5051
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5152
github.com/google/gnostic-models v0.6.8 // indirect
53+
github.com/google/go-licenses v1.6.0 // indirect
5254
github.com/google/gofuzz v1.2.0 // indirect
55+
github.com/google/licenseclassifier v0.0.0-20210722185704-3043a050f148 // indirect
5356
github.com/google/pprof v0.0.0-20240525223248-4bfdf5a9a2af // indirect
5457
github.com/imdario/mergo v0.3.6 // indirect
58+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
59+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
5560
github.com/josharian/intern v1.0.0 // indirect
5661
github.com/json-iterator/go v1.1.12 // indirect
62+
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
5763
github.com/mailru/easyjson v0.7.7 // indirect
64+
github.com/mitchellh/go-homedir v1.1.0 // indirect
5865
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
5966
github.com/modern-go/reflect2 v1.0.2 // indirect
6067
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
68+
github.com/otiai10/copy v1.6.0 // indirect
6169
github.com/pkg/errors v0.9.1 // indirect
6270
github.com/prometheus/client_golang v1.19.1 // indirect
6371
github.com/prometheus/client_model v0.6.1 // indirect
6472
github.com/prometheus/common v0.55.0 // indirect
6573
github.com/prometheus/procfs v0.15.1 // indirect
74+
github.com/sergi/go-diff v1.2.0 // indirect
75+
github.com/spf13/cobra v1.8.1 // indirect
6676
github.com/spf13/pflag v1.0.5 // indirect
77+
github.com/src-d/gcfg v1.4.0 // indirect
6778
github.com/x448/float16 v0.8.4 // indirect
79+
github.com/xanzy/ssh-agent v0.2.1 // indirect
80+
go.opencensus.io v0.23.0 // indirect
6881
go.uber.org/multierr v1.11.0 // indirect
6982
go.uber.org/zap v1.27.0 // indirect
83+
golang.org/x/crypto v0.36.0 // indirect
7084
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
85+
golang.org/x/mod v0.17.0 // indirect
7186
golang.org/x/oauth2 v0.21.0 // indirect
87+
golang.org/x/sync v0.12.0 // indirect
7288
golang.org/x/term v0.30.0 // indirect
7389
golang.org/x/time v0.3.0 // indirect
7490
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
7591
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
7692
google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect
7793
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
7894
gopkg.in/inf.v0 v0.9.1 // indirect
95+
gopkg.in/src-d/go-billy.v4 v4.3.2 // indirect
96+
gopkg.in/src-d/go-git.v4 v4.13.1 // indirect
97+
gopkg.in/warnings.v0 v0.1.2 // indirect
7998
k8s.io/apiextensions-apiserver v0.31.0 // indirect
8099
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
81100
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
@@ -101,3 +120,5 @@ require (
101120
k8s.io/apimachinery v0.31.3
102121
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
103122
)
123+
124+
tool github.com/google/go-licenses

0 commit comments

Comments
 (0)