Skip to content

Commit

Permalink
Confirm that modules are always tidy and vendored. (mongodb#1003)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewdale authored Jul 1, 2022
1 parent 94bf67e commit d3cf243
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,13 @@ tasks:
vars:
targets: check-fmt

- name: sa-modules
tags: ["static-analysis"]
commands:
- func: run-make
vars:
targets: check-modules

- name: sa-lint
tags: ["static-analysis"]
commands:
Expand Down
16 changes: 15 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ TEST_TIMEOUT = 1800

### Utility targets. ###
.PHONY: default
default: add-license build build-examples check-env check-fmt lint test-short
default: add-license build build-examples check-env check-fmt check-modules lint test-short

.PHONY: add-license
add-license:
Expand Down Expand Up @@ -49,6 +49,20 @@ build-tests:
check-fmt:
etc/check_fmt.sh $(PKGS)

# check-modules runs "go mod tidy" then "go mod vendor" and exits with a non-zero exit code if there
# are any module or vendored modules changes. The intent is to confirm two properties:
#
# 1. Exactly the required modules are declared as dependencies. We should always be able to run
# "go mod tidy" and expect that no unrelated changes are made to the "go.mod" file.
#
# 2. All required modules are copied into the vendor/ directory and are an exact copy of the
# original module source code (i.e. the vendored modules are not modified from their original code).
.PHONY: check-modules
check-modules:
go mod tidy -v
go mod vendor
git diff --exit-code go.mod go.sum ./vendor

.PHONY: doc
doc:
godoc -http=:6060 -index
Expand Down

0 comments on commit d3cf243

Please sign in to comment.