-
Notifications
You must be signed in to change notification settings - Fork 19
129 lines (106 loc) · 3.92 KB
/
Copy pathtest.yml
File metadata and controls
129 lines (106 loc) · 3.92 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
name: Tests
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
schedule:
- cron: '0 2 * * *'
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pytest pytest-cov
- name: Test package import
run: |
python -c "import brightdata; print('Import successful')"
- name: Run tests
run: |
python -m pytest tests/ -v --cov=brightdata --cov-report=xml
- name: Upload coverage to Codecov
if: matrix.python-version == '3.8'
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
test-pypi-package:
runs-on: ubuntu-latest
if: github.event_name == 'schedule'
strategy:
matrix:
python-version: ['3.8', '3.11']
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install PyPI package
run: |
python -m pip install --upgrade pip
pip install brightdata-sdk
pip install pytest
- name: Test PyPI package import
run: |
python -c "import brightdata; print('PyPI package import successful')"
python -c "from brightdata import bdclient; print('bdclient import successful')"
- name: Test PyPI package basic functionality
run: |
python -c "
import sys
from brightdata import bdclient, __version__
print(f'PyPI package version: {__version__}')
# Test that validation works (accept any validation error as success)
try:
client = bdclient(api_token='test_token_too_short')
print('WARNING: No validation error - this might indicate an issue')
except Exception as e:
print(f'Validation error caught: {str(e)[:100]}...')
print('PyPI package validation working correctly')
# Test basic client creation with disabled auto-zone creation
try:
client = bdclient(api_token='test_token_123456789', auto_create_zones=False)
print('Client creation successful')
# Test that basic methods exist
methods = ['scrape', 'search', 'download_content']
for method in methods:
if hasattr(client, method):
print(f'Method {method} exists')
else:
print(f'Method {method} missing (might be version difference)')
except Exception as e:
print(f'ERROR: Client creation failed: {e}')
sys.exit(1)
print('PyPI package basic functionality test completed')
"
- name: Test PyPI package compatibility
run: |
python -c "
print('Running PyPI package compatibility tests...')
# Test import compatibility
try:
from brightdata import bdclient, __version__
from brightdata.exceptions import ValidationError
print('Core imports working')
except ImportError as e:
print(f'ERROR: Import failed: {e}')
exit(1)
# Test that client requires token
try:
client = bdclient() # Should fail without token
print('WARNING: Client created without token - unexpected')
except Exception:
print('Token requirement validated')
print('PyPI package compatibility tests completed')
"