mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-13 17:06:06 -06:00
Currently when running `make updatedeps` from a branch, the dependency list from master ends up getting used. We tried to work around this in35490f7812
, and got part way there, but here's what was happening: - record the current SHA - run `go get -f -u -v ./...` which ends up checking out master - master is checked out early in the `go get` process, which means all subsequent dependencies are resolved from master - re-checkout the recorded SHA - run tests This works in most cases, except when the branch being tested actually changes the list of dependencies in some way. Here we move away from letting `go get -v` walk through everything in `./...`, instead building our own list of dependencies with the help of `deplist`. We can then filter terraform packages out from the list, so they don't get touched, and safely update the rest. This should solve problems like those observed in #899 and #900. __Note__: had to add a feature to deplist to make this work properly; see016ef97111
Working on getting it accepted upstream.
64 lines
1.8 KiB
Makefile
64 lines
1.8 KiB
Makefile
TEST?=./...
|
|
VETARGS?=-asmdecl -atomic -bool -buildtags -copylocks -methods -nilfunc -printf -rangeloops -shift -structtags -unsafeptr
|
|
|
|
default: test
|
|
|
|
# bin generates the releaseable binaries for Terraform
|
|
bin: generate
|
|
@sh -c "'$(CURDIR)/scripts/build.sh'"
|
|
|
|
# dev creates binaries for testing Terraform locally. These are put
|
|
# into ./bin/ as well as $GOPATH/bin
|
|
dev: generate
|
|
@TF_DEV=1 sh -c "'$(CURDIR)/scripts/build.sh'"
|
|
|
|
# test runs the unit tests and vets the code
|
|
test: generate
|
|
TF_ACC= go test $(TEST) $(TESTARGS) -timeout=30s -parallel=4
|
|
@$(MAKE) vet
|
|
|
|
# testacc runs acceptance tests
|
|
testacc: generate
|
|
@if [ "$(TEST)" = "./..." ]; then \
|
|
echo "ERROR: Set TEST to a specific package"; \
|
|
exit 1; \
|
|
fi
|
|
TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout 45m
|
|
|
|
# testrace runs the race checker
|
|
testrace: generate
|
|
TF_ACC= go test -race $(TEST) $(TESTARGS)
|
|
|
|
# updatedeps installs all the dependencies that Terraform needs to run
|
|
# and build.
|
|
updatedeps:
|
|
go get -u github.com/phinze/deplist
|
|
go get -u github.com/mitchellh/gox
|
|
go get -u golang.org/x/tools/cmd/stringer
|
|
go get -u golang.org/x/tools/cmd/vet
|
|
go list github.com/hashicorp/terraform/... \
|
|
| xargs -n 1 deplist -s \
|
|
| grep -v github.com/hashicorp/terraform \
|
|
| sort -u \
|
|
| xargs go get -f -u -v
|
|
|
|
# vet runs the Go source code static analysis tool `vet` to find
|
|
# any common errors.
|
|
vet:
|
|
@go tool vet 2>/dev/null ; if [ $$? -eq 3 ]; then \
|
|
go get golang.org/x/tools/cmd/vet; \
|
|
fi
|
|
@echo "go tool vet $(VETARGS) ."
|
|
@go tool vet $(VETARGS) . ; if [ $$? -eq 1 ]; then \
|
|
echo ""; \
|
|
echo "Vet found suspicious constructs. Please check the reported constructs"; \
|
|
echo "and fix them if necessary before submitting the code for reviewal."; \
|
|
fi
|
|
|
|
# generate runs `go generate` to build the dynamically generated
|
|
# source files.
|
|
generate:
|
|
go generate ./...
|
|
|
|
.PHONY: bin default generate test updatedeps vet
|