11name : Test - OpenAI API Coverage - Nightly / Manual
22on :
33 schedule :
4- - cron : ' 0 20 * * 1,2,3' # At 8 PM UTC on Monday, Tuesday, and Wednesday which is 3 AM UTC+7 Tuesday, Wednesday, and Thursday
4+ - cron : ' 0 20 * * 1,2,3,4,5,6 '
55 workflow_dispatch :
66 inputs :
77 endpoints :
1515 required : false
1616 default : dev
1717 type : string
18+
19+ push :
20+ branches :
21+ - fix/openai_coverage_misc
1822
1923env :
20- OPENAI_API_PYTHON_TAG : v1.23.2
24+ OPENAI_API_PYTHON_TAG : v1.33.0
2125 TARGET_BRANCH : ${{ github.event.inputs.branch }}
2226
2327jobs :
@@ -28,37 +32,26 @@ jobs:
2832 uses : actions/checkout@v4
2933 with :
3034 fetch-depth : 0
31- ref : ${{ env.TARGET_BRANCH }}
35+ # ref: ${{ env.TARGET_BRANCH }}
3236
3337 - name : Installing node
3438 uses : actions/setup-node@v4
3539 with :
3640 node-version : 20
3741
38- - name : " Cleanup cache"
39- continue-on-error : true
40- run : |
41- npm cache clean --force
42-
43- - name : Install dependencies
44- run : |
45- npm install -g @stoplight/prism-cli
42+ - uses : actions/setup-python@v4
43+ with :
44+ python-version : " 3.10"
4645
4746 - run : yarn install && yarn build
4847 working-directory : ./cortex-js
4948
50- - name : Run and extract openapi.json
51- run :
52- |
53- node cortex-js/dist/src/command.js serve --host 127.0.0.1 --port 4010 > cortex.log & cortex_pid=$!
54- sleep 3
55- wget --no-verbose -O api.json http://127.0.0.1:4010/api-json
56- kill $cortex_pid
57-
58- - name : Create python virtual environment and run test
49+ - name : Run test
5950 run : |
60- python3 -m venv /tmp/jan
61- source /tmp/jan/bin/activate
51+ node cortex-js/dist/src/command.js serve --host 127.0.0.1 --port 4010 > cortex.log & cortex_pid=$!
52+ sleep 3
53+ wget --no-verbose -O api.json http://127.0.0.1:4010/api-json
54+ cat api.json
6255
6356 # Clone openai-api-python repo
6457 git clone https://github.com/openai/openai-python.git -b $OPENAI_API_PYTHON_TAG
@@ -67,18 +60,14 @@ jobs:
6760 pip install -r requirements-dev.lock
6861 pip install pytest-reportportal pytest-html
6962
70- # Create pytest.ini file with content
71- mv ../coverage/pytest.ini pytest.ini
72- echo "rp_api_key=${{ secrets.RP_API_KEY }}" >> pytest.ini
73- echo "rp_endpoint=${{ secrets.RP_ENDPOINT }}" >> pytest.ini
74-
75- # Append to conftest.py
7663 mv ../coverage/conftest.py tests/conftest.py
7764 mv ../coverage/endpoint_mapping.json tests/endpoints_mapping.json
78-
79- prism mock ../api.json > prism.log & prism_pid=$!
80- pytest --endpoint "$ENDPOINTS" --reportportal --html=report.html && kill $prism_pid
81- deactivate
65+ mv ../coverage/pytest.ini pytest.ini
66+ echo "rp_api_key = ${{ secrets.RP_API_KEY }}" >> pytest.ini
67+ echo "rp_endpoint = ${{ secrets.RP_ENDPOINT }}" >> pytest.ini
68+
69+ pytest --continue-on-collection-errors --endpoint "$ENDPOINTS" --reportportal --html=report.html -v || true
70+ kill $cortex_pid
8271 env :
8372 ENDPOINTS : ${{ github.event.inputs.endpoints }}
8473
8776 run : |
8877 wget --no-verbose -O total-coverage.json "${{ secrets.RP_ENDPOINT }}/api/v1/openai-api-test/widget/27" --header 'authorization: bearer ${{ secrets.RP_API_KEY }}'
8978 wget --no-verbose -O today-endpoint.json "${{ secrets.RP_ENDPOINT }}/api/v1/openai-api-test/widget/multilevel/32" --header 'authorization: bearer ${{ secrets.RP_API_KEY }}'
79+
80+ echo "Overall coverage"
9081 cat total-coverage.json
9182 current_date=$(date +"%m-%d-%Y")
9283 cp today-endpoint.json $current_date.json
84+ echo "Endpoint today"
9385 cat $current_date.json
9486
9587 - name : Upload report json files to S3
@@ -109,7 +101,6 @@ jobs:
109101 name : report
110102 path : |
111103 openai-python/report.html
112- openai-python/prism.log
113104 openai-python/cortex.log
114105 openai-python/total-coverage.json
115106 openai-python/today-endpoint.json
0 commit comments