File tree 3 files changed +46
-0
lines changed
3 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -451,6 +451,7 @@ lint/ts:
451
451
452
452
lint/go :
453
453
./scripts/check_enterprise_imports.sh
454
+ ./scripts/check_codersdk_imports.sh
454
455
linter_ver=$(shell egrep -o 'GOLANGCI_LINT_VERSION=\S+' dogfood/contents/Dockerfile | cut -d '=' -f 2)
455
456
go run github.com/golangci/golangci-lint/cmd/golangci-lint@v$$ linter_ver run
456
457
.PHONY : lint/go
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # This file checks all codersdk imports to be sure it doesn't import any packages
4
+ # that are being replaced in go.mod.
5
+
6
+ set -euo pipefail
7
+ # shellcheck source=scripts/lib.sh
8
+ source " $( dirname " ${BASH_SOURCE[0]} " ) /lib.sh"
9
+ cdroot
10
+
11
+ deps=$( ./scripts/list_dependencies.sh github.com/coder/coder/v2/codersdk)
12
+
13
+ set +e
14
+ replaces=$( grep " ^replace" go.mod | awk ' {print $2}' )
15
+ conflicts=$( echo " $deps " | grep -xF -f <( echo " $replaces " ) )
16
+
17
+ if [ -n " ${conflicts} " ]; then
18
+ error " $( printf ' codersdk cannot import the following packages being replaced in go.mod:\n%s' " ${conflicts} " ) "
19
+ fi
20
+ log " codersdk imports OK"
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # This script lists all dependencies of a given package, including dependencies
4
+ # of test files.
5
+
6
+ # Usage: list_dependencies <package>
7
+
8
+ set -euo pipefail
9
+
10
+ if [[ " $# " -ne 1 ]]; then
11
+ echo " Usage: $0 <package>"
12
+ exit 1
13
+ fi
14
+
15
+ package=" $1 "
16
+ all_deps=$( go list -f ' {{join .Deps "\n"}}' " $package " )
17
+ test_imports=$( go list -f ' {{ join .TestImports " " }}' " $package " )
18
+ xtest_imports=$( go list -f ' {{ join .XTestImports " " }}' " $package " )
19
+
20
+ for pkg in $test_imports $xtest_imports ; do
21
+ deps=$( go list -f ' {{join .Deps "\n"}}' " $pkg " )
22
+ all_deps+=$' \n ' " $deps "
23
+ done
24
+
25
+ echo " $all_deps " | sort | uniq
You can’t perform that action at this time.
0 commit comments