Skip to content

Commit ab0da22

Browse files
committed
feat: add tests
1 parent 2ef8826 commit ab0da22

14 files changed

Lines changed: 3238 additions & 0 deletions

.github/workflows/test-suite.yml

Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
name: Test Suite
2+
3+
on:
4+
push:
5+
branches: [main, pre/beta, dev]
6+
pull_request:
7+
branches: [main, pre/beta]
8+
workflow_dispatch:
9+
10+
jobs:
11+
unit-tests:
12+
name: Unit Tests (Python ${{ matrix.python-version }})
13+
runs-on: ${{ matrix.os }}
14+
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest, macos-latest, windows-latest]
19+
python-version: ['3.10', '3.11', '3.12']
20+
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Python ${{ matrix.python-version }}
26+
uses: actions/setup-python@v5
27+
with:
28+
python-version: ${{ matrix.python-version }}
29+
30+
- name: Install uv
31+
uses: astral-sh/setup-uv@v4
32+
33+
- name: Install dependencies
34+
run: |
35+
uv sync
36+
37+
- name: Install Playwright browsers
38+
run: |
39+
uv run playwright install chromium
40+
41+
- name: Run unit tests
42+
run: |
43+
uv run pytest tests/ -m "unit or not integration" --cov --cov-report=xml --cov-report=term
44+
45+
- name: Upload coverage to Codecov
46+
uses: codecov/codecov-action@v4
47+
with:
48+
file: ./coverage.xml
49+
flags: unittests
50+
name: codecov-${{ matrix.os }}-py${{ matrix.python-version }}
51+
token: ${{ secrets.CODECOV_TOKEN }}
52+
if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.11'
53+
54+
integration-tests:
55+
name: Integration Tests
56+
runs-on: ubuntu-latest
57+
58+
strategy:
59+
fail-fast: false
60+
matrix:
61+
test-group: [smart-scraper, multi-graph, file-formats]
62+
63+
steps:
64+
- name: Checkout code
65+
uses: actions/checkout@v4
66+
67+
- name: Set up Python
68+
uses: actions/setup-python@v5
69+
with:
70+
python-version: '3.11'
71+
72+
- name: Install uv
73+
uses: astral-sh/setup-uv@v4
74+
75+
- name: Install dependencies
76+
run: |
77+
uv sync
78+
79+
- name: Install Playwright browsers
80+
run: |
81+
uv run playwright install chromium
82+
83+
- name: Run integration tests
84+
env:
85+
OPENAI_APIKEY: ${{ secrets.OPENAI_APIKEY }}
86+
ANTHROPIC_APIKEY: ${{ secrets.ANTHROPIC_APIKEY }}
87+
GROQ_APIKEY: ${{ secrets.GROQ_APIKEY }}
88+
run: |
89+
uv run pytest tests/integration/ -m integration --integration -v
90+
91+
- name: Upload test results
92+
uses: actions/upload-artifact@v4
93+
if: always()
94+
with:
95+
name: integration-test-results-${{ matrix.test-group }}
96+
path: |
97+
htmlcov/
98+
benchmark_results/
99+
100+
benchmark-tests:
101+
name: Performance Benchmarks
102+
runs-on: ubuntu-latest
103+
104+
steps:
105+
- name: Checkout code
106+
uses: actions/checkout@v4
107+
108+
- name: Set up Python
109+
uses: actions/setup-python@v5
110+
with:
111+
python-version: '3.11'
112+
113+
- name: Install uv
114+
uses: astral-sh/setup-uv@v4
115+
116+
- name: Install dependencies
117+
run: |
118+
uv sync
119+
120+
- name: Install Playwright browsers
121+
run: |
122+
uv run playwright install chromium
123+
124+
- name: Run performance benchmarks
125+
env:
126+
OPENAI_APIKEY: ${{ secrets.OPENAI_APIKEY }}
127+
run: |
128+
uv run pytest tests/ -m benchmark --benchmark -v
129+
130+
- name: Upload benchmark results
131+
uses: actions/upload-artifact@v4
132+
with:
133+
name: benchmark-results
134+
path: benchmark_results/
135+
136+
- name: Compare with baseline
137+
if: github.event_name == 'pull_request'
138+
run: |
139+
# Download baseline from main branch
140+
# Compare and comment on PR if regression detected
141+
echo "Benchmark comparison would run here"
142+
143+
code-quality:
144+
name: Code Quality Checks
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Set up Python
152+
uses: actions/setup-python@v5
153+
with:
154+
python-version: '3.11'
155+
156+
- name: Install uv
157+
uses: astral-sh/setup-uv@v4
158+
159+
- name: Install dependencies
160+
run: |
161+
uv sync
162+
163+
- name: Run Ruff linting
164+
run: |
165+
uv run ruff check scrapegraphai/ tests/
166+
167+
- name: Run Black formatting check
168+
run: |
169+
uv run black --check scrapegraphai/ tests/
170+
171+
- name: Run isort check
172+
run: |
173+
uv run isort --check-only scrapegraphai/ tests/
174+
175+
- name: Run type checking with mypy
176+
run: |
177+
uv run mypy scrapegraphai/
178+
continue-on-error: true
179+
180+
test-coverage-report:
181+
name: Test Coverage Report
182+
needs: [unit-tests, integration-tests]
183+
runs-on: ubuntu-latest
184+
if: always()
185+
186+
steps:
187+
- name: Checkout code
188+
uses: actions/checkout@v4
189+
190+
- name: Download coverage artifacts
191+
uses: actions/download-artifact@v4
192+
193+
- name: Generate coverage report
194+
run: |
195+
echo "Coverage report generation would run here"
196+
197+
- name: Comment coverage on PR
198+
if: github.event_name == 'pull_request'
199+
uses: py-cov-action/python-coverage-comment-action@v3
200+
with:
201+
GITHUB_TOKEN: ${{ github.token }}
202+
203+
test-summary:
204+
name: Test Summary
205+
needs: [unit-tests, integration-tests, code-quality]
206+
runs-on: ubuntu-latest
207+
if: always()
208+
209+
steps:
210+
- name: Check test results
211+
run: |
212+
echo "All test jobs completed"
213+
echo "Unit tests: ${{ needs.unit-tests.result }}"
214+
echo "Integration tests: ${{ needs.integration-tests.result }}"
215+
echo "Code quality: ${{ needs.code-quality.result }}"

0 commit comments

Comments
 (0)