fix: Add flag to skip if error #26
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test - OpenAI API Coverage - Nightly / Manual | |
on: | |
schedule: | |
- cron: '0 20 * * 1,2,3,4,5,6' | |
workflow_dispatch: | |
inputs: | |
endpoints: | |
description: 'comma-separated list (see available at coverage/endpoint_mapping.json e.g. GET /users,POST /transform)' | |
required: false | |
default: all | |
type: string | |
branch: | |
description: 'Target github branch - default is dev' | |
required: false | |
default: dev | |
type: string | |
push: | |
branches: | |
- fix/openai_coverage_misc | |
env: | |
OPENAI_API_PYTHON_TAG: v1.33.0 | |
TARGET_BRANCH: ${{ github.event.inputs.branch }} | |
jobs: | |
openai-python-tests: | |
runs-on: [self-hosted, Linux, ubuntu-desktop] | |
steps: | |
- name: Getting the repo | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# ref: ${{ env.TARGET_BRANCH }} | |
- name: Installing node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: "3.10" | |
- run: yarn install && yarn build | |
working-directory: ./cortex-js | |
- name: Run test | |
run: | | |
node cortex-js/dist/src/command.js serve --host 127.0.0.1 --port 4010 > cortex.log & cortex_pid=$! | |
sleep 3 | |
wget --no-verbose -O api.json http://127.0.0.1:4010/api-json | |
cat api.json | |
# Clone openai-api-python repo | |
git clone https://github.com/openai/openai-python.git -b $OPENAI_API_PYTHON_TAG | |
cd openai-python | |
pip install -r requirements-dev.lock | |
pip install pytest-reportportal pytest-html | |
mv ../coverage/conftest.py tests/conftest.py | |
mv ../coverage/endpoint_mapping.json tests/endpoints_mapping.json | |
mv ../coverage/pytest.ini pytest.ini | |
echo "rp_api_key = ${{ secrets.RP_API_KEY }}" >> pytest.ini | |
echo "rp_endpoint = ${{ secrets.RP_ENDPOINT }}" >> pytest.ini | |
pytest --continue-on-collection-errors --endpoint "$ENDPOINTS" --reportportal --html=report.html -v | |
kill $cortex_pid | |
env: | |
ENDPOINTS: ${{ github.event.inputs.endpoints }} | |
- name: Collect RP artifacts | |
run: | | |
wget --no-verbose -O total-coverage.json "${{ secrets.RP_ENDPOINT }}/api/v1/openai-api-test/widget/27" --header 'authorization: bearer ${{ secrets.RP_API_KEY }}' | |
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 }}' | |
echo "Overall coverage" | |
cat total-coverage.json | |
current_date=$(date +"%m-%d-%Y") | |
cp today-endpoint.json $current_date.json | |
echo "Endpoint today" | |
cat $current_date.json | |
- name: Upload report json files to S3 | |
run: | | |
current_date=$(date +"%m-%d-%Y") | |
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "openai-api-collection-test/$current_date.json" --body "./$current_date.json" --content-type "application/json" | |
aws s3api put-object --endpoint-url https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com --bucket ${{ secrets.CLOUDFLARE_R2_BUCKET_NAME }} --key "openai-api-collection-test/total-coverage.json" --body "./total-coverage.json" --content-type "application/json" | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: auto | |
AWS_EC2_METADATA_DISABLED: "true" | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: report | |
path: | | |
openai-python/report.html | |
openai-python/cortex.log | |
openai-python/total-coverage.json | |
openai-python/today-endpoint.json | |
api.json | |
- name: Clean up | |
if: always() | |
run: | | |
rm -rf /tmp/jan | |
rm -rf openai-python | |
rm -rf report.html | |
rm -rf report.zip | |