-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build: improve makefile commands * build: fix build workflow * build: run test with dynamnic tag * build: run test with dynamnic tag * build: run test with dynamnic tag * wip: disable int test * feat: commit proto code * feat: test with vendor * feat: run without dyanmic * test: chekc integration test * test: chekc integration test * test: skip integration test on main
- Loading branch information
Showing
9 changed files
with
746 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Raccoon Test & Build | ||
name: Test | ||
|
||
on: | ||
- push | ||
|
@@ -7,32 +7,29 @@ on: | |
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.14' | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
go-version: "1.14" | ||
- name: Checkout repo | ||
uses: actions/checkout@v2 | ||
- name: Setup Project | ||
run: make install-protoc; make setup | ||
with: | ||
fetch-depth: 0 | ||
- name: Invoking go test | ||
run: make test | ||
- name: Invoking go bench test | ||
run: make test-bench | ||
|
||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Setup Go | ||
uses: actions/[email protected] | ||
with: | ||
go-version: '1.14' | ||
go-version: "1.14" | ||
- name: Install Protoc | ||
uses: arduino/setup-protoc@v1 | ||
- uses: actions/checkout@v2 | ||
- name: Build | ||
run: make all | ||
run: make build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,8 +13,5 @@ coverage | |
.vscode | ||
*.env | ||
*.idea/ | ||
clickstream-service | ||
raccoon | ||
pkg/proto/*.pb.go | ||
proto/*.pb.go | ||
.temp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,86 +1,61 @@ | ||
.PHONY: all | ||
|
||
ALL_PACKAGES=$(shell go list ./... | grep -v "vendor") | ||
APP_EXECUTABLE="out/raccoon" | ||
COVER_FILE="/tmp/coverage.out" | ||
|
||
all: install-protoc setup compile | ||
|
||
# Setups | ||
setup: generate-proto copy-config | ||
make update-deps | ||
|
||
install-protoc: | ||
@echo "> installing dependencies" | ||
go get -u github.com/golang/protobuf/[email protected] | ||
go get -u github.com/golang/protobuf/[email protected] | ||
go get -u google.golang.org/grpc/cmd/[email protected] | ||
|
||
update-deps: | ||
go mod tidy -v | ||
go mod vendor | ||
|
||
copy-config: | ||
cp .env.sample .env | ||
|
||
PROTO_PACKAGE=/proto | ||
generate-proto: | ||
rm -rf .temp | ||
mkdir -p .temp | ||
curl -o .temp/proton.tar.gz -L http://api.github.com/repos/raystack/proton/tarball/main; tar xvf .temp/proton.tar.gz -C .temp/ --strip-components 1 | ||
protoc --proto_path=.temp/ .temp/raystack/raccoon/v1beta1/raccoon.proto --go_out=./ --go_opt=paths=import --go_opt=Mraystack/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE) | ||
protoc --proto_path=.temp/ .temp/raystack/raccoon/v1beta1/raccoon.proto --go-grpc_opt=paths=import --go-grpc_opt=Mraystack/raccoon/v1beta1/raccoon.proto=$(PROTO_PACKAGE) --go-grpc_out=./ | ||
|
||
# Build Lifecycle | ||
compile: | ||
mkdir -p out/ | ||
go build -o $(APP_EXECUTABLE) | ||
|
||
build: copy-config update-deps compile | ||
NAME="github.com/raystack/raccoon" | ||
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 := "ccbf219312db35a934361ebad895cb40145ca235" | ||
|
||
.PHONY: all build clean test tidy vet proto setup format generate | ||
|
||
all: clean test build format lint | ||
|
||
tidy: | ||
@echo "Tidy up go.mod..." | ||
@go mod tidy -v | ||
|
||
lint: ## Lint checker | ||
@echo "Running lint checks using golangci-lint..." | ||
@golangci-lint run | ||
|
||
clean: tidy ## Clean the build artifacts | ||
@echo "Cleaning up build directories..." | ||
@rm -rf $coverage.out ${BUILD_DIR} | ||
|
||
proto: ## Generate the protobuf files | ||
@echo "Generating protobuf from raystack/proton" | ||
@echo " [info] make sure correct version of dependencies are installed using 'make install'" | ||
@buf generate https://github.com/raystack/proton/archive/${PROTON_COMMIT}.zip#strip_components=1 --template buf.gen.yaml --path raystack/raccoon -v | ||
@cp -R proto/raystack/raccoon/v1beta1/* proto/ && rm -Rf proto/raystack | ||
@echo "Protobuf compilation finished" | ||
|
||
setup: ## Install required dependencies | ||
@echo "> Installing dependencies..." | ||
go mod tidy | ||
go install github.com/bufbuild/buf/cmd/[email protected] | ||
|
||
config: ## Generate the sample config file | ||
@echo "Initializing sample server config..." | ||
@cp .env.sample .env | ||
|
||
build: ## Build the raccoon binary | ||
@echo "Building racccoon version ${VERSION}..." | ||
go build | ||
@echo "Build complete" | ||
|
||
install: | ||
go install $(ALL_PACKAGES) | ||
|
||
start: build | ||
./$(APP_EXECUTABLE) | ||
@echo "Installing Guardian to ${GOBIN}..." | ||
@go install | ||
|
||
clean: ## Clean the builds | ||
rm -rf out/ | ||
|
||
# Utility | ||
|
||
fmt: | ||
go fmt $(ALL_PACKAGES) | ||
|
||
vet: | ||
go vet $(ALL_PACKAGES) | ||
|
||
lint: | ||
@for p in $(ALL_PACKAGES); do \ | ||
echo "==> Linting $$p"; \ | ||
golint $$p | { grep -vwE "exported (var|function|method|type|const) \S+ should have comment" || true; } \ | ||
done | ||
|
||
# Tests | ||
|
||
test: lint | ||
ENVIRONMENT=test go test $(shell go list ./... | grep -v "vendor" | grep -v "integration") -v | ||
@go list ./... | grep -v "vendor" | grep -v "integration" | xargs go test -count 1 -cover -short -race -timeout 1m -coverprofile ${COVER_FILE} | ||
@go tool cover -func ${COVER_FILE} | tail -1 | xargs echo test coverage: | ||
test: ## Run the tests | ||
go test $(shell go list ./... | grep -v "vendor" | grep -v "integration") -v | ||
|
||
test-bench: # run benchmark tests | ||
@go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark | ||
|
||
test_ci: install-protoc setup test | ||
@go test $(shell go list ./... | grep -v "vendor") -v -bench ./... -run=^Benchmark ] | ||
|
||
# Docker Run | ||
vendor: ## Update the vendor directory | ||
@echo "Updating vendor directory..." | ||
@go mod vendor | ||
|
||
docker-run: | ||
docker-compose build | ||
docker-compose up -d | ||
|
||
docker-stop: | ||
docker-compose stop | ||
|
||
docker-start: | ||
docker-compose start | ||
docker-compose up -d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: v1 | ||
plugins: | ||
- plugin: buf.build/protocolbuffers/go:v1.31.0 | ||
out: proto | ||
opt: paths=source_relative | ||
- plugin: buf.build/grpc/go:v1.3.0 | ||
out: proto | ||
opt: paths=source_relative,require_unimplemented_servers=true |
Oops, something went wrong.