fun-with-monorepos

An opinionated test repo for fun with monorepos using Go and Bazel!

Structure

  • Go packages reside at the root of the repo, and Bazel is used to build and test them.
  • The apps directory contains Go applications that depend on the packages in the root of the repo.
    • Apps could include services, CLI tools, etc. but should produce a binary or container image.

Setup

brew install bazelisk go golangci-lint

Buf Toolchain:

go install github.com/bufbuild/buf/cmd/buf@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install github.com/bufbuild/connect-go/cmd/protoc-gen-connect-go@latest

Developing & Contributing

Build

bazelisk build //...

Test

bazelisk test //...

Linting Go Code

golangci-lint run

Adding A New Go package

# Install new package as normal
go get github.com/your/thing

# Update Bazel with new Go package
bazelisk run //:gazelle-update-repos

Adding New Go Test, Package, or Go Code File

# Register new files with Bazel via Gazelle
bazelisk run //:gazelle

Committing Changes

Commits should follow conventional commits. See here for more information.

The repo is configured to use release-please to automatically create releases and changelogs based on the conventional commit messages. See here for more information.

TODOs / Ideas

  • Connect-go service
  • Buf lint and breaking detection
  • Generate Tech Docs
  • Change image versioning to git tags
  • Link packages and containers to releases
  • Swagger spec generation
  • GRPC clients in multiple languages
  • Setup golangci-lint
  • Setup release-please
  • Setup Bazel build and test

Resources Used For Developing The Monorepo