-
Notifications
You must be signed in to change notification settings - Fork 4
154 lines (138 loc) · 4.22 KB
/
ci.yml
File metadata and controls
154 lines (138 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
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@v4
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@v4
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