All Projects → flowerinthenight → Golang Monorepo

flowerinthenight / Golang Monorepo

Licence: mit
An example of a golang-based monorepo.

Programming Languages

go
31211 projects - #10 most used programming language
shell
77523 projects
golang
3204 projects
bash
514 projects

Projects that are alternatives of or similar to Golang Monorepo

Alpinewsl
Alpine Linux based WSL distribution. Supports multi-install. Lightest WSL distribution.
Stars: ✭ 203 (-6.88%)
Mutual labels:  makefile
Puppeteer Extra
💯 Teach puppeteer new tricks through plugins.
Stars: ✭ 3,397 (+1458.26%)
Mutual labels:  monorepo
Easyrtspclient
Streaming media sdk tool:An elegant, simple, high performance & high compatibility RTSP Client Utility,can use in RTSP Player,NVR,RTSP Relay,EasyRTSPClient can run in any platform ,such as x68/x64/Windows/Linux/Android/iOS/arm etc..,with flexible interface,EasyRTSPClient can fit almost all network IPCamera,very easy to use.简单、稳定、高效、易用的RTSPClient工具,支持Windows、Linux、ARM、Android、iOS等几乎所有平台,支持RTP Over TCP/UDP,支持断线重连,能够接入市面上99%以上的IPC,调用简单且成熟稳定!
Stars: ✭ 213 (-2.29%)
Mutual labels:  makefile
Openwrt Pcap dnsproxy
Pcap_DNSProxy for OpenWrt/LEDE
Stars: ✭ 204 (-6.42%)
Mutual labels:  makefile
Docs
Documentation for setting up OpenAPS
Stars: ✭ 204 (-6.42%)
Mutual labels:  makefile
Pcat open source
PointCloud Annotation Tools, support to label object bound box, ground, lane and kerb
Stars: ✭ 209 (-4.13%)
Mutual labels:  makefile
Migrating To Cloud Native Application Architectures
《迁移到云原生应用架构》中文版 https://jimmysong.io/migrating-to-cloud-native-application-architectures/
Stars: ✭ 203 (-6.88%)
Mutual labels:  makefile
How To Be A Good Programmer
I'm here to tell you some amazing stuff which teacher would never tell you.
Stars: ✭ 3,020 (+1285.32%)
Mutual labels:  makefile
Helmfiles
Comprehensive Distribution of Helmfiles for Kubernetes
Stars: ✭ 205 (-5.96%)
Mutual labels:  makefile
Margarita
[not actively maintained] Mobile and Web application implementing Kiwi.com Tequila API
Stars: ✭ 213 (-2.29%)
Mutual labels:  monorepo
Circleci Monorepo
An example of monorepo with CircleCI using conditional workflows and pipeline parameters.
Stars: ✭ 205 (-5.96%)
Mutual labels:  monorepo
Bit
A tool for component-driven application development.
Stars: ✭ 14,443 (+6525.23%)
Mutual labels:  monorepo
Browserpass Native
Browserpass native client app
Stars: ✭ 209 (-4.13%)
Mutual labels:  makefile
Docker Makefile
Makefile for building docker repository releases
Stars: ✭ 204 (-6.42%)
Mutual labels:  makefile
Go Build Template
A Makefile/Dockerfile example for Go projects.
Stars: ✭ 2,625 (+1104.13%)
Mutual labels:  makefile
Monorepo Builder
[READ-ONLY] Not only Composer tools to build a Monorepo - Init, Split and Release Monorepo
Stars: ✭ 201 (-7.8%)
Mutual labels:  monorepo
Provision docker
Test Ansible roles and playbooks using Docker
Stars: ✭ 207 (-5.05%)
Mutual labels:  makefile
Stator
Stator, your go-to template for the perfect stack. 😍🙏
Stars: ✭ 217 (-0.46%)
Mutual labels:  monorepo
Openwrt Dns Forwarder
DNS-Forwarder for OpenWrt
Stars: ✭ 215 (-1.38%)
Mutual labels:  makefile
React Barcode
A <Barcode/> component for use with React.
Stars: ✭ 210 (-3.67%)
Mutual labels:  makefile
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 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 range), excluding hidden files, pkg, and vendor folders. It will then try to walk up the directory path until it can find a Makefile (excluding root Makefile). Once found, the root Makefile will include that Makefile and call the custom rule as target, thus, initiating the build.

When the changes belong to either pkg or vendor, the script will then try to determine the services (and cmds) that have dependencies using the go list command. All dependent services will then be built using the same process described above.

You can override the COMMIT_RANGE environment variable for your own CI. If this is set, build.sh will use its value. You also want to set CIRCLE_SHA1 to your commit SHA (CIRCLE_SHA1 is CircleCI-specific). Example for GitHub Actions is here. Something like:

# If your commit range is correct:
COMMIT_RANGE: aaaaa..bbbbb
CIRCLE_SHA1: aaaaa

# If no valid commit range:
COMMIT_RANGE: <your_commit_sha>
CIRCLE_SHA1: <your_commit_sha>

Directory structure

  • services/ - Basically, long running services.
  • cmd/ - CLI-based tools that are not long running.
  • pkg/ - Shared codes, or libraries common across the repo.
  • vendor/ - Third party codes from different vendors.

Although we have this structure, there is no limitation into where should you put your services/cmds. Any subdirectory structure is fine as long as a Makefile is provided.

How to add a service/cmd

A reference template named samplesvc is provided. Basically, these are the things that you need to do:

  • Create a new directory for your service under services/ or tool under cmd/. You may copy the samplesvc contents to your new directory.
  • Update the dockerfile inside your new service directory. Note that during build, this dockerfile is copied to the root directory (to be able to access pkg and vendor directories).
  • Update the Makefile with your own values. You need to at least update the MODULE variable with your service name. The only required rule is the custom part so you may need to change that as well (i.e. name of the dockerfile used in docker build).
  • [Optional] Update the deploy.sh script for your deployment needs.

Need help

PR's are welcome!

  • [x] Support for GitHub Actions
  • [ ] Support for GitLab
  • [ ] Run go test ... for pkg/ when Makefile is root
  • [ ] Make it work without the vendor folder as well

Misc

https://tech.mobingi.com/2018/09/25/ouchan-monorepo.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].