All Projects → bufbuild → makego

bufbuild / makego

Licence: Apache-2.0 license
Makefile setup for our Golang projects.

Programming Languages

Makefile
30231 projects
go
31211 projects - #10 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to makego

Buf
A new way of working with Protocol Buffers.
Stars: ✭ 3,328 (+5020%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protobuf Swift
Google ProtocolBuffers for Apple Swift
Stars: ✭ 925 (+1323.08%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protolock
Protocol Buffer companion tool. Track your .proto files and prevent changes to messages and services which impact API compatibility.
Stars: ✭ 394 (+506.15%)
Mutual labels:  protobuf, protocol-buffers, protoc
protobuf-d
Protocol Buffers Compiler Plugin and Support Library for D
Stars: ✭ 32 (-50.77%)
Mutual labels:  protobuf, protocol-buffers, protoc
Pb And K
Kotlin Code Generator and Runtime for Protocol Buffers
Stars: ✭ 137 (+110.77%)
Mutual labels:  protobuf, protocol-buffers, protoc
protopatch
protoc-gen-go patch utility
Stars: ✭ 58 (-10.77%)
Mutual labels:  protobuf, protocol-buffers, protoc
Prototool
Your Swiss Army Knife for Protocol Buffers
Stars: ✭ 4,932 (+7487.69%)
Mutual labels:  protobuf, protocol-buffers, protoc
protocell
Conjures up convenient OCaml types and serialization functions based on protobuf definition files
Stars: ✭ 18 (-72.31%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protodot
transforming your .proto files into .dot files (and .svg, .png if you happen to have graphviz installed)
Stars: ✭ 107 (+64.62%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protobuf
Protocol Buffers - Google's data interchange format
Stars: ✭ 52,305 (+80369.23%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protobuf
A pure Elixir implementation of Google Protobuf
Stars: ✭ 442 (+580%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protobuf Dynamic
Protocol Buffers Dynamic Schema - create protobuf schemas programmatically
Stars: ✭ 186 (+186.15%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protoc Jar
Protocol Buffers protobuf compiler - multi-platform executable protoc JAR and API
Stars: ✭ 103 (+58.46%)
Mutual labels:  protobuf, protocol-buffers, protoc
Protoc Jar Maven Plugin
Protocol Buffers protobuf maven plugin - based on protoc-jar multi-platform executable protoc JAR
Stars: ✭ 177 (+172.31%)
Mutual labels:  protobuf, protocol-buffers, protoc
Rules protobuf
Bazel rules for building protocol buffers and gRPC services (java, c++, go, ...)
Stars: ✭ 206 (+216.92%)
Mutual labels:  protobuf, protocol-buffers, protoc
rules proto grpc
Bazel rules for building Protobuf and gRPC code and libraries from proto_library targets
Stars: ✭ 201 (+209.23%)
Mutual labels:  protobuf, protocol-buffers
protokit
A starter kit for building protoc plugins. Rather than write your own, you can just use an existing one.
Stars: ✭ 69 (+6.15%)
Mutual labels:  protobuf, protoc
j2cl-protobuf
Protocol Buffers implementation for J2CL
Stars: ✭ 23 (-64.62%)
Mutual labels:  protobuf, protocol-buffers
stockholm
💵 Modern Python library for working with money and monetary amounts. Human friendly and flexible approach for development. 100% test coverage + built-in support for GraphQL and Protocol Buffers transports using current best-practices.
Stars: ✭ 26 (-60%)
Mutual labels:  protobuf, protocol-buffers
Protoman
Postman for protobuf APIs
Stars: ✭ 241 (+270.77%)
Mutual labels:  protobuf, protocol-buffers

Makego

License Release CI

Makego is our Makefile setup for our Golang projects. This repository also functions as a template repository for our Golang projects that use makego.

Makego supports our development workflow, which includes Golang, Docker, and Protobuf primarily. All projects should result in make working out of the box, as long as the system has Golang >=1.13 installed, and Docker installed if Docker is used. All other dependences (except for a few that we need to document that most systems will have, such as bash, curl, and git) are installed by makego automatically and cached on a per-project basis, including all Golang module downloads.

Makego allows updating from this main (or your forked main) automatically, only copying the files you need.

Notice

Makego is primarily OSS as we use it in our OSS projects. Makego will likely have many breaking changes, and we do not provide support for it in any form. You're obviously welcome to fork it and/or use components of it, however - the MAKEGO_REMOTE variable controls the remote location for make copyfrommakego.

If you do use this, you should get familiar with the actual Makefiles contained in this project.

Status

Very alpha. This will change a bunch. The documentation is incomplete as well.

Example

Buf uses this, and should be treated as the gold-standard example for makego usage.

Layout

The following are controlled by makego, and should not be edited directly:

  • make/go - This is the "actual" makego library. This contains the Makefiles and scripts that compromise makego's functionality.
  • .dockerignore - The autogenerated Docker ignore file. If you do not include make/go/docker.mk, you should delete this file for your new Golang project.
  • .gitignore The autogenerated git ignore file.
  • go.mod, go.sum - The Golang module files. These are autogenerated.

Additionally, makego expects the following if Docker is used:

Otherwise, you're free to choose your own layout, however you should generally do the following:

  • Have a file make/PROJECT/all.mk such as make/foo/all.mk that defines the setup for your project. This should be the only file included in your Makefile.
  • Put your main packages in cmd. For example, for a binary named foo, you should have cmd/foo, and add cmd/foo to GO_BINS such as in make/foo/all.mk.
  • If using Docker, put a Dockerfile per main package as Dockerfile.foo. Then add foo to DOCKER_BINS such as in make/foo/all.mk.
  • Put generated files in any subdirectory named gen. Makego treats gen directories as special, primarily by not linting them or using them for code coverage.

Other files of relevance:

  • .github - This is for GitHub Actions primarily, there is an example action at .github/workflows/ci.yaml.
  • .envrc - This is for direnv, which makego supports. This generally should not be edited, however.
  • LICENSE - Our license. Replace with your own license.
  • Makefile - The main Makefile. See below for setup.
  • README.md - This readme.
  • .env - This directory contains your individual environment, if you want. You can back this up to with make envbackup and restore with make envrestore. The special file .env/env.sh will be included with make direnv, which direnv calls via .envrc.
  • .tmp - This directory is used for temporary files such as coverage files and makego temporary clones.

New Project Setup

Assuming your actual remote is github.com/eng/hello:

git clone https://github.com/bufbuild/makego hello
cd ./hello
rm -rf .git
git init
git remote add origin https://github.com/eng/hello

Move make/foo to make/PROJECT:

mv make/foo make/hello

Then edit the Makefile:

# You can put make/go somewhere else if you want but we would not recommend it, however it
# should work as all Makefile in make/go use this variable to know where things are
MAKEGO := make/go
# Change to your fork. Do not use ours.
MAKEGO_REMOTE := https://github.com/eng/makego.git
# Your project name
PROJECT := hello
# The Golang module
GO_MODULE := github.com/eng/makego
# The Docker organization. Optimally this is your Docker Hub organization, but makego
# does not currently interact with Docker Hub.
DOCKER_ORG := eng
# The Docker project name, generally the same as PROJECT. The Docker image
# $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.
DOCKER_PROJECT := hello

# This changes from make/foo/all.mk to make/hello/all.mk
include make/hello/all.mk

Update everything and make sure everything builds:

# This also calls make generate and make all
make upgrade

Figure out the specific files you want (see "Basic Concepts" below), and only include those files in make/hello/all.mk. When you're sure you are done, run make updatemakego to delete unnecessary files.

# CONFIRM=1 is just for protection
# If you later want to restore all the files, you can do so by adding ALL=1 to this command
make updatemakego CONFIRM=1

Then, delete everything in this readme except potentially the badge links at the top (but if you keep the badge links, update them for your repository). Also update the LICENSE for your use.

Basic concepts

All projects should have a make/PROJECT/all.mk file that defines your actual setup. This includes files from make/go that you need, as well as any custom build commands See make/buf/all.mk for a real-world example.

This file should all or some of these files, depending on what you need:

  • make/go/bootstrap.mk - This always needs to be the first file included. This defines functions that the rest of the files use.
  • make/go/go.mk - This defines Golang functionality. All projects should generally include this.
  • make/go/docker.mk - This defines Docker functionality. Only include if you want to use Docker. If you do not use Docker, you can delete the .dockerignore file and any Dockerfiles.

All other files are automatically included.

Development commands

We are not documenting all development commands, however some important ones of note:

  • make all - This is the default goal, and runs linting and testing.
  • make ci - This is the goal for CI, and downloads deps, and runs linting, testing, and code coverage. Note that deps are downloaded automatically on a per-target basis, so the intial dep download really shouldn't be needed.
  • make generate - Do all generation.
  • make lint - Do all linting.
  • make build - Go build.
  • make test - Go test.
  • make cover - Go code coverage.
  • make install - Install all Go binaries defined by GO_BINS.
  • make dockermakeworkspace - This will run make all by default inside the Docker container defined by Docker.workspace. You can edit the Makefile target with DOCKERMAKETARGET.
  • make dockerbuild - Build all Docker images defined by DOCKER_BINS.
  • make updatemakego - Update from makego main.

Variables

Makego is controlled by various environment variables. This list may get out of date, however as of this writing, this is what is required, settable, and settable at runtime.

Required

These variables should be defined in your Makefile and are required.

  • MAKEGO - The location of the make/go directory. Generally you should have this as make/go, however we did make it settable so you can put the files somewhere else.
  • MAKEGO_REMOTE - The remote location for makego. You should point this at your fork. The make target make copyfrommakego will copy makego to your current files.
  • PROJECT - Your project name. This is used for many things such as your config and cache locations.
  • GO_MODULE - Your Golang module name.

If you use Docker, the following are also required.

  • DOCKER_ORG - The Docker organization. Optimally this is your Docker Hub organization, but makego does not currently interact with Docker Hub.
  • DOCKER_PROJECT - The Docker project name, generally the same as PROJECT. The Docker image $(DOCKER_ORG)/$(DOCKER_PROJECT)-workspace will be created.

Settable

These variables are settable in your Makefiles, but should be static, i.e. these are for project-specific settings and not intended to be set on the command line.

  • FILE_IGNORES - The relative paths to files to add to .dockerignore and .gitignore. By default, makego will add .env, .tmp. and any Golang binaries. Note if you set this, you should do so by including the current value ie FILE_IGNORES := $(FILE_IGNORES) .build/.
  • CACHE_BASE - By default, makego caches to ~/.cache/$(PROJECT). Set this to change that.
  • GO_BINS - The relative paths to your Golang main packages, For example cmd/foo. Note if you set this, you should do so by including the current value ie GO_BINS := $(GO_BINS) cmd/bar.
  • GO_GET_PKGS - Extra packages to get when running make upgrade. For example, make/buf/all.mk adds master for github.com/jhump/protoreflect. Note if you set this, you should do so by including the current value ie GO_GET_PKGS := $(GO_GET_PKGS) github.com/foo/[email protected].
  • GO_LINT_IGNORES - Extra grep ignores for linting. Note if you set this, you should do so by including the current value ie GO_LINT_IGNORES := $(GO_LINT_IGNORES) \/foobar\/.
  • DOCKER_BINS - This sets any Dockerfiles that are to be built. There should be a matching Dockerfile.binaryname for each value. Note if you set this, you should do so by including the current value ie DOCKER_BINS := $(DOCKER_BINS) bar.
  • .*_VERSION - This sets the version for dependencies, such as ERRCHECK_VERSION := e14f8d59a22d460d56c5ee92507cd94c78fbf274. We update these once in a while, but you can set your own as well to make sure your own builds are deterministic. See the dep_.* files for the individual variables.

Runtime

These variables are meant to be set when invoking make targets on the command line.

  • CONFIRM - This is required to be set when running make updatemakego. This is to protect against updating when not intended.
  • ALL - This results in all makego files being downloaded when running make updatemakego instead of just the ones that you current have included.
  • DOCKERMAKETARGET - This changes the recursive make target for make dockermakeworkspace from all to this value.
  • GOPKGS - This controls what packages to build for Go commands. By default, this is ./.... If you only wanted to test ./internal/foo/... for example, you could run make test GOPKGS=./internal/foo/...
  • COVEROPEN - This will result in the cover.html file being automatically opened after make cover is run, for example `make cover COVEROPEN=1.
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].