Skip to content

Commit

Permalink
WIP - protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 authored and netanelc305 committed Dec 10, 2023
1 parent f1981ba commit f063bd7
Show file tree
Hide file tree
Showing 41 changed files with 1,795 additions and 1,969 deletions.
15 changes: 12 additions & 3 deletions .github/workflows/macos-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
- os: macos-latest
arch: arm64
python-version: "3.12"

- os: macos-latest
arch: x86_64
python-version: "3.8"
Expand All @@ -60,11 +60,20 @@ jobs:
- name: Run server
working-directory: ./src/rpcserver
run: |
make SERVER_CFLAGS=-DSAFE_READ_WRITES
sudo nohup ./rpcserver &
brew install protobuf protobuf-c
make -C ../protos/ c_protos
mkdir build
cd build
cmake .. -DTARGET=OSX
make
sudo nohup ./rpcserver_macosx &
- name: Install python package + pytest
working-directory: ./src/rpcclient
run: |
pip3 install mypy-protobuf protobuf grpcio-tools
make -C ../protos/ python_protos
python -m pip install --upgrade pip
python -m pip install -U pytest
python -m pip install -U .
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,16 @@ jobs:
- name: Lint with flake8
run: |
python -m pip install flake8
flake8 . --max-complexity=14 --max-line-length=127 --statistics
flake8 . --max-complexity=14 --max-line-length=127 --statistics --exclude=rpcclient/protos/*
- name: Verify sorted imports
run: |
python -m pip install isort
isort . -m HANGING_INDENT -l 120 --check-only
- name: Test install
run: |
pip3 install mypy-protobuf protobuf grpcio-tools
make -C ../protos/ python_protos
python -m pip install --upgrade pip
python -m pip install -U .
- name: Test show usage
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
python-version: '3.x'
- name: Install dependencies
run: |
pip3 install mypy-protobuf protobuf grpcio-tools
make -C ../protos/ python_protos
python -m pip install --upgrade pip
pip install -U build setuptools wheel twine
- name: Build and publish
Expand Down
27 changes: 21 additions & 6 deletions .github/workflows/server-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@ jobs:
include:
- os: macos-latest
arch: arm64
- os: macos-latest
arch: x86_64
- os: ubuntu-latest
arch: aarch64
- os: ubuntu-latest
arch: i686
- os: ubuntu-latest
arch: x86_64

steps:
- uses: actions/checkout@v3
- name: Test make
- name: Test build
run: |
make clean all
if [ "${{ runner.os }}" == "macOS" ]; then
brew install protobuf protobuf-c
pip3 install mypy-protobuf
make -C ../protos/ c_protos
mkdir build
cd build
cmake .. -DTARGET=IOS
make
cmake .. -DTARGET=OSX
make
elif [ "${{ runner.os }}" == "Linux" ]; then
sudo apt-get update
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev protobuf-c-compiler
make -C ../protos/ c_protos
mkdir build
cd build
cmake .. -DTARGET=LINUX
make
fi
45 changes: 26 additions & 19 deletions .github/workflows/server-publish.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Uploading release artifacts

on:
release:
types: [created]
pull_request:
branches: [ "master" ]

jobs:
build:
Expand All @@ -25,38 +25,45 @@ jobs:
name: Build server on ubuntu
working-directory: ./src/rpcserver
run: |
make SERVER_CFLAGS=-DSAFE_READ_WRITES
sudo apt-get update
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev protobuf-c-compiler
make -C ../protos/ c_protos
mkdir build
cd build
cmake .. -DTARGET=LINUX
make
- if: matrix.os == 'ubuntu-latest'
name: Upload ubuntu server artifact
uses: actions/upload-artifact@v3
with:
name: rpcserver_ubuntu_x86_64
path: ./src/rpcserver/rpcserver
name: rpcserver_linux
path: ./src/rpcserver/build/rpcserver_linux

- if: matrix.os == 'macos-latest'
name: Build server on macos
working-directory: ./src/rpcserver
run: |
./build_darwin.sh
brew install protobuf protobuf-c
make -C ../protos/ c_protos
mkdir build
cd build
cmake .. -DTARGET=IOS
make
cmake .. -DTARGET=OSX
make
- if: matrix.os == 'macos-latest'
name: Upload iphoneos server artifact
uses: actions/upload-artifact@v3
with:
name: rpcserver_iphoneos_arm64
path: ./src/rpcserver/rpcserver_iphoneos_arm64
name: rpcserver_ios
path: ./src/rpcserver/build/rpcserver_ios

- if: matrix.os == 'macos-latest'
name: Upload macos,x86_64 server artifact
uses: actions/upload-artifact@v3
with:
name: rpcserver_macosx_x86_64
path: ./src/rpcserver/rpcserver_macosx_x86_64

- if: matrix.os == 'macos-latest'
name: Upload macos,arm64 server artifact
name: Upload macos server artifact
uses: actions/upload-artifact@v3
with:
name: rpcserver_macosx_arm64
path: ./src/rpcserver/rpcserver_macosx_arm64
name: rpcserver_macosx
path: ./src/rpcserver/build/rpcserver_macosx
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ _CodeSignature

# Build
**/_version.py

# Third party
src/rpcserver/protobuf-c/
26 changes: 20 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,22 +80,36 @@ Install the latest client from PyPi:
python3 -m pip install -U rpcclient
```

## Building
## Construction

macOS & Linux:
**Note:** Cross-platform support is currently not available.

```shell
### macOS

For macOS/iOS (Ensure that Xcode is installed):

```bash
brew install protobuf protobuf-c
git clone [email protected]:doronz88/rpc-project.git
cd src/rpcserver
mkdir build
cd build
cmake .. -DTARGET=OSX # Build for macOS
# OR
cmake .. -DTARGET=IOS # Build for iOS
make
```

iOS (Make sure to have XCode installed):
### Linux

```shell
```bash
sudo apt-get install -y protobuf-compiler libprotobuf-dev libprotoc-dev protobuf-c-compiler
git clone [email protected]:doronz88/rpc-project.git
cd src/rpcserver
./build_darwin.sh
mkdir build
cd build
cmake .. -DTARGET=LINUX
make
```

## Quickstart
Expand Down
21 changes: 21 additions & 0 deletions src/protos/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PROTO_FILES = rpc.proto
PYTHON_OUT_DIR=../rpcclient/rpcclient/protos/
C_OUT_DIR=../rpcserver/protos/

.PHONY: all c_protos python_protos clean

all: c_protos python_protos

c_protos: $(PROTO_FILES)
# Compile Protocol Buffers for C
mkdir -p $(C_OUT_DIR)
protoc --c_out=$(C_OUT_DIR) --proto_path=. $(PROTO_FILES)

python_protos: $(PROTO_FILES)
# Compile Protocol Buffers for Python
mkdir -p $(PYTHON_OUT_DIR)
python3 -m grpc_tools.protoc --python_out=$(PYTHON_OUT_DIR) --mypy_out=$(PYTHON_OUT_DIR) --proto_path=. $(PROTO_FILES)

clean:
# Clean up generated files
rm -rf $(C_OUT_DIR) $(PYTHON_OUT_DIR)
Loading

0 comments on commit f063bd7

Please sign in to comment.