Skip to content

Commit

Permalink
refactor: migrate to new aperturerobotics/common pattern
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Stewart <christian@aperture.us>
  • Loading branch information
paralin committed Apr 23, 2024
1 parent 6cd0d45 commit fbe16f2
Show file tree
Hide file tree
Showing 29 changed files with 101 additions and 1,443 deletions.
6 changes: 0 additions & 6 deletions .github/renovate.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@
"workarounds:all"
],
"branchConcurrentLimit": 0,
"ignorePaths": ["hack", "examples/plugin-demo"],
"packageRules": [
{
"matchManagers": ["gomod"],
"matchDepTypes": ["replace"],
"enabled": false
},
{
"matchPackagePatterns": ["github.com/aperturerobotics/controllerbus"],
"matchManagers": ["gomod"],
"enabled": false
}
]
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ debug.test*
__debug*
.aider*
*.test
/.tools/
138 changes: 19 additions & 119 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,131 +1,31 @@
# https://github.com/aperturerobotics/template

PROJECT_DIR := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
SHELL:=bash
PROTOWRAP=hack/bin/protowrap
PROTOC_GEN_GO=hack/bin/protoc-gen-go-lite
PROTOC_GEN_STARPC=hack/bin/protoc-gen-go-starpc
GOIMPORTS=hack/bin/goimports
GOFUMPT=hack/bin/gofumpt
GOLANGCI_LINT=hack/bin/golangci-lint
GO_MOD_OUTDATED=hack/bin/go-mod-outdated
GOLIST=go list -f "{{ .Dir }}" -m
MAKEFLAGS += --no-print-directory

GO_VENDOR_DIR := ./vendor
COMMON_DIR := $(GO_VENDOR_DIR)/github.com/aperturerobotics/common
COMMON_MAKEFILE := $(COMMON_DIR)/Makefile

export GO111MODULE=on
undefine GOARCH
undefine GOOS

all:

vendor:
go mod vendor

$(PROTOC_GEN_GO):
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go-lite \
github.com/aperturerobotics/protobuf-go-lite/cmd/protoc-gen-go-lite

$(GOIMPORTS):
cd ./hack; \
go build -v \
-o ./bin/goimports \
golang.org/x/tools/cmd/goimports

$(GOFUMPT):
cd ./hack; \
go build -v \
-o ./bin/gofumpt \
mvdan.cc/gofumpt

$(PROTOWRAP):
cd ./hack; \
go build -v \
-o ./bin/protowrap \
github.com/aperturerobotics/goprotowrap/cmd/protowrap
.PHONY: $(MAKECMDGOALS)

$(GOLANGCI_LINT):
cd ./hack; \
go build -v \
-o ./bin/golangci-lint \
github.com/golangci/golangci-lint/cmd/golangci-lint

$(GO_MOD_OUTDATED):
cd ./hack; \
go build -v \
-o ./bin/go-mod-outdated \
github.com/psampaz/go-mod-outdated

$(PROTOC_GEN_STARPC):
cd ./hack; \
go build -v \
-o ./bin/protoc-gen-go-starpc \
github.com/aperturerobotics/starpc/cmd/protoc-gen-go-starpc

node_modules:
yarn install

.PHONY: genproto
genproto: vendor node_modules $(GOIMPORTS) $(PROTOWRAP) $(PROTOC_GEN_GO) $(PROTOC_GEN_STARPC)
shopt -s globstar; \
set -eo pipefail; \
export PROJECT=$$(go list -m); \
export PATH=$$(pwd)/hack/bin:$${PATH}; \
export OUT=$$(pwd)/vendor; \
mkdir -p $${OUT}/$$(dirname $${PROJECT}); \
rm $$(pwd)/vendor/$${PROJECT} || true; \
ln -s $$(pwd) $$(pwd)/vendor/$${PROJECT} ; \
protogen() { \
$(PROTOWRAP) \
-I $${OUT} \
--plugin=./node_modules/.bin/protoc-gen-es \
--plugin=./node_modules/.bin/protoc-gen-es-starpc \
--go-lite_out=$${OUT} \
--go-lite_opt=features=marshal+unmarshal+size+equal+json+clone+text \
--go-starpc_out=$${OUT} \
--es_out=$${OUT} \
--es_opt target=ts \
--es_opt ts_nocheck=false \
--es-starpc_out=$${OUT} \
--es-starpc_opt target=ts \
--es-starpc_opt ts_nocheck=false \
--proto_path $${OUT} \
--print_structure \
--only_specified_files \
$$(\
git \
ls-files "$$1" |\
xargs printf -- \
"$$(pwd)/vendor/$${PROJECT}/%s "); \
}; \
protogen "./*.proto"; \
rm $$(pwd)/vendor/$${PROJECT} || true
$(GOIMPORTS) -w ./
npm run format:js

.PHONY: gen
gen: genproto

.PHONY: outdated
outdated: $(GO_MOD_OUTDATED)
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED) -update -direct

.PHONY: list
list: $(GO_MOD_OUTDATED)
go list -mod=mod -u -m -json all | $(GO_MOD_OUTDATED)
all:

.PHONY: lint
lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
$(COMMON_MAKEFILE): vendor
@if [ ! -f $(COMMON_MAKEFILE) ]; then \
echo "Please add github.com/aperturerobotics/common to your go.mod."; \
exit 1; \
fi

.PHONY: fix
fix: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run --fix
$(MAKECMDGOALS): $(COMMON_MAKEFILE)
@$(MAKE) -C $(COMMON_DIR) PROJECT_DIR="$(PROJECT_DIR)" $@

.PHONY: test
test:
go test -v ./...
%: $(COMMON_MAKEFILE)
@$(MAKE) -C $(COMMON_DIR) PROJECT_DIR="$(PROJECT_DIR)" $@

.PHONY: format
format: $(GOFUMPT) $(GOIMPORTS)
$(GOIMPORTS) -w ./
$(GOFUMPT) -w ./
vendor:
go mod vendor
2 changes: 1 addition & 1 deletion bus/api/api_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/bus/api/api.proto (package bus.api, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion bus/api/api_srpc.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bus/api/controller/controller_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/bus/api/controller/controller.proto (package bus.api.controller, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion config/config_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/config/config.proto (package config, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion controller/configset/controller/config_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/controller/configset/controller/config.proto (package configset.controller, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion controller/configset/proto/configset_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/controller/configset/proto/configset.proto (package configset.proto, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion controller/controller_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/controller/controller.proto (package controller, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion controller/exec/exec_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/controller/exec/exec.proto (package controller.exec, syntax proto3)
/* eslint-disable */

Expand Down
9 changes: 9 additions & 0 deletions deps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//go:build deps_only
// +build deps_only

package controllerbus

import (
// _ imports common with the Makefile and tools
_ "github.com/aperturerobotics/common"
)
2 changes: 1 addition & 1 deletion directive/directive_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/directive/directive.proto (package directive, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion example/boilerplate/controller/config_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/example/boilerplate/controller/config.proto (package boilerplate.controller, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion example/boilerplate/v1/boilerplate_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/example/boilerplate/v1/boilerplate.proto (package boilerplate.v1, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion example/hello-world/controller_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/example/hello-world/controller.proto (package main, syntax proto3)
/* eslint-disable */

Expand Down
2 changes: 1 addition & 1 deletion example/plugin-demo/demo-controller/config_pb.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.8.0 with parameter "target=ts,ts_nocheck=false"
// @generated by protoc-gen-es v1.9.0 with parameter "target=ts,ts_nocheck=false"
// @generated from file github.com/aperturerobotics/controllerbus/example/plugin-demo/demo-controller/config.proto (package hot.compile.demo.controller, syntax proto3)
/* eslint-disable */

Expand Down
4 changes: 2 additions & 2 deletions example/plugin-demo/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ replace (

require (
github.com/aperturerobotics/controllerbus v0.30.9
github.com/aperturerobotics/protobuf-go-lite v0.4.5
github.com/aperturerobotics/protobuf-go-lite v0.5.0
github.com/blang/semver v3.5.1+incompatible
github.com/pkg/errors v0.9.1
github.com/sirupsen/logrus v1.9.3
Expand All @@ -22,7 +22,7 @@ require (
require (
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
github.com/aperturerobotics/starpc v0.31.2 // indirect
github.com/aperturerobotics/util v1.18.0 // indirect
github.com/aperturerobotics/util v1.19.0 // indirect
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect
Expand Down
8 changes: 4 additions & 4 deletions example/plugin-demo/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ github.com/aperturerobotics/logrus v1.9.4-0.20240119050608-13332fb58195 h1:uyeD1
github.com/aperturerobotics/logrus v1.9.4-0.20240119050608-13332fb58195/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
github.com/aperturerobotics/protobuf-go v1.33.1-0.20240411062030-e36f75e0a3b8 h1:Juij9Gj5jVOJjqiu3EGHWnX9nH6fkBeGGu/3U8i5qss=
github.com/aperturerobotics/protobuf-go v1.33.1-0.20240411062030-e36f75e0a3b8/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
github.com/aperturerobotics/protobuf-go-lite v0.4.5 h1:t7MyE0xB0spkQlN5Ei/wI8XmiOXVEFwkSm09DMPbpDg=
github.com/aperturerobotics/protobuf-go-lite v0.4.5/go.mod h1:wRZn4YydbTn8Bdx4NB6ms0doF19llgim+0SNBvQ7M9c=
github.com/aperturerobotics/protobuf-go-lite v0.5.0 h1:JmTfiOeTQv06EYIFyVkjkmGXxI7JoCRuokVK2SOvo3I=
github.com/aperturerobotics/protobuf-go-lite v0.5.0/go.mod h1:/EduuzDxtr5s0e9s10XYG35+pPgvrgg3UmBliivOaSs=
github.com/aperturerobotics/starpc v0.31.2 h1:9zRZbRpZ7TK3O/5ENz0rwShfLS5jkw0SkqIU2pbuvZk=
github.com/aperturerobotics/starpc v0.31.2/go.mod h1:Q5dAx56ZUhOlytE37LoMA2JhRAPFe68BcMDzHw7kwxs=
github.com/aperturerobotics/util v1.18.0 h1:ie2KAuVWGkSICxLrMoI2Dzth0HZSgvmb2CxtxsyGUaY=
github.com/aperturerobotics/util v1.18.0/go.mod h1:NdGzI+NyJvqEwt+RkKPxOlKl9zUSWJMgKicNci7ZFMU=
github.com/aperturerobotics/util v1.19.0 h1:eDGMk1rhE3pyKF0GC2XGhPCXTM3saQwKIWNq7PPn6Ng=
github.com/aperturerobotics/util v1.19.0/go.mod h1:qAQ/fIrnvLUe8RW3tKd96foP66BGbSSA0cBRApTMKXg=
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/cenkalti/backoff v2.2.1+incompatible h1:tNowT99t7UNflLxfYYSlKYsBpXdEet03Pg2g16Swow4=
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (

require (
github.com/Jeffail/gabs/v2 v2.7.0
github.com/aperturerobotics/common v0.12.0
github.com/blang/semver v3.5.1+incompatible
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/fsnotify/fsnotify v1.7.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg=
github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw=
github.com/aperturerobotics/common v0.12.0 h1:kN4w2P5BAR5ingpeYDvnGjrW70MmsljbzuF3J7k4JOM=
github.com/aperturerobotics/common v0.12.0/go.mod h1:XAF6181CsLce+cercpaPUo0fWps0V6X1RPo8zQBytJA=
github.com/aperturerobotics/protobuf-go-lite v0.5.0 h1:JmTfiOeTQv06EYIFyVkjkmGXxI7JoCRuokVK2SOvo3I=
github.com/aperturerobotics/protobuf-go-lite v0.5.0/go.mod h1:/EduuzDxtr5s0e9s10XYG35+pPgvrgg3UmBliivOaSs=
github.com/aperturerobotics/starpc v0.31.2 h1:9zRZbRpZ7TK3O/5ENz0rwShfLS5jkw0SkqIU2pbuvZk=
Expand Down
2 changes: 0 additions & 2 deletions hack/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions hack/Makefile

This file was deleted.

Loading

0 comments on commit fbe16f2

Please sign in to comment.