Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CI #24

Merged
merged 5 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 2 additions & 4 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ jobs:
uses: apache/skywalking-eyes@5c90c9698806040f50671a172a7cac17974ecebd
- name: Update dependencies
run: GOPROXY=https://proxy.golang.org go mod download
- name: Install Protoc
hanahmily marked this conversation as resolved.
Show resolved Hide resolved
uses: arduino/setup-protoc@v1
- name: Generate codes
run: make generate
- name: Lint
run: make lint
- name: Check
Expand Down Expand Up @@ -73,8 +73,6 @@ jobs:
uses: actions/checkout@v2
- name: Update dependencies
run: GOPROXY=https://proxy.golang.org go mod download
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Test
run: make test
checks:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*.so
*.dylib
bin
include
build/bin
build/release/

Expand Down
30 changes: 12 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,16 @@ PROJECTS := banyand

##@ Build targets

clean: TARGET=clean test-clean
clean: TARGET=clean
clean: PROJECTS:=$(PROJECTS) pkg
clean: default ## Clean artifacts in all projects

generate: ## Generate API codes
@echo "Install the protocol compiler plugins for Go..."
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.26
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.1
buf generate
$(MAKE) format
go install github.com/golang/mock/mockgen@v1.6.0
go generate ./...
$(MAKE) format
generate: TARGET=generate
generate: PROJECTS:=api $(PROJECTS) pkg
generate: default ## Generate API codes
@$(MAKE) format

build: TARGET=all
build: PROJECTS:=$(PROJECTS)
build: default ## Build all projects

##@ Release targets
Expand All @@ -49,24 +44,20 @@ release: default ## Build the release artifacts for all projects, usually the s
##@ Test targets

test: TARGET=test
test: PROJECTS:=$(PROJECTS)
test: default ## Run the unit tests in all projects

test-race: TARGET=test-race
test-race: PROJECTS:=$(PROJECTS)
test-race: default ## Run the unit tests in all projects with race detector on

test-coverage: TARGET=test-coverage
test-coverage: PROJECTS:=$(PROJECTS)
test-coverage: default ## Run the unit tests in all projects with coverage analysis on

##@ Code quality targets

lint: TARGET=lint
lint: PROJECTS:=$(PROJECTS)
lint: PROJECTS:=api $(PROJECTS) pkg
lint: default ## Run the linters on all projects


##@ Code style targets

# The goimports tool does not arrange imports in 3 blocks if there are already more than three blocks.
Expand All @@ -86,7 +77,7 @@ EXPECTED_GO_VERSION_PREFIX := "go version go$(CONFIGURED_GO_VERSION)"
GO_VERSION := $(shell go version)

## Check that the status is consistent with CI.
check: clean generate
check: clean
# case statement because /bin/sh cannot do prefix comparison, awk is awkward and assuming /bin/bash is brittle
@case "$(GO_VERSION)" in $(EXPECTED_GO_VERSION_PREFIX)* ) ;; * ) \
echo "Expected 'go version' to start with $(EXPECTED_GO_VERSION_PREFIX), but it didn't: $(GO_VERSION)"; \
Expand Down Expand Up @@ -123,6 +114,9 @@ default:
fi; \
done

nuke:
git clean -xdf

include scripts/build/help.mk

.PHONY: all $(PROJECTS) clean build release test test-race test-coverage lint default check format license-check license-fix pre-commit
.PHONY: all $(PROJECTS) clean build release test test-race test-coverage lint default check format license-check license-fix pre-commit nuke
35 changes: 8 additions & 27 deletions scripts/ci/install_fb.sh → api/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#!/usr/bin/env bash

# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
Expand All @@ -16,32 +14,15 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

set -e

FB_VERSION=${FB_VERSION:=v2.0.0}

for CMD in curl cmake g++ make; do
command -v $CMD > /dev/null || \
{ echo "[ERROR]: '$CMD' command not not found. Exiting" 1>&2; exit 1; }
done

## Create Temp Build Directory
BUILD_DIR=$(mktemp -d)
pushd $BUILD_DIR
NAME := api

## Fetch Tarball
curl -sLO https://github.com/google/flatbuffers/archive/$FB_VERSION.tar.gz
tar xf $FB_VERSION.tar.gz
include ../scripts/build/base.mk
include ../scripts/build/help.mk

## Build Binaries
cd flatbuffers-${FB_VERSION#v}
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release
make
./flattests
sudo cp flatc /usr/local/bin/flatc
sudo chmod +x /usr/local/bin/flatc
generate: $(PROTOC)
@PATH=$(PATH):$(tool_bin) buf generate

## Cleanup Temp Build Directory
popd
rm -rf $BUILD_DIR
lint: $(PROTOC)
@PATH=$(PATH):$(tool_bin) buf lint
24 changes: 24 additions & 0 deletions api/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

version: v1beta1
plugins:
- name: go
out: proto
opt: paths=source_relative
32 changes: 32 additions & 0 deletions api/buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

version: v1beta1
build:
roots:
- ./proto
lint:
use:
- DEFAULT
except:
- RPC_REQUEST_STANDARD_NAME
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I asked in the last PR #23 , do we need to impose these two rules?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the standard/common pattern to name the request. skywalking keeps using this pattern to build grpc service.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the standard/common pattern to name the request. skywalking keeps using this pattern to build grpc service.

So if we need to comply with the conventions, we have to change the request and response types as well as delete this except section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you fix this issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you fix this issue?

Sure I can do this later.

- RPC_RESPONSE_STANDARD_NAME
breaking:
use:
- FILE
2 changes: 1 addition & 1 deletion api/proto/banyandb/v1/database.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 api/proto/banyandb/v1/query.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 api/proto/banyandb/v1/rpc.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 api/proto/banyandb/v1/schema.pb.go

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

4 changes: 2 additions & 2 deletions api/proto/banyandb/v1/write.pb.go

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

2 changes: 2 additions & 0 deletions banyand/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ SERVER := $(NAME)-server
BINARIES := $(SERVER)
DEBUG_BINARIES := $(SERVER)-debug

include ../scripts/build/base.mk
include ../scripts/build/generate_go.mk
include ../scripts/build/build.mk
include ../scripts/build/test.mk
include ../scripts/build/lint.mk
Expand Down
2 changes: 2 additions & 0 deletions banyand/series/schema/sw/sw.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@
// specific language governing permissions and limitations
// under the License.

//nolint
//go:generate sh -c "protoc -I../../../../api/proto --encode=banyandb.v1.TraceSeries ../../../../api/proto/banyandb/v1/schema.proto < trace_series.textproto > trace_series.bin"
//go:generate sh -c "protoc -I../../../../api/proto --encode=banyandb.v1.IndexRule ../../../../api/proto/banyandb/v1/schema.proto < index_rule.textproto > index_rule.bin"
//nolint
//go:generate sh -c "protoc -I../../../../api/proto --encode=banyandb.v1.IndexRuleBinding ../../../../api/proto/banyandb/v1/schema.proto < index_rule_binding.textproto > index_rule_binding.bin"
package sw

Expand Down
2 changes: 1 addition & 1 deletion banyand/series/trace/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ func setupTestData(t *testing.T, ts *traceSeries, seriesEntities []seriesEntity)
seriesID := []byte(se.seriesID)
ev := pb.NewEntityValueBuilder().
DataBinary(se.entity.binary).
EntityId(se.entity.id).
EntityID(se.entity.id).
Timestamp(se.entity.t).
Fields(se.entity.items...).
Build()
Expand Down
6 changes: 3 additions & 3 deletions banyand/series/trace/trace.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ func (s *service) Serve() error {
e := pb.NewShardEventBuilder().Action(v1.Action_ACTION_PUT).Time(t).
Shard(
pb.NewShardBuilder().
Id(uint64(i)).Total(sMeta.shardNum).SeriesMetadata(sMeta.group, sMeta.name).UpdatedAt(t).CreatedAt(t).
ID(uint64(i)).Total(sMeta.shardNum).SeriesMetadata(sMeta.group, sMeta.name).UpdatedAt(t).CreatedAt(t).
Node(pb.NewNodeBuilder().
Id(s.repo.NodeID()).CreatedAt(t).UpdatedAt(t).Addr("localhost").
ID(s.repo.NodeID()).CreatedAt(t).UpdatedAt(t).Addr("localhost").
Build()).
Build()).
Build()
Expand Down Expand Up @@ -405,7 +405,7 @@ func (t *traceSeries) getState(entityValue *v1.EntityValue) (state State, fieldS
state = StateError
default:
err = errors.Wrapf(ErrUnknownFieldValue, "value:%s, supported value: %s, %s",
string(v.Str.GetValue()), t.strStateSuccessVal, t.strStateErrorVal)
v.Str.GetValue(), t.strStateSuccessVal, t.strStateErrorVal)
return
}
default:
Expand Down
2 changes: 1 addition & 1 deletion banyand/series/trace/write_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ func Test_traceSeries_Write(t *testing.T) {
seriesID := []byte(tt.args.seriesID)
ev := pb.NewEntityValueBuilder().
DataBinary(tt.args.entity.binary).
EntityId(tt.args.entity.id).
EntityID(tt.args.entity.id).
Fields(tt.args.entity.items...).
Timestamp(time.Now()).
Build()
Expand Down
5 changes: 0 additions & 5 deletions buf.gen.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions buf.yaml

This file was deleted.

9 changes: 5 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,19 @@ require (
github.com/RoaringBitmap/roaring v0.9.1
github.com/cespare/xxhash v1.1.0
github.com/dgraph-io/badger/v3 v3.2011.1
github.com/golang/mock v1.3.1
github.com/golang/mock v1.5.0
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6
github.com/klauspost/compress v1.13.1 // indirect
github.com/oklog/run v1.1.0
github.com/pkg/errors v0.9.1
github.com/rs/zerolog v1.23.0
github.com/spf13/cobra v1.1.3
github.com/spf13/cobra v1.2.1
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.7.1
github.com/spf13/viper v1.8.1
github.com/stretchr/testify v1.7.0
go.uber.org/atomic v1.7.0
go.uber.org/multierr v1.6.0
go.uber.org/multierr v1.7.0
golang.org/x/net v0.0.0-20210716203947-853a461950ff // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
google.golang.org/genproto v0.0.0-20210722135532-667f2b7c528f // indirect
Expand Down
Loading