Skip to content

Commit d3cf243

Browse files
authored
Confirm that modules are always tidy and vendored. (#1003)
1 parent 94bf67e commit d3cf243

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.evergreen/config.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,13 @@ tasks:
10681068
vars:
10691069
targets: check-fmt
10701070

1071+
- name: sa-modules
1072+
tags: ["static-analysis"]
1073+
commands:
1074+
- func: run-make
1075+
vars:
1076+
targets: check-modules
1077+
10711078
- name: sa-lint
10721079
tags: ["static-analysis"]
10731080
commands:

Makefile

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ TEST_TIMEOUT = 1800
1313

1414
### Utility targets. ###
1515
.PHONY: default
16-
default: add-license build build-examples check-env check-fmt lint test-short
16+
default: add-license build build-examples check-env check-fmt check-modules lint test-short
1717

1818
.PHONY: add-license
1919
add-license:
@@ -49,6 +49,20 @@ build-tests:
4949
check-fmt:
5050
etc/check_fmt.sh $(PKGS)
5151

52+
# check-modules runs "go mod tidy" then "go mod vendor" and exits with a non-zero exit code if there
53+
# are any module or vendored modules changes. The intent is to confirm two properties:
54+
#
55+
# 1. Exactly the required modules are declared as dependencies. We should always be able to run
56+
# "go mod tidy" and expect that no unrelated changes are made to the "go.mod" file.
57+
#
58+
# 2. All required modules are copied into the vendor/ directory and are an exact copy of the
59+
# original module source code (i.e. the vendored modules are not modified from their original code).
60+
.PHONY: check-modules
61+
check-modules:
62+
go mod tidy -v
63+
go mod vendor
64+
git diff --exit-code go.mod go.sum ./vendor
65+
5266
.PHONY: doc
5367
doc:
5468
godoc -http=:6060 -index

0 commit comments

Comments
 (0)