From 01e0904fa60bb2fcefe30090cdd84d2bf9f22763 Mon Sep 17 00:00:00 2001 From: nfel Date: Sat, 23 Nov 2024 16:17:21 +0330 Subject: [PATCH] v2: ci updates Signed-off-by: nfel --- .gitea/workflows/buf-ci.yaml | 55 +++++++++++++++++++++++++++--------- alert/v1/msg.proto | 46 ++++++++++++++++++++++++++++++ alert/v1/srv.proto | 12 ++++++++ base/v1/msg.proto | 9 ++++++ 4 files changed, 109 insertions(+), 13 deletions(-) create mode 100644 alert/v1/msg.proto create mode 100644 alert/v1/srv.proto diff --git a/.gitea/workflows/buf-ci.yaml b/.gitea/workflows/buf-ci.yaml index db8de27..a9284cf 100644 --- a/.gitea/workflows/buf-ci.yaml +++ b/.gitea/workflows/buf-ci.yaml @@ -21,25 +21,54 @@ jobs: with: token: ${{ gitea.token }} path: ./ + + - name: install tea cli and init + run: | + mkdir tmp && cd tmp + wget https://dl.gitea.com/tea/main/tea-main-linux-amd64.xz + apt install xz-utils -y + xz -d tea-main-linux-amd64.xz + mv tea-main-linux-amd64 tea + export PATH=$PATH:$(pwd)/tea + cd .. + tea login \ + --name ${{ gitea.server_url }} \ + --token ${{ secrets.PROD_REG_TOKEN }} \ + --url ${{ gitea.server_url }} - run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest - run: go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest - run: go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest - run: npm install --save @bufbuild/protobuf @bufbuild/protoc-gen-es @bufbuild/buf - run: buf --version - run: "export PATH=$PATH:./node_modules/.bin\nbuf generate \n" - - run: | - if [ -n ${{ gitea.ref_name }} ]; then - mkdir .res + - name: tar files + run: | for out in go ts doc; do - echo releasing ${out} ... tar czf .res/${out}.tar.gz ./stub/${out}/ - curl -Ss --user ${{ gitea.actor}}:${{ gitea.token}}\ - --upload-file .res/${out}.tar.gz \ - ${{ gitea.server_url }}/api/packages/Kahroba/generic/proto/${{ gitea.ref_name }}/${out}.tar.gz done - echo releasing proto ... - tar czf ./.res/src.tar.gz $(find -type f -name "*.proto") - curl -Ss --user ${{ gitea.actor}}:${{ gitea.token}}\ - --upload-file ./.res/src.tar.gz \ - ${{ gitea.server_url }}/api/packages/Kahroba/generic/proto/${{ gitea.ref_name }}/src.tar.gz - fi + tar czf ./.res/src.tar.gz $(find -type f -name "*.proto") + tea r c \ + --title "${{ gitea.ref_name }}" \ + --tag "${{ gitea.ref_name }}" \ + -a ./.res/src.tar.gz \ + -a ./.res/go.tar.gz \ + -a ./.res/doc.tar.gz \ + -a ./.res/ts.tar.gz \ + + # - run: | + # if [ -n ${{ gitea.ref_name }} ]; then + # mkdir .res + # for out in go ts doc; do + # echo releasing ${out} ... + # tar czf .res/${out}.tar.gz ./stub/${out}/ + # curl -Ss --user nfel:${{ secrets.PROD_REG_TOKEN }}\ + # --upload-file .res/${out}.tar.gz \ + # ${{ gitea.server_url }}/api/packages/Kahroba/generic/proto/${{ gitea.ref_name }}/${out}.tar.gz + # done + # echo releasing proto ... + # tar czf ./.res/src.tar.gz $(find -type f -name "*.proto") + # curl -Ss --user nfel:${{ secrets.PROD_REG_TOKEN }}\ + # --upload-file ./.res/src.tar.gz \ + # ${{ gitea.server_url }}/api/packages/Kahroba/generic/proto/${{ gitea.ref_name }}/src.tar.gz + # fi + # - run: | diff --git a/alert/v1/msg.proto b/alert/v1/msg.proto new file mode 100644 index 0000000..1296d52 --- /dev/null +++ b/alert/v1/msg.proto @@ -0,0 +1,46 @@ +syntax = "proto3"; + +package alert.v1; + +enum Importance { + LOW = 0; + MEDIUM = 1; + HIGH = 2; + CRITICAL = 3; +} + +enum LogSource { + UNKNOWN = 0; + USER = 1; + SYSTEM = 2; + WALLET = 3; +} + +message Meta { + uint32 created_at_ts = 1; + uint32 updated_at_ts = 2; + uint32 blamer_id = 3; // User ID of person who made the change +} + +message LogEvent { + optional uint64 id = 1; // Record Id of Log stored in db + string content = 2; + string effective_user = 3; + optional LogEvent prev_cause = 4; + optional LogSource source = 5; + Importance importance = 6; + Meta meta = 7; +} + +message LogEventList { + repeated LogEvent events = 1; +} +/* + Internal Msg +*/ +message SMS { + string recipient = 1; //recipient + string text = 2; + optional string sender = 3; + Meta meta = 4; +} diff --git a/alert/v1/srv.proto b/alert/v1/srv.proto new file mode 100644 index 0000000..0749057 --- /dev/null +++ b/alert/v1/srv.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +package alert.v1; + +import "alert/v1/msg.proto"; +import "base/v1/msg.proto"; + +service AlertSrv { + rpc Log(LogEvent) returns (base.v1.StatusRes) {} + rpc LogHistory(base.v1.IdReq) returns(LogEventList) {} + rpc StatusChange(LogEvent) returns (base.v1.StatusRes) {} +} diff --git a/base/v1/msg.proto b/base/v1/msg.proto index 9dc85cd..32a57cf 100644 --- a/base/v1/msg.proto +++ b/base/v1/msg.proto @@ -13,3 +13,12 @@ message IdRes { message IdReq { int64 id = 1; } +message Pagination{ + uint32 page = 1; // in query param it will be p + uint32 page_size = 2; // in query param it will be pz +} +message Filter { + string query = 1; // q + string sort = 2; // s + optional Pagination page = 3; +}