terraform/Makefile
Martin Atkins 5811be26f8 go.mod: Separate modules at code ownership boundaries
Historically it's been hard for us to keep on top of dependency upgrades
as a matter of course because it's unclear which code owners might be
affected by or responsible for an upgrade of each module.

After trying a few different techniques to try to mitigate this, the most
promising one seems to be to tell the Go toolchain that each of these
components is a separate Go module, but then to stitch them all back
together again using replace directives so that we can mostly ignore these
module boundaries in everyday development.

The one case where we _do_ need to pay attention to these boundaries is
also the case where the separation is useful: upgrading a dependency of
any one of these modules might potentially force upgrading it for another
module too, and so the Go toolchain will help us notice that interaction
and we can immediately which code owners might need to be involved in
reviewing and testing that particular upgrade.

To make that process less onerous, this adds a new makefile target
"make syncdeps" which runs "go mod tidy" in all of the modules at once
and thus forces the toolchain to align their dependencies to the extent
required for them all to be linked together successfully, and to generate
go.mod and/or go.sum diffs that will match our configured code ownership
paths to trigger the appropriate code review requests.

Hopefully before too long we'll be able to move all the backends out into
provider plugins and delete the "legacy" module entirely and then this
oddness won't be needed anymore, but as long as we're all trying to play
together in this same sandbox this is a small amount of extra ceremony in
return for hopefully reducing the level of anxiety involved in keeping the
system's dependencies up to date more consistently.
2024-03-11 08:34:46 -07:00

55 lines
1.6 KiB
Makefile

# generate runs `go generate` to build the dynamically generated
# source files, except the protobuf stubs which are built instead with
# "make protobuf".
generate:
go generate ./...
# We separate the protobuf generation because most development tasks on
# Terraform do not involve changing protobuf files and protoc is not a
# go-gettable dependency and so getting it installed can be inconvenient.
#
# If you are working on changes to protobuf interfaces, run this Makefile
# target to be sure to regenerate all of the protobuf stubs using the expected
# versions of protoc and the protoc Go plugins.
protobuf:
go run ./tools/protobuf-compile .
fmtcheck:
"$(CURDIR)/scripts/gofmtcheck.sh"
importscheck:
"$(CURDIR)/scripts/goimportscheck.sh"
staticcheck:
"$(CURDIR)/scripts/staticcheck.sh"
exhaustive:
"$(CURDIR)/scripts/exhaustive.sh"
copyright:
"$(CURDIR)/scripts/copyright.sh" --plan
copyrightfix:
"$(CURDIR)/scripts/copyright.sh"
syncdeps:
"$(CURDIR)/scripts/syncdeps.sh"
# Run this if working on the website locally to run in watch mode.
website:
$(MAKE) -C website website
# Use this if you have run `website/build-local` to use the locally built image.
website/local:
$(MAKE) -C website website/local
# Run this to generate a new local Docker image.
website/build-local:
$(MAKE) -C website website/build-local
# disallow any parallelism (-j) for Make. This is necessary since some
# commands during the build process create temporary files that collide
# under parallel conditions.
.NOTPARALLEL:
.PHONY: fmtcheck importscheck generate protobuf staticcheck syncdeps website website/local website/build-local