-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
177 changed files
with
1,170 additions
and
635 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
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,111 +1,5 @@ | ||
MODULE := $(shell go list -m) | ||
MODULE_NAME := $(lastword $(subst /, ,$(MODULE))) | ||
BUILD := $(shell git rev-parse --short HEAD)@$(shell date +%s) | ||
CURRENT_OS := $(shell uname | tr "[A-Z]" "[a-z]") | ||
CURRENT_ARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/') | ||
|
||
DOCKER_IMAGE ?= ghcr.io/tbxark/$(MODULE_NAME) | ||
DOCKER_FILE := cmd/app/Dockerfile | ||
|
||
LD_FLAGS := "-X $(MODULE)/internal/config.BuildVersion=$(BUILD)" | ||
GO_BUILD := CGO_ENABLED=0 go build -trimpath -ldflags $(LD_FLAGS) -tags=jsoniter | ||
|
||
.PHONY: init | ||
init: ## Init all dependencies | ||
go mod download | ||
go get entgo.io/ent/cmd/ent@latest | ||
go get github.com/google/wire/cmd/wire@latest | ||
go install github.com/swaggo/swag/cmd/swag@latest | ||
go install github.com/bufbuild/buf/cmd/buf@latest | ||
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest | ||
go install github.com/favadi/protoc-go-inject-tag@latest | ||
$(MAKE) install | ||
$(MAKE) gen-ent | ||
$(MAKE) gen-docs | ||
$(MAKE) gen-wire | ||
buf dep update | ||
go mod tidy | ||
|
||
.PHONY: install | ||
install: ## Install all dependencies | ||
# cd contrib/protoc-gen-sphere && go mod download && go install . | ||
# cd contrib/protoc-gen-route && go mod download && go install . | ||
# cd contrib/ent-gen-proto && go mod download && go install . | ||
go install github.com/TBXark/sphere/contrib/protoc-gen-sphere@latest | ||
go install github.com/TBXark/sphere/contrib/protoc-gen-route@latest | ||
go install github.com/TBXark/sphere/contrib/ent-gen-proto@latest | ||
|
||
.PHONY: gen-proto | ||
gen-proto: ## Generate proto files and run protoc plugins | ||
ent-gen-proto -path=./internal/pkg/database/schema | ||
buf generate | ||
protoc-go-inject-tag -input="./api/*/*/*.pb.go" -remove_tag_comment | ||
|
||
.PHONY: gen-ent | ||
gen-ent: ## Generate ent code | ||
go generate ./internal/pkg/database/generate.go | ||
|
||
.PHONY: gen-docs | ||
gen-docs: gen-proto ## Generate swagger docs | ||
go generate docs.go | ||
|
||
.PHONY: gen-wire | ||
gen-wire: ## Generate wire code | ||
go generate ./cmd/... | ||
|
||
.PHONY: gen-conf | ||
gen-conf: ## Generate example config | ||
go run ./cmd/cli/config gen | ||
|
||
.PHONY: generate | ||
generate: ## Run all generate command | ||
go generate ./... | ||
|
||
.PHONY: dash | ||
dash: ## Build dash | ||
sh ./assets/dash/build.sh | ||
|
||
.PHONY: build | ||
build: ## Build binary | ||
$(GO_BUILD) -o ./build/$(CURRENT_OS)_$(CURRENT_ARCH)/ ./... | ||
|
||
.PHONY: build-linux-amd64 | ||
build-linux-amd64: ## Build linux amd64 binary | ||
GOOS=linux GOARCH=amd64 $(GO_BUILD) -o ./build/linux_amd64/ ./... | ||
|
||
.PHONY: build-linux-arm64 | ||
build-linux-arm64: ## Build linux arm64 binary | ||
GOOS=linux GOARCH=arm64 $(GO_BUILD) -o ./build/linux_arm64/ ./... | ||
|
||
.PHONY: build-all | ||
build-all: build-linux-amd64 build-linux-arm64 ## Build all arch binary | ||
|
||
.PHONY: build-docker | ||
build-docker: ## Build docker image | ||
docker buildx build --platform=linux/amd64,linux/arm64 -t $(DOCKER_IMAGE) . -f $(DOCKER_FILE) --push --provenance=false | ||
|
||
.PHONY: delpoy | ||
deploy: ## Deploy binary | ||
ansible-playbook -i devops/hosts/inventory.ini devops/delpoy-binary.yaml | ||
|
||
.PHONY: lint | ||
lint: ## Run linter | ||
golangci-lint run | ||
buf lint | ||
|
||
.PHONY: fmt | ||
fmt: ## Run formatter | ||
go fmt ./... | ||
buf format | ||
|
||
.PHONY: clean | ||
clean: ## Clean build files | ||
rm -rf ./build | ||
rm -rf ./swagger | ||
rm -rf ./api | ||
rm -rf ./internal/pkg/database/ent | ||
|
||
.PHONY: help | ||
help: ## Show this help message | ||
@echo "\n\033[1mSphere build tool.\033[0m Usage: make [target]\n" | ||
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\(.*\):.*##\(.*\)/\1:\2/' | column -t -s ':' | sed -e 's/^/ /' | ||
cd contrib/protoc-gen-sphere && go mod download && go install . | ||
cd contrib/protoc-gen-route && go mod download && go install . | ||
cd contrib/ent-gen-proto && go mod download && go install . |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
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,4 +1,4 @@ | ||
.idea | ||
../.idea | ||
.vscode | ||
build | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland,go | ||
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,goland,go | ||
|
||
### Go ### | ||
# If you prefer the allow list template instead of the deny list, see community template: | ||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore | ||
# | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, built with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Go workspace file | ||
go.work | ||
|
||
### GoLand ### | ||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider | ||
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 | ||
|
||
# User-specific stuff | ||
.idea/**/workspace.xml | ||
.idea/**/tasks.xml | ||
.idea/**/usage.statistics.xml | ||
.idea/**/dictionaries | ||
.idea/**/shelf | ||
|
||
# AWS User-specific | ||
.idea/**/aws.xml | ||
|
||
# Generated files | ||
.idea/**/contentModel.xml | ||
|
||
# Sensitive or high-churn files | ||
.idea/**/dataSources/ | ||
.idea/**/dataSources.ids | ||
.idea/**/dataSources.local.xml | ||
.idea/**/sqlDataSources.xml | ||
.idea/**/dynamic.xml | ||
.idea/**/uiDesigner.xml | ||
.idea/**/dbnavigator.xml | ||
|
||
# Gradle | ||
.idea/**/gradle.xml | ||
.idea/**/libraries | ||
|
||
# Gradle and Maven with auto-import | ||
# When using Gradle or Maven with auto-import, you should exclude module files, | ||
# since they will be recreated, and may cause churn. Uncomment if using | ||
# auto-import. | ||
# .idea/artifacts | ||
# .idea/compiler.xml | ||
# .idea/jarRepositories.xml | ||
# .idea/modules.xml | ||
# .idea/*.iml | ||
# .idea/modules | ||
# *.iml | ||
# *.ipr | ||
|
||
# CMake | ||
cmake-build-*/ | ||
|
||
# Mongo Explorer plugin | ||
.idea/**/mongoSettings.xml | ||
|
||
# File-based project format | ||
*.iws | ||
|
||
# IntelliJ | ||
out/ | ||
|
||
# mpeltonen/sbt-idea plugin | ||
.idea_modules/ | ||
|
||
# JIRA plugin | ||
atlassian-ide-plugin.xml | ||
|
||
# Cursive Clojure plugin | ||
.idea/replstate.xml | ||
|
||
# SonarLint plugin | ||
.idea/sonarlint/ | ||
|
||
# Crashlytics plugin (for Android Studio and IntelliJ) | ||
com_crashlytics_export_strings.xml | ||
crashlytics.properties | ||
crashlytics-build.properties | ||
fabric.properties | ||
|
||
# Editor-based Rest Client | ||
.idea/httpRequests | ||
|
||
# Android studio 3.1+ serialized cache file | ||
.idea/caches/build_file_checksums.ser | ||
|
||
### GoLand Patch ### | ||
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 | ||
|
||
# *.iml | ||
# modules.xml | ||
# .idea/misc.xml | ||
# *.ipr | ||
|
||
# Sonarlint plugin | ||
# https://plugins.jetbrains.com/plugin/7973-sonarlint | ||
.idea/**/sonarlint/ | ||
|
||
# SonarQube Plugin | ||
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin | ||
.idea/**/sonarIssues.xml | ||
|
||
# Markdown Navigator plugin | ||
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced | ||
.idea/**/markdown-navigator.xml | ||
.idea/**/markdown-navigator-enh.xml | ||
.idea/**/markdown-navigator/ | ||
|
||
# Cache file creation bug | ||
# See https://youtrack.jetbrains.com/issue/JBR-2257 | ||
.idea/$CACHE_FILE$ | ||
|
||
# CodeStream plugin | ||
# https://plugins.jetbrains.com/plugin/12206-codestream | ||
.idea/codestream.xml | ||
|
||
# Azure Toolkit for IntelliJ plugin | ||
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij | ||
.idea/**/azureSettings.xml | ||
|
||
### VisualStudioCode ### | ||
.vscode/* | ||
!.vscode/settings.json | ||
!.vscode/tasks.json | ||
!.vscode/launch.json | ||
!.vscode/extensions.json | ||
!.vscode/*.code-snippets | ||
|
||
# Local History for Visual Studio Code | ||
.history/ | ||
|
||
# Built Visual Studio Code Extensions | ||
*.vsix | ||
|
||
### VisualStudioCode Patch ### | ||
# Ignore all local history of files | ||
.history | ||
.ionide | ||
|
||
# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,goland,go | ||
|
||
/swagger | ||
/build | ||
/var | ||
/api | ||
/config.json |
File renamed without changes.
Oops, something went wrong.