Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ linters:
- (io.Closer).Close
- (*database/sql.Conn).Close
- (*github.com/jmoiron/sqlx.Conn).Close
- (*google.golang.org/grpc.ClientConn).Close
- (github.com/ory/dockertest/v3.Resource).Close
exclusions:
rules:
Expand Down
71 changes: 23 additions & 48 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,87 +3,62 @@ COMMIT := $(shell git rev-parse --short HEAD)
TAG := "$(shell git rev-list --tags --max-count=1)"
VERSION := "$(shell git describe --tags ${TAG})-next"
BUILD_DIR=dist
PROTON_COMMIT := "409f146"
PROTON_COMMIT := "b9ed2ad"

.PHONY: all build clean test tidy vet proto setup format generate lint install

all: clean test build format lint

tidy:
@echo "Tidy up go.mod..."
tidy: ## Tidy go.mod
@go mod tidy -v

install:
@echo "Installing compass to ${GOBIN}..."
install: ## Install compass binary
@go install

format:
@echo "Running go fmt..."
format: ## Format Go source files
@go fmt ./...

lint: ## Lint checker
@echo "Running lint checks using golangci-lint..."
lint: ## Run lint checks
@golangci-lint run

clean: ## Clean the build artifacts
@echo "Cleaning up build directories..."
clean: ## Clean build artifacts
@rm -rf coverage.out ${BUILD_DIR}

test: ## Run the tests
go test ./... -race -coverprofile=coverage.out
test: ## Run tests with coverage
@go test ./... -race -coverprofile=coverage.out

e2e: ## Run all e2e tests
go test ./test/... --tags=e2e
e2e: ## Run e2e tests
@go test ./test/... --tags=e2e

coverage: test ## Print the code coverage
@echo "Generating coverage report..."
coverage: test ## Generate coverage report
@go tool cover -html=coverage.out

build: ## Build the compass binary
@echo "Building compass version ${VERSION}..."
CGO_ENABLED=0 go build -ldflags "-X ${NAME}/cli.Version=${VERSION}"
@echo "Build complete"
@CGO_ENABLED=0 go build -ldflags "-X ${NAME}/cli.Version=${VERSION}"

buildr: setup ## Build release snapshot
goreleaser release --snapshot --skip=publish --clean
@goreleaser release --snapshot --skip=publish --clean

vet: ## Run go vet
go vet ./...
@go vet ./...

download: ## Download go modules
@go mod download

generate: ## Run all go generate in the code base
@echo "Running go generate..."
go generate ./...
generate: ## Run go generate
@go generate ./...

config: ## Generate the sample config file
@echo "Initializing sample server config..."
config: ## Generate sample config file
@cp config/config.yaml config.yaml

proto: ## Generate the protobuf files
@echo "Generating protobuf from raystack/proton"
@echo " [info] make sure correct version of dependencies are installed using 'make setup'"
proto: ## Generate protobuf files
@rm -rf proto/
@buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path raystack/compass -v
@echo "Protobuf compilation finished"

setup: ## Install required dependencies
@echo "> Installing dependencies..."
go mod tidy
go install github.com/vektra/mockery/v2@latest
go install github.com/bufbuild/buf/cmd/buf@latest

swagger-md:
npx swagger-markdown -i proto/compass.swagger.yaml -o docs/docs/reference/api.md

clean-doc:
@echo "> cleaning up auto-generated docs"
@rm -rf ./docs/docs/reference/cli.md
@rm -f ./docs/docs/reference/api.md

doc: clean-doc swagger-md ## Generate api and cli references
@echo "> generate cli docs"
@go run . reference --plain | sed '1 s,.*,# CLI,' > ./docs/docs/reference/cli.md
@go mod tidy
@go install github.com/vektra/mockery/v2@latest
@go install github.com/bufbuild/buf/cmd/buf@latest

help: ## Display this help message
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
@cat $(MAKEFILE_LIST) | grep -e "^[a-zA-Z_\-]*: *.*## *" | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ alias compass="docker run -e HOME=/tmp -v $HOME/.config/raystack:/tmp/.config/ra

## Usage

Compass is purely API-driven. It is very easy to get started with Compass. It provides CLI, HTTP and GRPC APIs for simpler developer experience.
Compass is purely API-driven. It is very easy to get started with Compass. It provides CLI and HTTP APIs for simpler developer experience.

#### CLI

Expand All @@ -115,7 +115,7 @@ compass reference

#### API

Compass provides a fully-featured GRPC and HTTP API to interact with Compass server. Both APIs adheres to a set of standards that are rigidly followed. Please refer to [proton](https://github.com/raystack/proton/tree/main/raystack/compass/v1beta1) for GRPC API definitions.
Compass provides a fully-featured HTTP API to interact with Compass server. The API is built with [Connect RPC](https://connectrpc.com/) and supports both Connect and gRPC protocols. Please refer to [proton](https://github.com/raystack/proton/tree/main/raystack/compass/v1beta1) for API definitions.

## Contribute

Expand Down
35 changes: 13 additions & 22 deletions buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
version: v1
version: v2
managed:
enabled: true
override:
- file_option: go_package
path: raystack/compass/v1beta1/service.proto
value: github.com/raystack/compass/proto/compassv1beta1
plugins:
- plugin: buf.build/protocolbuffers/go:v1.31.0
- remote: buf.build/protocolbuffers/go:v1.31.0
out: proto
opt: paths=source_relative
- plugin: buf.build/grpc/go:v1.3.0
opt: module=github.com/raystack/compass/proto
- remote: buf.build/bufbuild/validate-go:v1.0.2
out: proto
opt: paths=source_relative,require_unimplemented_servers=true
- plugin: buf.build/grpc-ecosystem/gateway:v2.16.0
opt: module=github.com/raystack/compass/proto
- remote: buf.build/connectrpc/go:v1.18.1
out: proto
opt:
- paths=source_relative
- allow_repeated_fields_in_body=true
- plugin: buf.build/bufbuild/validate-go:v1.0.2
out: proto
opt:
- paths=source_relative
- plugin: buf.build/grpc-ecosystem/openapiv2:v2.16.0
out: proto
opt:
- allow_repeated_fields_in_body=true
- output_format=yaml
- allow_merge=true
- merge_file_name=compass
- openapi_naming_strategy=simple
- json_names_for_fields=false
opt: module=github.com/raystack/compass/proto
Loading
Loading