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

feat: add github actions #5

Merged
merged 21 commits into from
Jul 5, 2024
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
25 changes: 25 additions & 0 deletions .github/workflows/code-static-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Code Static Check

on:
pull_request:
branches:
- main

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4.1.3
- uses: bufbuild/buf-setup-action@9990c72db080fa39cf561230b8d2d7b736681f85 # v1.30.1
with:
version: "1.28.1"
- uses: actions/setup-go@v4
with:
go-version: 1.22.2
- name: Run Buf Lint
run: buf lint
- name: Run Buf format
run: buf format -d --exit-code
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
9 changes: 9 additions & 0 deletions buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@ name: buf.build/shibukazu/open-ve
deps:
- buf.build/googleapis/googleapis
- buf.build/grpc-ecosystem/grpc-gateway
breaking:
use:
- FILE
lint:
use:
- DEFAULT
except:
- PACKAGE_VERSION_SUFFIX
- PACKAGE_DIRECTORY_MATCH
2 changes: 1 addition & 1 deletion go/pkg/dsl/dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (r *DSLReader) parseAndSaveDSL(dsl *DSL) error {
return err
}
if err := r.redis.Set(GetVariablesID(v.ID), variablesBytes, 0).Err(); err != nil {
failure.Translate(err, appError.ErrRedisOperationFailed)
return failure.Translate(err, appError.ErrRedisOperationFailed)
}

celVariables, err := ToCELVariables(v.Variables)
Expand Down
45 changes: 20 additions & 25 deletions proto/dsl/v1/dsl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,32 +5,29 @@ import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "protoc-gen-openapiv2/options/annotations.proto";


option go_package = "proto/dsl/v1";

message Validation {
string id = 1 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"price\""}
];
string cel = 2 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"number % 3 == 0 || number < 5\""}
];
repeated Variable variables = 3 [
(google.api.field_behavior) = REQUIRED
];
string id = 1 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"price\""}
];
string cel = 2 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"number % 3 == 0 || number < 5\""}
];
repeated Variable variables = 3 [(google.api.field_behavior) = REQUIRED];
}

message Variable {
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"number\""}
];
string type = 2 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"int\""}
];
string name = 1 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"number\""}
];
string type = 2 [
(google.api.field_behavior) = REQUIRED,
(grpc.gateway.protoc_gen_openapiv2.options.openapiv2_field) = {example: "\"int\""}
];
}

message RegisterRequest {
Expand All @@ -57,16 +54,14 @@ service DSLService {
tags: ["DSL"]
operation_id: "Register"
};
};
}
rpc Read(ReadRequest) returns (ReadResponse) {
option (google.api.http) = {
get: "/v1/dsl"
};
option (google.api.http) = {get: "/v1/dsl"};

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "Read DSL"
tags: ["DSL"]
operation_id: "Read"
};
};
}
}
23 changes: 11 additions & 12 deletions proto/openapi/v1/openapi.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ package openapi.v1;
import "protoc-gen-openapiv2/options/annotations.proto";

option go_package = "proto/validate/v1";

option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
info: {
title: "Open-VE";
description: "Centralized and Consistent Data Validation Engine";
version: "1.0";
title: "Open-VE"
description: "Centralized and Consistent Data Validation Engine"
version: "1.0"
contact: {
name: "Open-VE";
url: "https://github.com/shibukazu/open-ve";
};
};
consumes: "application/json";
produces: "application/json";
schemes: HTTPS;
};
name: "Open-VE"
url: "https://github.com/shibukazu/open-ve"
}
}
consumes: "application/json"
produces: "application/json"
schemes: HTTPS
};
4 changes: 2 additions & 2 deletions proto/validate/v1/validate.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
syntax = "proto3";
package validate.v1;

import "google/protobuf/any.proto";
import "google/api/annotations.proto";
import "google/api/field_behavior.proto";
import "google/protobuf/any.proto";
import "protoc-gen-openapiv2/options/annotations.proto";

option go_package = "proto/validate/v1";
Expand Down Expand Up @@ -43,4 +43,4 @@ service ValidateService {
operation_id: "Check"
};
}
}
}
Loading