1+ name : Test Python SDK
2+
3+ on :
4+ push :
5+ branches : [ main, master ]
6+ pull_request :
7+ branches : [ main, master ]
8+
9+ jobs :
10+ test :
11+ runs-on : ubuntu-latest
12+ strategy :
13+ matrix :
14+ python-version : ["3.8", "3.9", "3.10", "3.11", "3.12"]
15+
16+ steps :
17+ - uses : actions/checkout@v4
18+
19+ - name : Set up Python ${{ matrix.python-version }}
20+ uses : actions/setup-python@v4
21+ with :
22+ python-version : ${{ matrix.python-version }}
23+
24+ - name : Cache pip dependencies
25+ uses : actions/cache@v3
26+ with :
27+ path : ~/.cache/pip
28+ key : ${{ runner.os }}-pip-${{ matrix.python-version }}-${{ hashFiles('**/pyproject.toml') }}
29+ restore-keys : |
30+ ${{ runner.os }}-pip-${{ matrix.python-version }}-
31+
32+ - name : Install dependencies
33+ run : |
34+ python -m pip install --upgrade pip
35+ pip install pytest pytest-asyncio responses
36+ cd scrapegraph-py
37+ pip install -e .
38+
39+ - name : Run tests with coverage
40+ run : |
41+ cd scrapegraph-py
42+ python -m pytest tests/ -v --cov=scrapegraph_py --cov-report=xml --cov-report=term-missing
43+
44+ - name : Run real API tests (if API key available)
45+ run : |
46+ cd scrapegraph-py
47+ if [ -n "$SGAI_API_KEY" ]; then
48+ python -m pytest tests/test_real_apis.py -v --tb=short
49+ else
50+ echo "SGAI_API_KEY not set, skipping real API tests"
51+ fi
52+ env :
53+ SGAI_API_KEY : ${{ secrets.SGAI_API_KEY }}
54+
55+ - name : Upload coverage to Codecov
56+ uses : codecov/codecov-action@v3
57+ with :
58+ file : ./scrapegraph-py/coverage.xml
59+ flags : unittests
60+ name : codecov-umbrella
61+ fail_ci_if_error : false
62+
63+ lint :
64+ runs-on : ubuntu-latest
65+
66+ steps :
67+ - uses : actions/checkout@v4
68+
69+ - name : Set up Python
70+ uses : actions/setup-python@v4
71+ with :
72+ python-version : " 3.11"
73+
74+ - name : Install dependencies
75+ run : |
76+ python -m pip install --upgrade pip
77+ pip install flake8 black isort mypy
78+ cd scrapegraph-py
79+ pip install -e .
80+
81+ - name : Run linting
82+ run : |
83+ cd scrapegraph-py
84+ flake8 scrapegraph_py/ tests/ --max-line-length=88 --extend-ignore=E203,W503
85+ black --check scrapegraph_py/ tests/
86+ isort --check-only scrapegraph_py/ tests/
87+ mypy scrapegraph_py/ --ignore-missing-imports
88+
89+ security :
90+ runs-on : ubuntu-latest
91+
92+ steps :
93+ - uses : actions/checkout@v4
94+
95+ - name : Set up Python
96+ uses : actions/setup-python@v4
97+ with :
98+ python-version : " 3.11"
99+
100+ - name : Install dependencies
101+ run : |
102+ python -m pip install --upgrade pip
103+ pip install bandit safety
104+ cd scrapegraph-py
105+ pip install -e .
106+
107+ - name : Run security checks
108+ run : |
109+ cd scrapegraph-py
110+ bandit -r scrapegraph_py/ -f json -o bandit-report.json || true
111+ safety check --json --output safety-report.json || true
0 commit comments