Skip to content

Commit 4142794

Browse files
authored
Refactored the tests to use the github action (#111)
* Refactored the tests to use the github action * Fixed the yaml syntax * Added the shell name * Added the param * Removed the repo path during checkout * Added the repo path back * Removed the repo path * Debugging * Debugging * Made the params optional * Made the params optional * Changed the rai-host param name * Upgraded the setup python github action for node 12 issues * Added the rai_host param * Made the input params as mandatory * Fixed the rai_host value
1 parent 918f11d commit 4142794

File tree

3 files changed

+73
-16
lines changed

3 files changed

+73
-16
lines changed

.github/actions/test/action.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: 'rai-sdk-python test'
2+
3+
inputs:
4+
client_id:
5+
required: true
6+
description: 'Client ID for oAuth'
7+
8+
client_secret:
9+
required: true
10+
description: 'Client secret for oAuth'
11+
12+
client_credentials_url:
13+
required: true
14+
description: 'Client credentials url for fetching the oAuth token'
15+
16+
rai_host:
17+
required: false
18+
description: 'RAI host'
19+
default: 'azure-staging.relationalai.com'
20+
21+
custom_headers:
22+
required: false
23+
description: 'Optional http headers'
24+
default: '{}'
25+
26+
runs:
27+
using: 'composite'
28+
steps:
29+
- uses: actions/checkout@v3
30+
with:
31+
repository: RelationalAI/rai-sdk-python
32+
ref: ia-test-refactor
33+
34+
- name: Initialize Python 3.7
35+
uses: actions/setup-python@v2
36+
with:
37+
python-version: 3.7
38+
39+
- name: Install dependencies
40+
run: |
41+
python -m pip install --upgrade pip
42+
pwd
43+
ls
44+
pip install -r requirements.txt
45+
pip install -e ./
46+
shell: bash
47+
48+
- name: Generate Protobuf
49+
run: |
50+
python -m grpc_tools.protoc -I railib/pb --python_out=./railib/pb railib/pb/*.proto
51+
shell: bash
52+
53+
- name: test
54+
env:
55+
CLIENT_ID: ${{ inputs.client_id }}
56+
CLIENT_SECRET: ${{ inputs.client_secret }}
57+
CLIENT_CREDENTIALS_URL: ${{ inputs.client_credentials_url }}
58+
HOST: ${{ inputs.rai_host }}
59+
CUSTOM_HEADERS: ${{ inputs.custom_headers }}
60+
run: |
61+
mkdir -p ~/.rai
62+
python -m unittest
63+
shell: bash

.github/workflows/build.yaml

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,24 @@ jobs:
99
build:
1010
runs-on: ubuntu-latest
1111
steps:
12-
- uses: actions/checkout@v2
12+
- uses: actions/checkout@v3
1313

1414
- name: Initialize Python 3.7
15-
uses: actions/setup-python@v1
15+
uses: actions/setup-python@v2
1616
with:
1717
python-version: 3.7
1818

1919
- name: Install dependencies
2020
run: |
2121
python -m pip install --upgrade pip
2222
pip install flake8
23-
pip install -r requirements.txt
24-
pip install -e ./
25-
26-
- name: Generate Protobuf
27-
run: python -m grpc_tools.protoc -I railib/pb --python_out=./railib/pb railib/pb/*.proto
2823
2924
- name: flake8 linter
3025
run: flake8 .
3126

32-
- name: test
33-
env:
34-
CLIENT_ID: ${{ secrets.CLIENT_ID }}
35-
CLIENT_SECRET: ${{ secrets.CLIENT_SECRET }}
36-
CLIENT_CREDENTIALS_URL: ${{ secrets.CLIENT_CREDENTIALS_URL }}
37-
run: |
38-
mkdir -p ~/.rai
39-
python -m unittest
27+
- uses: ./.github/actions/test
28+
with:
29+
client_id: ${{ secrets.CLIENT_ID }}
30+
client_secret: ${{ secrets.CLIENT_SECRET }}
31+
client_credentials_url: ${{ secrets.CLIENT_CREDENTIALS_URL }}
32+
rai_host: 'azure.relationalai.com'

test/test_integration.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
client_id = os.getenv("CLIENT_ID")
1313
client_secret = os.getenv("CLIENT_SECRET")
1414
client_credentials_url = os.getenv("CLIENT_CREDENTIALS_URL")
15+
host = os.getenv("HOST")
1516
custom_headers = json.loads(os.getenv('CUSTOM_HEADERS', '{}'))
1617

1718
if client_id is None:
@@ -26,7 +27,7 @@
2627
client_credentials_url={client_credentials_url}
2728
region=us-east
2829
port=443
29-
host=azure.relationalai.com
30+
host={host}
3031
""")
3132
file.seek(0)
3233
cfg = config.read(fname=file.name)

0 commit comments

Comments
 (0)