This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Expand file tree
/
Copy pathlicenses.sh
More file actions
executable file
·44 lines (36 loc) · 1.71 KB
/
licenses.sh
File metadata and controls
executable file
·44 lines (36 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env bash
# This script either generates a report of third-party dependencies, or runs a check that fails
# if there are any unapproved dependencies ('action items').
#
# Please refer to the handbook entry for more details: https://docs-legacy.sourcegraph.com/dev/background-information/ci#third-party-licenses
set -euf -o pipefail
# by default, generate a report. this does not care if there are pending action items
COMMAND="report --format=csv --save=./third-party-licenses/ThirdPartyLicenses.csv --write-headers"
# if LICENSE_CHECK=true, report unapproved dependencies and error if there are any ('action items')
if [[ "${LICENSE_CHECK:-''}" == "true" ]]; then
COMMAND="action_items"
fi
tmpdir=$(mktemp -d -t src-gocache.XXXXXXXX)
export GOPATH=$tmpdir # stuff in cache causes strange things to happen
echo "Using $(go env GOPATH) as GOPATH"
function cleanup() {
go clean -modcache # need to remove modcache from tmpdir before we can remove
echo "Removing $tmpdir"
rm -rf "$tmpdir"
}
trap cleanup EXIT
# prepare dependencies
go mod tidy
go mod vendor # go mod download does not work with license_finder
echo "Running pnpm install with retry"
./dev/ci/pnpm-install-with-retry.sh
echo "Running various license_finder things"
# report license_finder configuration
license_finder permitted_licenses list
license_finder restricted_licenses list
license_finder ignored_groups list
license_finder ignored_dependencies list
license_finder dependencies list
# run license check
echo "Running license_finder - if this fails, refer to our handbook: https://docs-legacy.sourcegraph.com/dev/background-information/ci#third-party-licenses"
license_finder "${COMMAND}" --columns=package_manager name version licenses homepage approved