ci action (#15)
* ci action
* ci action
* Create build.yml
* Delete build.yml
* Update README.md
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000..693b884
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,39 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+name: Build and Test
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+ - name: Set up Python 3.10
+ uses: actions/setup-python@v2
+ with:
+ python-version: '3.10'
+ - name: Install dependencies
+ run: pip install -r requirements.txt
+ - name: Run tests and collect coverage
+ run: pytest --cov app
+ - name: Upload coverage to Codecov
+ uses: codecov/codecov-action@v3
\ No newline at end of file
diff --git a/.github/workflows/license-checker.yml b/.github/workflows/license-checker.yml
new file mode 100644
index 0000000..ee5f902
--- /dev/null
+++ b/.github/workflows/license-checker.yml
@@ -0,0 +1,32 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+name: License checker
+
+on:
+ pull_request:
+ push:
+ branches:
+ - main
+
+jobs:
+ check-license:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Check License Header
+ uses: apache/skywalking-eyes@v0.1.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.licenserc.yaml b/.licenserc.yaml
new file mode 100644
index 0000000..8e74b29
--- /dev/null
+++ b/.licenserc.yaml
@@ -0,0 +1,32 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+header:
+ license:
+ spdx-id: Apache-2.0
+ copyright-owner: Apache Software Foundation
+
+ paths-ignore:
+ - 'licenses'
+ - '**/*.md'
+ - 'LICENSE'
+ - 'DISCLAIMER'
+ - 'NOTICE'
+ - '.gitignore'
+
+ comment: on-failure
\ No newline at end of file
diff --git a/README.md b/README.md
index 59dc130..2a92ab2 100644
--- a/README.md
+++ b/README.md
@@ -1,30 +1,39 @@
-## Apache-ShenYu-Client
-Apache-Shenyu-Client for python client allows you to access ShenYu Gateway, it supports registory python service to ShenYu Gateway.
+## Apache-ShenYu-Client
-### Requirements
-Supported python version over 3.6
-Supported ShenYu version over 2.4.3
+[![Build and Test](https://github.com/apache/incubator-shenyu-client-python/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/apache/incubator-shenyu-client-python/actions)
+[![codecov.io](https://codecov.io/gh/apache/incubator-shenyu-client-python/coverage.svg?branch=main)](https://app.codecov.io/gh/apache/incubator-shenyu-client-python?branch=main)
-### instructions
-> 1、install
-pip3 install Apache-ShenYu-Client -i https://pypi.python.org/simple
+Apache-Shenyu-Client for python client allows you to access ShenYu Gateway, it supports registry python service to ShenYu Gateway.
-> 2、usage
+### Requirements
-> 3.1、Use the decorator
+- python3.6+
+- ShenYu2.4.3+
+
+### Install
+
+`pip3 install Apache-ShenYu-Client -i https://pypi.python.org/simple`
+
+### Usage
+
+#### Use the decorator
```
->>import package:
+import package:
from apache_shenyu_client.config import GatewayConfig
from apache_shenyu_client.register import register_uri, register_metadata, register_all_metadata
+```
+_First, modify the configuration according to the project situation, If you do not configure it, you will not be able to use apache_shenyu_client._
-3.1.0、First, modify the configuration according to the project situation, If you do not configure it, you will not be able to use apache_shenyu_client.
-#### Configure shenyu gateway services and port
+- Configure shenyu gateway services and port
+```
GatewayConfig.test = {
"servers": "xx.xx.xx.xx",
"port": 1001
- }
-#### Configure python services information
+ }
+```
+- Configure python services information
+```
GatewayConfig.uri = {
"app_name": "app2", # app name
"host": "172.24.43.28", # python service host
@@ -32,8 +41,10 @@
"context_path": "/flask_test", # context_path
"environment": "test", # environment
"rpc_type": "http" # rpc type
- }
-#### Configure to get administrator token
+ }
+```
+- Configure to get administrator token
+```
GatewayConfig.register = {
"register_type": "http",
"servers": "xx.xx.xx.xx",
@@ -42,40 +53,41 @@
"password": "123456"
}
}
+```
+- Proxy all api
+ - Using a decorator at the entry of a service request to register for this service: `@register_uri`
+ - Using a decorator at the entry of a service request: `@register_all_metadata(register_all=True)`
-3.1.1、proxy all api
-
-3.1.1.1、Using a decorator at the entry of a service request to register for this service: @register_uri
-3.1.1.2、Using a decorator at the entry of a service request: @register_all_metadata(register_all=True)
-
-3.1.2、proxy some api
-3.1.2.1、Using a decorator at the entry of a service request to register for this service: @register_uri
-3.1.2.2、use a decorator on that api definition: @register_metadata,need param: path, as follows 3.1.2.3:
-
-3.1.2.3、this is a python flask service api, path is "/search"
+- Proxy some api
+ - Using a decorator at the entry of a service request to register for this service: @register_uri
+ - Use a decorator on that api definition: @register_metadata,need param: path, as follows 3.1.2.3:
+ - This is a python flask service api, path is "/search"
+ ```
@user.route('/search', methods=['GET'])
def user_search_handler():
data = UserBusiness.search_by_nickname()
return json_detail_render(0, data)`
+
+ proxy:
+ @register_metadata("/search")
+ @user.route('/search', methods=['GET'])
+ def user_search_handler():
+ data = UserBusiness.search_by_nickname()
+ return json_detail_render(0, data)
+
+ ```
-proxy:
-@register_metadata("/search")
-@user.route('/search', methods=['GET'])
-def user_search_handler():
- data = UserBusiness.search_by_nickname()
- return json_detail_render(0, data)
+#### Function call usage
```
-
-> 3.2、function call usage
-```
->>import package
+import package
from apache_shenyu_client.config import GatewayConfig
from apache_shenyu_client.api import GatewayProxy
gt = GatewayProxy()
-
-3.2.1、Modify the configuration according to the project situation
+```
+- Modify the configuration according to the project situation
+```
GatewayConfig.uri = {
"app_name": "app2", # app name
"host": "172.24.43.28", # python service host
@@ -84,14 +96,16 @@
"environment": "test", # environment
"rpc_type": "http" # rpc type
}
-
-3.2.2、register uri: gt.register_uri()
-
-"/helloqq2" is the path to register
-
-3.2.2.1、register some path:
-gt.register_metadata("/helloqq2")
-
-3.2.2.1、register all path:
-gt.register_metadata(register_all=True)
```
+- Register uri
+
+ ```gt.register_uri()``` and `"/helloqq2"` is the path to register
+
+ - register some path:
+ ```
+ gt.register_metadata("/helloqq2")
+ ```
+ - register all path:
+ ```
+ gt.register_metadata(register_all=True)
+ ```