Skip to content

Commit

Permalink
feat: reorg (#633)
Browse files Browse the repository at this point in the history
* feat: run server programmatically
* feat: reorg

Signed-off-by: James Yin <ywhjames@hotmail.com>
Signed-off-by: James Yean <ywhjames@hotmail.com>
  • Loading branch information
ifplusor authored Oct 7, 2023
1 parent d03f5ed commit c9aff3e
Show file tree
Hide file tree
Showing 866 changed files with 6,989 additions and 9,802 deletions.
4 changes: 2 additions & 2 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ header:
copyright-owner: Linkall Inc.

paths-ignore:
- 'proto/include'
- 'raft/'
- 'pkg/raft/'
- 'build/'
- '.github/'
- 'assets/'
- 'docs/'
- 'config/'
- '.gitignore'
Expand Down
16 changes: 12 additions & 4 deletions .github/workflows/codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
startsWith(github.event.pull_request.title, 'perf') ||
startsWith(github.event.pull_request.title, 'test')
runs-on: ${{ matrix.os }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
steps:
- uses: actions/setup-go@v3
with:
Expand All @@ -36,10 +34,20 @@ jobs:
- name: Generate coverage report
timeout-minutes: 5
run: |
go test -failfast -race -coverprofile=coverage.txt -covermode=atomic -timeout 300s ./internal/...
- uses: codecov/codecov-action@v2
for pkg in lib api pkg client server; do
for d in $(go list ./$pkg/... | grep -v /pkg/raft); do
go test -failfast -race -coverprofile=profile.out -covermode=atomic -timeout 300s $d
if [ -f profile.out ]; then
cat profile.out >> coverage.txt
rm profile.out
fi
done
done
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.txt # optional
flags: unittests # optional
name: codecov-umbrella # optional
fail_ci_if_error: true # optional (default = false)
verbose: true # optional (default = false)
3 changes: 2 additions & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ jobs:
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: v1.52

# Optional: working directory, useful for monorepos
working-directory: internal
# working-directory: interval

# Optional: golangci-lint command line arguments.
args: --timeout 3m
Expand Down
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ __debug_bin
# JetBrains
.idea/

# Go workspace file
go.work
go.work.sum

# configuration file
/config/*.json
/config/*.toml
Expand All @@ -26,8 +22,8 @@ go.work.sum
/config/**/*.local.*

# data dir of etcd
etcd
bin
/etcd
/bin

*.xml

Expand Down
18 changes: 5 additions & 13 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ run:
timeout: 1m # default 1m
skip-dirs:
- ^client/
- ^raft/
- ^cmd/ # TODO: fix lint
- ^pkg/raft/
- ^proto/
- ^test/ # TODO: fix lint
- ^tool/ # TODO: fix lint

severity:
default-severity: info
Expand Down Expand Up @@ -37,7 +40,7 @@ linters-settings:
shadow:
strict: true # default false
staticcheck:
go: "1.17" # default 1.13
go: "1.19" # default 1.13
checks: ["*"] # https://staticcheck.io/docs/options#checks # default ["*"]
unused:
check-exported: false # default false # TODO: enable after fixing false positives
Expand Down Expand Up @@ -418,17 +421,6 @@ issues:
- path: "init.go"
linters:
- gochecknoinits
- path: "^vsctl"
linters:
- gomnd
- funlen
- gocognit
- gocyclo
- nestif
- cyclop
- gochecknoinits
- gochecknoglobals
- forbidigo
- text: "unexported-return: exported func (NewController|NewGateway) returns unexported type"
linters:
- revive
Expand Down
38 changes: 20 additions & 18 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
* @wenfengwang
* @ifplusor

/build/ @xdlbdy

/client/ @ifplusor
/lib/ @ifplusor
/pkg/raft/ @ifplusor

/cmd/controller/ @xdlbdy
/cmd/gateway/ @ifplusor
/cmd/store/ @ifplusor
/cmd/trigger/ @xdlbdy
/pkg/kv/ @xdlbdy

/deploy/ @xdlbdy
/server/root/ @xdlbdy
/server/controller/ @xdlbdy
/server/controller/eventbus/ @ifplusor
/server/gateway/ @hwjiangkai
/server/store/ @ifplusor
/server/trigger/ @xdlbdy
/server/timer/ @hwjiangkai

/internal/controller/ @xdlbdy
/internal/controller/eventbus/ @ifplusor
/internal/gateway/ @hwjiangkai
/internal/kv/ @xdlbdy
/internal/raft/ @ifplusor
/internal/store/ @ifplusor
/internal/trigger/ @xdlbdy
/internal/timer/ @hwjiangkai
/client/ @hwjiangkai

/raft/ @ifplusor
/cmd/vs-root/ @xdlbdy
/cmd/vs-controller/ @xdlbdy
/cmd/vs-gateway/ @ifplusor
/cmd/vs-store/ @ifplusor
/cmd/vs-trigger/ @xdlbdy
/cmd/vs-timer/ @hwjiangkai

/build/ @xdlbdy
/deploy/ @xdlbdy
110 changes: 59 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
VANUS_ROOT=$(shell pwd)
VSPROTO_ROOT=$(VANUS_ROOT)/proto
GIT_COMMIT=$(shell git log -1 --format='%h' | awk '{print $0}')
DATE=$(shell date +%Y-%m-%d_%H:%M:%S%z)
GO_VERSION=$(shell go version)
VANUS_ROOT = $(shell pwd)
GIT_COMMIT = $(shell git log -1 --format='%h' | awk '{print $0}')
DATE = $(shell date +%Y-%m-%d_%H:%M:%S%z)
GO_VERSION = $(shell go version)

export VANUS_LOG_LEVEL=info

DOCKER_REGISTRY ?= public.ecr.aws
DOCKER_REPO ?= ${DOCKER_REGISTRY}/vanus
IMAGE_PREFIX ?=
IMAGE_TAG ?= ${GIT_COMMIT}

#os linux or darwin
GOOS ?= linux
#arch amd64 or arm64
GOARCH ?= amd64
CMD_OUTPUT_DIR ?= ${VANUS_ROOT}/bin

BIN_DIR = ${VANUS_ROOT}/bin
CMD_DIR = ${VANUS_ROOT}/cmd
CMD_OUTPUT_DIR ?= ${BIN_DIR}

VERSION ?= ${IMAGE_TAG}

Expand All @@ -25,77 +28,82 @@ DOCKER_PLATFORM ?= linux/amd64,linux/arm64
clean:
rm -rf bin

docker-push: docker-push-root docker-push-controller docker-push-timer docker-push-trigger docker-push-gateway docker-push-store
docker-build: docker-build-root docker-build-controller docker-build-timer docker-build-trigger docker-build-gateway docker-build-store
build: build-root build-controller build-timer build-trigger build-gateway build-store

docker-push-store:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}store:${IMAGE_TAG} -f build/images/store/Dockerfile . --push
docker-build-store:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}store:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/store/Dockerfile .
build-store:
$(GO_BUILD) -o bin/store cmd/store/main.go

docker-push-gateway:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}gateway:${IMAGE_TAG} -f build/images/gateway/Dockerfile . --push
docker-build-gateway:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}gateway:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/gateway/Dockerfile .
build-gateway:
$(GO_BUILD) -o bin/gateway cmd/gateway/main.go

docker-push-test-infra:
docker build -t ${DOCKER_REPO}/test-infra:${IMAGE_TAG} -f test/infra/Dockerfile .
docker push ${DOCKER_REPO}/test-infra:${IMAGE_TAG}

docker-push-test-regression:
docker build -t ${DOCKER_REPO}/test-regression:${IMAGE_TAG} -f test/regression/Dockerfile .
docker push ${DOCKER_REPO}/test-regression:${IMAGE_TAG}

t1=-X 'main.Version=${VERSION}'
t2=${t1} -X 'main.GitCommit=${GIT_COMMIT}'
t3=${t2} -X 'main.BuildDate=${DATE}'
t4=${t3} -X 'main.GoVersion=${GO_VERSION}'
LD_FLAGS=${t4} -X 'main.Platform=${GOOS}/${GOARCH}'

docker-push-toolbox:
docker buildx build --no-cache --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/toolbox:${IMAGE_TAG} -f build/toolbox/Dockerfile . --push
LD_FLAGS = -X 'main.Version=${VERSION}'
LD_FLAGS += -X 'main.GitCommit=${GIT_COMMIT}'
LD_FLAGS += -X 'main.BuildDate=${DATE}'
LD_FLAGS += -X 'main.GoVersion=${GO_VERSION}'
LD_FLAGS += -X 'main.Platform=${GOOS}/${GOARCH}'

build-vsctl:
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/vsctl ./vsctl/
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/vsctl ${CMD_DIR}/vsctl/

build-vsrepair:
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/vsrepair ./vsrepair/
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/vsrepair ${CMD_DIR}/vsrepair/

.PHONY: build-cmd
build-cmd: build-vsctl

.PHONY: docker-push
docker-push: docker-push-root docker-push-controller docker-push-timer docker-push-trigger docker-push-gateway docker-push-store

.PHONY: docker-build
docker-build: docker-build-root docker-build-controller docker-build-timer docker-build-trigger docker-build-gateway docker-build-store

.PHONY: build
build: build-root build-controller build-store build-timer build-trigger build-gateway

docker-push-root:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}root-controller:${IMAGE_TAG} -f build/images/root-controller/Dockerfile . --push
docker-build-root:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}root-controller:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/root-controller/Dockerfile .
build-root:
$(GO_BUILD) -o bin/root-controller cmd/root/main.go
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/root-controller ${CMD_DIR}/vs-root/

docker-push-controller:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}controller:${IMAGE_TAG} -f build/images/controller/Dockerfile . --push
docker-build-controller:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}controller:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/controller/Dockerfile .
build-controller:
$(GO_BUILD) -o bin/controller cmd/controller/main.go
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/controller ${CMD_DIR}/vs-controller/

docker-push-trigger:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}trigger:${IMAGE_TAG} -f build/images/trigger/Dockerfile . --push
docker-build-trigger:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}trigger:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/trigger/Dockerfile .
build-trigger:
$(GO_BUILD) -o bin/trigger cmd/trigger/main.go
docker-push-store:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}store:${IMAGE_TAG} -f build/images/store/Dockerfile . --push
docker-build-store:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}store:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/store/Dockerfile .
build-store:
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/store ${CMD_DIR}/vs-store/

docker-push-timer:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}timer:${IMAGE_TAG} -f build/images/timer/Dockerfile . --push
docker-build-timer:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}timer:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/timer/Dockerfile .
build-timer:
$(GO_BUILD) -o bin/timer cmd/timer/main.go
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/timer ${CMD_DIR}/vs-timer/

docker-push-trigger:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}trigger:${IMAGE_TAG} -f build/images/trigger/Dockerfile . --push
docker-build-trigger:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}trigger:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/trigger/Dockerfile .
build-trigger:
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/trigger ${CMD_DIR}/vs-trigger/

docker-push-gateway:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}gateway:${IMAGE_TAG} -f build/images/gateway/Dockerfile . --push
docker-build-gateway:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/${IMAGE_PREFIX}gateway:${IMAGE_TAG} $(DOCKER_BUILD_ARG) -f build/images/gateway/Dockerfile .
build-gateway:
$(GO_BUILD) -ldflags "${LD_FLAGS}" -o ${CMD_OUTPUT_DIR}/gateway ${CMD_DIR}/vs-gateway/

docker-push-aio:
docker buildx build --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/all-in-one:${IMAGE_TAG} -f build/all-in-one/Dockerfile . --push

docker-push-test-infra:
docker build -t ${DOCKER_REPO}/test-infra:${IMAGE_TAG} -f test/infra/Dockerfile .
docker push ${DOCKER_REPO}/test-infra:${IMAGE_TAG}

docker-push-test-regression:
docker build -t ${DOCKER_REPO}/test-regression:${IMAGE_TAG} -f test/regression/Dockerfile .
docker push ${DOCKER_REPO}/test-regression:${IMAGE_TAG}

docker-push-toolbox:
docker buildx build --no-cache --platform ${DOCKER_PLATFORM} -t ${DOCKER_REPO}/toolbox:${IMAGE_TAG} -f build/toolbox/Dockerfile . --push
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div align="center">

<img src="img/vanus-logo.jpg" width="288" >
<img src="assets/img/vanus-logo.jpg" width="288" >

<!--
<img src="https://user-images.githubusercontent.capabilitiesom/68597908/206148625-43f14f58-f3c0-4042-82a0-9f9421c270fa.png" width="288" >
Expand Down
Loading

0 comments on commit c9aff3e

Please sign in to comment.