loading...

An example of a Golang-based monorepo

flowerinthenight profile image flowerinthenight ・1 min read

Planning to use a monorepo to structure your Go codes but not quite keen on the complexity of Bazel? You might want to check out:

GitHub logo flowerinthenight / golang-monorepo

An example of a golang-based monorepo.

GitHub Actions CircleCI
Main CircleCI

Overview

This is an example of a golang-based monorepo. It has the following features:

  • Only build the services or cmds that are modified in a commit;
  • Build all services and/or cmds that are affected by changes in common codes (i.e. pkg);
  • Build all services and/or cmds that are affected by changes in vendor codes.

For now, CircleCI 2.1 and GitHub Actions are supported. But since it uses bash scripts and Makefiles, it should be fairly straightforward to port to TravisCI or AppVeyor, etc.

At the moment, CI is setup to use Go 1.14[.x] with GO111MODULE=on and GOFLAGS=-mod=vendor environment variables enabled during build. See sample dockerfile for more details.

How does it work

During CI builds, build.sh iterates the updated files within the commit range (CIRCLE_COMPARE_URL environment variable in CircleCI) or the modified files within a single commit (when the value is not a valid…

It uses Bash scripts, Makefiles, and the go tools to determine what binaries to build based on commit changes. You might find this useful.

Discussion

pic
Editor guide