Skip to content

SDK Revamp with CI/CD & Bug Fixes #2

SDK Revamp with CI/CD & Bug Fixes

SDK Revamp with CI/CD & Bug Fixes #2

Workflow file for this run

name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
jobs:
ruff-format-check:
name: Ruff Format Check - ${{ matrix.file }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
file:
- __init__.py
- _config.py
- _types.py
- async_request.py
- audio.py
- classification.py
- embedding_v2.py
- embedding.py
- exceptions.py
- helpers.py
- image_generation.py
- prediction.py
- prompt_engine.py
- request.py
- search.py
- sentiment.py
- sql.py
- store.py
- summary.py
- translate.py
- validate.py
- vision.py
- web.py
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install ruff
run: pip install ruff
- name: Check formatting for ${{ matrix.file }}
run: |
ruff check jigsawstack/${{ matrix.file }} --select I,F,E,W
ruff format --check jigsawstack/${{ matrix.file }}
test:
name: Test - ${{ matrix.test-file }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test-file:
- test_audio.py
- test_classification.py
- test_embedding.py
- test_file_store.py
- test_image_generation.py
- test_object_detection.py
- test_prediction.py
- test_sentiment.py
- test_sql.py
- test_summary.py
- test_translate.py
- test_validate.py
- test_vision.py
- test_web.py
outputs:
test-result: ${{ steps.test-run.outcome }}
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-asyncio pytest-cov
pip install -e .
- name: Run test ${{ matrix.test-file }}
id: test-run
env:
JIGSAWSTACK_API_KEY: ${{ secrets.JIGSAWSTACK_API_KEY }}
run: |
pytest tests/${{ matrix.test-file }} -v --json-report --json-report-file=report.json
- name: Count passed tests
id: count-tests
if: always()
run: |
if [ -f report.json ]; then
PASSED=$(python -c "import json; data=json.load(open('report.json')); print(data.get('summary', {}).get('passed', 0))")
echo "passed-count=$PASSED" >> $GITHUB_OUTPUT
else
echo "passed-count=0" >> $GITHUB_OUTPUT
fi
- name: Upload test results
if: always()
uses: actions/upload-artifact@v3
with:
name: test-results-${{ matrix.test-file }}
path: report.json
all-checks-passed:
name: All Checks Passed
needs: [ruff-format-check, test]
runs-on: ubuntu-latest
if: always()
steps:
- name: Download all test results
uses: actions/download-artifact@v3
with:
path: test-results
- name: Count total passed tests
run: |
TOTAL_PASSED=0
for file in test-results/*/report.json; do
if [ -f "$file" ]; then
PASSED=$(python -c "import json; data=json.load(open('$file')); print(data.get('summary', {}).get('passed', 0))")
TOTAL_PASSED=$((TOTAL_PASSED + PASSED))
fi
done
echo "Total passed tests: $TOTAL_PASSED"
if [ $TOTAL_PASSED -lt 327 ]; then
echo "❌ Insufficient tests passed: $TOTAL_PASSED/327"
exit 1
else
echo "✅ Required tests passed: $TOTAL_PASSED/327"
fi
- name: Check if ruff passed
run: |
if [[ "${{ needs.ruff-format-check.result }}" != "success" ]]; then
echo "Ruff format check failed"
exit 1
fi