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

ci: add proto file comments linter #733

Merged
merged 11 commits into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from 9 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
22 changes: 22 additions & 0 deletions .github/workflows/proto-linter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Layotto Env Pipeline 🌊

on:
pull_request:
branches:
- main

jobs:
check:
name: "🍀 Proto Validation"
runs-on: ubuntu-latest
MichaelDeSteven marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Check out code
uses: actions/checkout@v2
- name: buf-setup
uses: bufbuild/buf-setup-action@v1
with:
version: '1.6.0'
- name: buf-lint
uses: bufbuild/buf-lint-action@v1
- name: check it
run: buf lint
MichaelDeSteven marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: v1
lint:
use:
- MINIMAL
- COMMENT_ENUM
- COMMENT_ENUM_VALUE
- COMMENT_FIELD
- COMMENT_MESSAGE
- COMMENT_ONEOF
- COMMENT_RPC
- COMMENT_SERVICE
MichaelDeSteven marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 9 additions & 2 deletions make/proto.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@ proto.gen.doc:

.PHONY: proto.gen.init
proto.gen.init:
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2

.PHONY: proto.gen.code
proto.gen.code:
$(DOCKER) build -t layotto/protoc $(ROOT_DIR)/docker/proto && \
$(DOCKER) run --rm \
-v $(ROOT_DIR)/spec/proto/runtime/v1:/api/proto \
layotto/protoc

.PHONY: proto.comments
proto.comments:
curl -fsSL \
"https://github.com/bufbuild/buf/releases/download/v1.6.0/buf-$$(uname -s)-$$(uname -m)" \
-o "$(OUTPUT_DIR)/buf"
buf lint $(ROOT_DIR)
MichaelDeSteven marked this conversation as resolved.
Show resolved Hide resolved
58 changes: 56 additions & 2 deletions spec/proto/runtime/v1/runtime.proto
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ service Runtime {
// A non-blocking method trying to get a lock with ttl.
rpc TryLock(TryLockRequest)returns (TryLockResponse) {}

// A method trying to unlock.
rpc Unlock(UnlockRequest)returns (UnlockResponse) {}

// Sequencer API
Expand Down Expand Up @@ -89,6 +90,7 @@ service Runtime {
}

message GetFileMetaRequest{
// File meta request
FileRequest request = 1;
}

Expand All @@ -97,19 +99,22 @@ message GetFileMetaResponse{
int64 size = 1;
// The modified time of file
string last_modified = 2;
// File meta response
FileMeta response = 3;
}

message FileMetaValue{
// File meta value
repeated string value = 1;
}

message FileMeta{
// A data structure to store metadata
map<string,FileMetaValue> metadata = 1;
}

message GetFileRequest {
//
// The name of store
string store_name = 1;
// The name of the file or object want to get.
string name = 2;
Expand All @@ -118,10 +123,12 @@ message GetFileRequest {
}

message GetFileResponse {
// The data of file
bytes data = 1;
}

message PutFileRequest {
// The name of store
string store_name = 1;
// The name of the file or object want to put.
string name = 2;
Expand All @@ -132,6 +139,7 @@ message PutFileRequest {
}

message FileRequest {
// The name of store
string store_name = 1;
// The name of the directory
string name = 2;
Expand All @@ -140,8 +148,11 @@ message FileRequest {
}

message ListFileRequest {
// File request
FileRequest request = 1;
// Page size
int32 page_size = 2;
// Marker
string marker = 3;
}

Expand All @@ -156,12 +167,16 @@ message FileInfo {
map<string,string> metadata = 4;
}
message ListFileResp {
// File info
repeated FileInfo files = 1;
// Marker
string marker = 2;
// Is truncated
bool is_truncated = 3;
}

message DelFileRequest {
// File request
FileRequest request = 1;
}

Expand All @@ -188,6 +203,7 @@ message SequencerOptions {
STRONG = 1;
}

// Default STRONG auto-increment
AutoIncrement increment = 1;

// We removed Uniqueness enum to make it simple.
Expand Down Expand Up @@ -237,73 +253,106 @@ message TryLockRequest {
}

message TryLockResponse {
// Is lock success
bool success = 1;
}

message UnlockRequest {
// The name of store
string store_name = 1;
// resource_id is the lock key.
string resource_id = 2;

// The owner of the lock
string lock_owner = 3;
}

message UnlockResponse {
// The enum of unlock status
enum Status {
// Unlock is success
SUCCESS = 0;
// The lock is not exist
LOCK_UNEXIST = 1;
// The lock is belong to others
LOCK_BELONG_TO_OTHERS = 2;
// Internal error
INTERNAL_ERROR = 3;
}

// The status of unlock
Status status = 1;
}

message SayHelloRequest {
// The name of service
string service_name = 1;
// Reuqest name
string name = 2;
// Optional. This field is used to control the packet size during load tests.
google.protobuf.Any data = 3;
}

message SayHelloResponse {
// Hello
string hello = 1;
// Hello message of data
google.protobuf.Any data = 2;
}

message InvokeServiceRequest {
// The identify of InvokeServiceRequest
string id = 1;
// InvokeServiceRequest message
CommonInvokeRequest message = 3;
}

message CommonInvokeRequest {
// The method of requset
string method = 1;
// The request data
google.protobuf.Any data = 2;
// The content type of request data
string content_type = 3;
// The extra information of http
HTTPExtension http_extension = 4;
}

message HTTPExtension {
// The enum of http reuest method
enum Verb {
// NONE
NONE = 0;
// GET method
GET = 1;
// HEAD method
HEAD = 2;
// POST method
POST = 3;
// PUT method
PUT = 4;
// DELETE method
DELETE = 5;
// CONNECT method
CONNECT = 6;
// CONNECT method
OPTIONS = 7;
// CONNECT method
TRACE = 8;
// PATCH method
PATCH = 9;
}

// The method of http reuest
Verb verb = 1;

// The query information of http
string querystring = 2;
}

message InvokeResponse {
// The response data
google.protobuf.Any data = 1;
// The content type of response data
string content_type = 2;
}

Expand Down Expand Up @@ -575,6 +624,7 @@ message StateOptions {
// When an ETag is associated with an save or delete request, the store shall allow the update only if the attached ETag matches with the latest ETag in the database.
// But when ETag is missing in the write requests, the state store shall handle the requests in the specified strategy(e.g. a last-write-wins fashion).
enum StateConcurrency {
// Concurrency state is unspecified
CONCURRENCY_UNSPECIFIED = 0;
// First write wins
CONCURRENCY_FIRST_WRITE = 1;
Expand All @@ -584,6 +634,7 @@ message StateOptions {

// Enum describing the supported consistency for state.
enum StateConsistency {
// Consistency state is unspecified
CONSISTENCY_UNSPECIFIED = 0;
// The API server assumes data stores are eventually consistent by default.A state store should:
// - For read requests, the state store can return data from any of the replicas
Expand All @@ -596,7 +647,9 @@ message StateOptions {
CONSISTENCY_STRONG = 2;
}

// The state operation of concurrency
StateConcurrency concurrency = 1;
// The state operation of consistency
StateConsistency consistency = 2;
}

Expand Down Expand Up @@ -714,5 +767,6 @@ message GetBulkSecretResponse {

// SecretResponse is a map of decrypted string/string values
message SecretResponse {
// The data struct of secrets
map<string, string> secrets = 1;
}