diff --git a/.github/workflows/pypi.yml b/.github/workflows/pypi.yml index 28df5829..24f1e57f 100644 --- a/.github/workflows/pypi.yml +++ b/.github/workflows/pypi.yml @@ -16,12 +16,23 @@ 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 + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies 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 @@ -37,6 +48,18 @@ 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 + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies run: | cd python @@ -60,7 +83,19 @@ 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 + - name: Install Protoc 3rd party protos + run: scripts/install-protoc.sh + - name: Install dependencies 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/package.json b/package.json index 3fe32a7f..858d169c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wechaty-grpc", - "version": "0.20.5", + "version": "0.20.7", "description": "gRPC for Wechaty", "main": "dist/src/mod.js", "typings": "dist/src/mod.d.js", 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..60ac0006 100644 --- a/python/Makefile +++ b/python/Makefile @@ -9,16 +9,17 @@ all : generate .PHONY: clean clean: - rm -fr generated/* + rm -fr src/* .PHONY: install install: pip3 install -r requirements.txt pip3 install -r requirements-dev.txt + ../scripts/install-protoc.sh .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/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 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'