Skip to content

Commit 3f920f8

Browse files
chore: setting up ci for formatting checks and testing.
1 parent 7de3549 commit 3f920f8

File tree

2 files changed

+141
-0
lines changed

2 files changed

+141
-0
lines changed

.github/ruff.toml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Ruff configuration for CI/CD
2+
line-length = 88
3+
target-version = "py37"
4+
5+
[lint]
6+
select = [
7+
"E", # pycodestyle errors
8+
"W", # pycodestyle warnings
9+
"F", # pyflakes
10+
"I", # isort
11+
"B", # flake8-bugbear
12+
"C4", # flake8-comprehensions
13+
"UP", # pyupgrade
14+
]
15+
ignore = [
16+
"E501", # line too long (handled by formatter)
17+
"B008", # do not perform function calls in argument defaults
18+
]
19+
20+
[format]
21+
quote-style = "double"
22+
indent-style = "space"
23+
skip-magic-trailing-comma = false
24+
line-ending = "auto"

.github/workflows/ci.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
ruff-format-check:
11+
name: Ruff Format Check - ${{ matrix.file }}
12+
runs-on: ubuntu-latest
13+
strategy:
14+
fail-fast: false
15+
matrix:
16+
file:
17+
- __init__.py
18+
- _config.py
19+
- _types.py
20+
- async_request.py
21+
- audio.py
22+
- classification.py
23+
- embedding_v2.py
24+
- embedding.py
25+
- exceptions.py
26+
- helpers.py
27+
- image_generation.py
28+
- prediction.py
29+
- prompt_engine.py
30+
- request.py
31+
- search.py
32+
- sentiment.py
33+
- sql.py
34+
- store.py
35+
- summary.py
36+
- translate.py
37+
- validate.py
38+
- vision.py
39+
- web.py
40+
steps:
41+
- uses: actions/checkout@v4
42+
43+
- name: Set up Python
44+
uses: actions/setup-python@v4
45+
with:
46+
python-version: '3.12'
47+
48+
- name: Install ruff
49+
run: pip install ruff
50+
51+
- name: Check formatting for ${{ matrix.file }}
52+
run: |
53+
ruff check jigsawstack/${{ matrix.file }} --select I,F,E,W
54+
ruff format --check jigsawstack/${{ matrix.file }}
55+
56+
test:
57+
name: Test - ${{ matrix.test-file }}
58+
runs-on: ubuntu-latest
59+
strategy:
60+
fail-fast: false
61+
matrix:
62+
test-file:
63+
- test_audio.py
64+
- test_classification.py
65+
- test_embedding.py
66+
- test_file_store.py
67+
- test_geo.py
68+
- test_image_generation.py
69+
- test_object_detection.py
70+
- test_prediction.py
71+
- test_sentiment.py
72+
- test_sql.py
73+
- test_summary.py
74+
- test_translate.py
75+
- test_validate.py
76+
- test_vision.py
77+
- test_web.py
78+
steps:
79+
- uses: actions/checkout@v4
80+
81+
- name: Set up Python
82+
uses: actions/setup-python@v4
83+
with:
84+
python-version: '3.12'
85+
86+
- name: Install dependencies
87+
run: |
88+
python -m pip install --upgrade pip
89+
pip install -r requirements.txt
90+
pip install pytest pytest-asyncio pytest-cov
91+
pip install -e .
92+
93+
- name: Run test ${{ matrix.test-file }}
94+
env:
95+
JIGSAWSTACK_API_KEY: ${{ secrets.JIGSAWSTACK_API_KEY }}
96+
run: |
97+
pytest tests/${{ matrix.test-file }} -v
98+
continue-on-error: true
99+
100+
- name: Check if critical tests passed
101+
if: contains(matrix.test-file, 'test_') && !contains(matrix.test-file, 'skip')
102+
run: |
103+
pytest tests/${{ matrix.test-file }} -v -m "not skip"
104+
105+
all-checks-passed:
106+
name: All Checks Passed
107+
needs: [ruff-format-check, test]
108+
runs-on: ubuntu-latest
109+
if: always()
110+
steps:
111+
- name: Check if all jobs passed
112+
run: |
113+
if [[ "${{ needs.ruff-format-check.result }}" != "success" || "${{ needs.test.result }}" != "success" ]]; then
114+
echo "One or more checks failed"
115+
exit 1
116+
fi
117+
echo "All checks passed successfully!"

0 commit comments

Comments
 (0)