From c30aaa2fcfaa275bb3880dc9029aa296f57ddbd5 Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Malmasi Date: Mon, 22 May 2023 09:43:05 +0330 Subject: [PATCH 1/2] generate_golang_protos and install_golang_requirements commands added to make file --- Makefile | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 1565338..86228b3 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ PROTOS_DIR=./protos PYTHON_PROTOS_OUTPUT_DIR=./AIaaS_interface PYTHON_REQUIREMENTS_FILE_PATH=./requirements.txt - +GOLANG_PROTOS_OUTPUT_DIR=./golang clean: rm -rf $(PYTHON_PROTOS_OUTPUT_DIR) + rm -rf $(GOLANG_PROTOS_OUTPUT_DIR) set_new_version_tag: bash ./scripts/generate_new_version_tag.sh @@ -12,6 +13,11 @@ set_new_version_tag: install_python_requirements: pip install -r $(PYTHON_REQUIREMENTS_FILE_PATH) +install_golang_requirements: + sudo apt-get update && sudo apt-get install -y protobuf-compiler + go install google.golang.org/protobuf/cmd/protoc-gen-go + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc + generate_python_protos: clean install_python_requirements mkdir $(PYTHON_PROTOS_OUTPUT_DIR) find $(PROTOS_DIR) -name "*.proto" \ @@ -21,3 +27,11 @@ generate_python_protos: clean install_python_requirements --pyi_out=$(PYTHON_PROTOS_OUTPUT_DIR) \ --grpc_python_out=$(PYTHON_PROTOS_OUTPUT_DIR) {} \; bash ./scripts/add_init_files.sh $(PYTHON_PROTOS_OUTPUT_DIR) + +generate_golang_protos: clean install_golang_requirements + mkdir $(GOLANG_PROTOS_OUTPUT_DIR) + find $(PROTOS_DIR) -name "*.proto" \ + -exec protoc \ + -I./protos \ + --go_out=$(GOLANG_PROTOS_OUTPUT_DIR) \ + --go-grpc_out=$(GOLANG_PROTOS_OUTPUT_DIR) {} \; From ca2f41e78f02bdc517aa19bea1ec3d3b0b83642e Mon Sep 17 00:00:00 2001 From: Mohammad Mahdi Malmasi Date: Mon, 22 May 2023 09:47:06 +0330 Subject: [PATCH 2/2] build and push golang codes CI added --- .../workflows/build_and_push_golang_codes.yml | 57 +++++++++++++++++++ Makefile | 4 +- .../notification_server.proto | 2 + 3 files changed, 61 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/build_and_push_golang_codes.yml diff --git a/.github/workflows/build_and_push_golang_codes.yml b/.github/workflows/build_and_push_golang_codes.yml new file mode 100644 index 0000000..0d989f6 --- /dev/null +++ b/.github/workflows/build_and_push_golang_codes.yml @@ -0,0 +1,57 @@ +name: Build and Push Tag to https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Golang + +on: [push] + +env: + DESTINATION_REPO: ECTLab/AIaaS-gRPC-protos-Autogenerated-Golang + DESTINATION_BRANCH: master + DESTINATION_TOKEN: ${{ secrets.PYTHON_DESTINATION_TOKEN }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout source code + uses: actions/checkout@v2 + with: + ref: ${{ github.ref }} + + - name: Install dependencies + run: | + make install_golang_requirements + + - name: Build + run: | + export PATH=$PATH:$(go env GOPATH)/bin + make generate_golang_protos + ls -l ./golang + + # - name: Checkout destination repo + # uses: actions/checkout@v2 + # with: + # repository: ${{ env.DESTINATION_REPO }} + # ref: ${{ env.DESTINATION_BRANCH }} + # token: ${{ env.DESTINATION_TOKEN }} + # path: destination-repo + + # - name: Copy files + # run: | + # rm -rf destination-repo/AIaaS_interface/ + # mkdir -p destination-repo/AIaaS_interface/ + # cp -r AIaaS_interface/* destination-repo/AIaaS_interface/ + + # - name: Commit changes + # run: | + # bash -c "if [[ ${{ github.ref }} == 'refs/tags/'* ]]; then export TAG_NAME=${{ github.ref }}; fi" + # echo "Tag name: $TAG_NAME" + # echo "payload: ${{ github.event.client_payload.tag_name }}" + # cd destination-repo + # git config user.email "m.mahdi.m79@gmail.com" + # git config user.name "Mohammad Mahdi Malmasi" + # git add . + # git commit -m "Update for tag: $TAG_NAME" + # git tag $TAG_NAME + # git push --tags + # git push origin master + # env: + # TAG_NAME: ${{ github.event.client_payload.tag_name }} diff --git a/Makefile b/Makefile index 86228b3..caa26bc 100644 --- a/Makefile +++ b/Makefile @@ -15,8 +15,8 @@ install_python_requirements: install_golang_requirements: sudo apt-get update && sudo apt-get install -y protobuf-compiler - go install google.golang.org/protobuf/cmd/protoc-gen-go - go install google.golang.org/grpc/cmd/protoc-gen-go-grpc + go install google.golang.org/protobuf/cmd/protoc-gen-go@latest + go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest generate_python_protos: clean install_python_requirements mkdir $(PYTHON_PROTOS_OUTPUT_DIR) diff --git a/protos/platform_management/notification_server.proto b/protos/platform_management/notification_server.proto index 4536e07..636f297 100644 --- a/protos/platform_management/notification_server.proto +++ b/protos/platform_management/notification_server.proto @@ -2,6 +2,8 @@ syntax = "proto3"; package platform_managment; +option go_package = "https://github.com/ECTLab/AIaaS-gRPC-protos-Autogenerated-Golang.git/AIaaS_interface/platform_managment/"; + message SendEmailRequest { string email = 1;