From 896895f9400a74e2961f759eab92b677390aa72f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:39:20 +0800 Subject: [PATCH 1/8] follow latest grpc proto annotations & rename --- .github/workflows/pypi.yml | 3 +-- .gitignore | 3 --- python/.gitignore | 2 +- python/Makefile | 6 +++--- python/generate.sh | 15 +++++++++++---- python/setup.py | 6 +++--- python/{ => tests}/integration_test.py | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) rename python/{ => tests}/integration_test.py (86%) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 28df5829..ac4ac0be 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -20,8 +20,7 @@ jobs: run: | cd python python -m pip install --upgrade pip - pip install -r requirements.txt - pip install -r requirements-dev.txt + make install - name: Test run: | cd python diff --git a/.gitignore b/.gitignore index 8a76d452..308fa391 100644 --- a/.gitignore +++ b/.gitignore @@ -76,9 +76,6 @@ t.* .idea target/ -# Python -python/src/ - # csharp *.nupkg .vs/ diff --git a/python/.gitignore b/python/.gitignore index bf891412..7a82c596 100644 --- a/python/.gitignore +++ b/python/.gitignore @@ -1 +1 @@ -chatie-grpc/ +src/wechaty_grpc diff --git a/python/Makefile b/python/Makefile index 07b2d7e4..736ee0f1 100644 --- a/python/Makefile +++ b/python/Makefile @@ -9,7 +9,7 @@ all : generate .PHONY: clean clean: - rm -fr generated/* + rm -fr src/* .PHONY: install install: @@ -17,8 +17,8 @@ install: pip3 install -r requirements-dev.txt .PHONY: test -pytest: - python3 -m pytest src/ tests/ +test: + python3 -m pytest tests/ code: code . diff --git a/python/generate.sh b/python/generate.sh index 26bc6b6b..cf868392 100755 --- a/python/generate.sh +++ b/python/generate.sh @@ -8,15 +8,22 @@ shopt -s globstar # # Directory to write generated code to (.js and .d.ts files) -OUT_DIR="./src/chatie_grpc" +OUT_DIR="./src/wechaty_grpc" [ -d ${OUT_DIR} ] || { mkdir -p ${OUT_DIR} } -./merge-proto.sh > "$OUT_DIR/chatie-grpc.proto" -PROTO_DIR="$OUT_DIR" +# ./merge-proto.sh > "$OUT_DIR/wechaty_grpc.proto" +# PROTO_DIR="$OUT_DIR" +PROTO_DIR=../proto/wechaty -PROTOC_CMD="python3 -m grpc_tools.protoc --proto_path=${PROTO_DIR} --proto_path=/usr/local/include/ ${PROTO_DIR}/**/*.proto" +PROTOC_CMD="python3 \ + -m grpc_tools.protoc \ + --proto_path=${PROTO_DIR} \ + --proto_path=../third-party \ + --proto_path=/usr/local/include/ \ + ${PROTO_DIR}/puppet.proto \ +" $PROTOC_CMD \ --python_betterproto_out=${OUT_DIR} diff --git a/python/setup.py b/python/setup.py index 8efc85b5..e0dd4552 100644 --- a/python/setup.py +++ b/python/setup.py @@ -35,15 +35,15 @@ def setup() -> None: version = versioning(pkg['version']) setuptools.setup( - name='chatie-grpc', + name='wechaty-grpc', version=version, author='Huan LI (李卓桓)', author_email='zixia@zixia.net', - description='gRPC for Chatie', + description='Wechaty Puppet Service gRPC API', long_description=long_description, long_description_content_type='text/markdown', license='Apache-2.0', - url='https://github.com/chatie/grpc', + url='https://github.com/wechaty/grpc', packages=setuptools.find_packages("src"), package_dir={'': 'src'}, classifiers=[ diff --git a/python/integration_test.py b/python/tests/integration_test.py similarity index 86% rename from python/integration_test.py rename to python/tests/integration_test.py index e2a1b6a9..fd01c41c 100644 --- a/python/integration_test.py +++ b/python/tests/integration_test.py @@ -15,4 +15,4 @@ def test_smoke_testing() -> None: """ wechaty """ - assert pytest, 'should True' + assert pytest, 'To-be added' From 06bb3a03841e8fb2a2a7d98187fe70d49061bf62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:39:54 +0800 Subject: [PATCH 2/8] deprecate merge-rpoto.sh (#46) --- python/merge-proto.sh | 7 +++++++ python/requirements-dev.txt | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/python/merge-proto.sh b/python/merge-proto.sh index c3021ffd..2256f8a5 100755 --- a/python/merge-proto.sh +++ b/python/merge-proto.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash +# +# DEPRECATED: this script was deprecated +# https://github.com/wechaty/grpc/issues/46 +# +# Huan(20200222): betterproto[compiler]>=2.0.0b2 is OK +# + set -eo pipefail function echo_name () { diff --git a/python/requirements-dev.txt b/python/requirements-dev.txt index a5b6f95b..2c88e2ff 100644 --- a/python/requirements-dev.txt +++ b/python/requirements-dev.txt @@ -1,4 +1,4 @@ -betterproto[compiler]>=2.0.0b1 +betterproto[compiler]>=2.0.0b2 grpcio-tools pyee pylint_quotes From acf2d746e63a56dbd136f48d5b1679be631de0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:44:19 +0800 Subject: [PATCH 3/8] install third party proto files --- python/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/python/Makefile b/python/Makefile index 736ee0f1..60ac0006 100644 --- a/python/Makefile +++ b/python/Makefile @@ -15,6 +15,7 @@ clean: install: pip3 install -r requirements.txt pip3 install -r requirements-dev.txt + ../scripts/install-protoc.sh .PHONY: test test: From 3322c65dbcabb336328399d3ea6046cad54bfdd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:44:30 +0800 Subject: [PATCH 4/8] 0.20.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5d56a7b6..3ac50aca 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-grpc", - "version": "0.20.4", + "version": "0.20.5", "description": "gRPC for Wechaty", "main": "dist/src/mod.js", "typings": "dist/src/mod.d.js", From 3a0841ec944d5174242cfbe6e5dec23d18d1b9dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:49:50 +0800 Subject: [PATCH 5/8] install proto by github actions --- .github/workflows/pypi.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index ac4ac0be..fa5af97d 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -16,6 +16,12 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.9 + + - name: Install Protoc + uses: arduino/setup-protoc@master + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies run: | cd python @@ -36,6 +42,12 @@ jobs: - uses: actions/setup-python@v1 with: python-version: 3.9 + + - name: Install Protoc + uses: arduino/setup-protoc@master + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies run: | cd python @@ -60,6 +72,12 @@ jobs: uses: actions/setup-python@v1 with: python-version: '3.7' + + - name: Install Protoc + uses: arduino/setup-protoc@master + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies run: | cd python From b82db5d0ac20c36db90286c71c8892b6857a9f33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:50:01 +0800 Subject: [PATCH 6/8] 0.20.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3ac50aca..f07ae601 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-grpc", - "version": "0.20.5", + "version": "0.20.6", "description": "gRPC for Wechaty", "main": "dist/src/mod.js", "typings": "dist/src/mod.d.js", From ec3a71a97f287eaee2de176ebf1083d20a8f2819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:52:35 +0800 Subject: [PATCH 7/8] add cache for pypi install --- .github/workflows/pypi.yml | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index fa5af97d..24f1e57f 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -16,6 +16,12 @@ jobs: uses: actions/setup-python@v1 with: python-version: 3.9 + - uses: actions/cache@master + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install Protoc uses: arduino/setup-protoc@master @@ -42,6 +48,12 @@ jobs: - uses: actions/setup-python@v1 with: python-version: 3.9 + - uses: actions/cache@master + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install Protoc uses: arduino/setup-protoc@master @@ -71,7 +83,13 @@ jobs: - name: Set up Python uses: actions/setup-python@v1 with: - python-version: '3.7' + python-version: '3.9' + - uses: actions/cache@master + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('python/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- - name: Install Protoc uses: arduino/setup-protoc@master From f8f076d2203d36cff617adf9b2776d140e7c5a08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Huan=20=28=E6=9D=8E=E5=8D=93=E6=A1=93=29?= Date: Mon, 22 Feb 2021 13:52:47 +0800 Subject: [PATCH 8/8] 0.20.7 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f07ae601..04ae9326 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-grpc", - "version": "0.20.6", + "version": "0.20.7", "description": "gRPC for Wechaty", "main": "dist/src/mod.js", "typings": "dist/src/mod.d.js",