@@ -75,13 +75,10 @@ jobs:
75
75
flags : unit
76
76
name : unit-tests
77
77
78
- test-integration :
79
- name : Integration Tests
78
+ test-integration-local :
79
+ name : Integration Tests (Local)
80
80
runs-on : ubuntu-latest
81
81
needs : test-unit
82
- strategy :
83
- matrix :
84
- test-category : ["api", "browser", "end_to_end"]
85
82
86
83
steps :
87
84
- uses : actions/checkout@v4
91
88
with :
92
89
python-version : " 3.11"
93
90
91
+ - name : Install system dependencies
92
+ run : |
93
+ sudo apt-get update
94
+ sudo apt-get install -y xvfb
95
+
94
96
- name : Install dependencies
95
97
run : |
96
98
python -m pip install --upgrade pip
@@ -100,43 +102,94 @@ jobs:
100
102
pip install temp/google_genai-1.14.0-py3-none-any.whl
101
103
# Install Playwright browsers for integration tests
102
104
playwright install chromium
105
+ playwright install-deps chromium
103
106
104
- - name : Run integration tests - ${{ matrix.test-category }}
107
+ - name : Run local integration tests
105
108
run : |
106
- # Check if test directory exists and has test files before running pytest
107
- if [ -d "tests/integration/${{ matrix.test-category }}" ] && find "tests/integration/${{ matrix.test-category }}" -name "test_*.py" -o -name "*_test.py" | grep -q .; then
108
- pytest tests/integration/${{ matrix.test-category }}/ -v \
109
- --cov=stagehand \
110
- --cov-report=xml \
111
- --junit-xml=junit-integration-${{ matrix.test-category }}.xml
112
- else
113
- echo "No test files found in tests/integration/${{ matrix.test-category }}/, skipping..."
114
- # Create empty junit file to prevent workflow failure
115
- echo '<?xml version="1.0" encoding="utf-8"?><testsuites><testsuite name="pytest" errors="0" failures="0" skipped="0" tests="0" time="0" timestamp="$(date -Iseconds)" hostname="$(hostname)"></testsuite></testsuites>' > junit-integration-${{ matrix.test-category }}.xml
116
- fi
109
+ # Run integration tests marked as 'local' and not 'slow'
110
+ xvfb-run -a pytest tests/integration/ -v \
111
+ --cov=stagehand \
112
+ --cov-report=xml \
113
+ --junit-xml=junit-integration-local.xml \
114
+ -m "local and not slow" \
115
+ --tb=short \
116
+ --maxfail=5
117
117
env :
118
- # Mock environment variables for testing
119
- BROWSERBASE_API_KEY : ${{ secrets.BROWSERBASE_API_KEY || 'mock-api-key' }}
120
- BROWSERBASE_PROJECT_ID : ${{ secrets.BROWSERBASE_PROJECT_ID || 'mock-project-id' }}
121
118
MODEL_API_KEY : ${{ secrets.MODEL_API_KEY || 'mock-model-key' }}
122
- STAGEHAND_API_URL : " http://localhost:3000"
119
+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY || 'mock-openai-key' }}
120
+ DISPLAY : " :99"
123
121
124
122
- name : Upload integration test results
125
123
uses : actions/upload-artifact@v4
126
124
if : always()
127
125
with :
128
- name : integration-test-results-${{ matrix.test-category }}
129
- path : junit-integration-${{ matrix.test-category }} .xml
126
+ name : integration-test-results-local
127
+ path : junit-integration-local .xml
130
128
131
129
- name : Upload coverage data
132
130
uses : actions/upload-artifact@v4
133
131
if : always()
134
132
with :
135
- name : coverage-data-integration-${{ matrix.test-category }}
133
+ name : coverage-data-integration-local
136
134
path : |
137
135
.coverage
138
136
coverage.xml
139
137
138
+ test-integration-slow :
139
+ name : Integration Tests (Slow)
140
+ runs-on : ubuntu-latest
141
+ needs : test-unit
142
+ if : |
143
+ contains(github.event.pull_request.labels.*.name, 'test-slow') ||
144
+ contains(github.event.pull_request.labels.*.name, 'slow') ||
145
+ github.event_name == 'schedule'
146
+
147
+ steps :
148
+ - uses : actions/checkout@v4
149
+
150
+ - name : Set up Python 3.11
151
+ uses : actions/setup-python@v4
152
+ with :
153
+ python-version : " 3.11"
154
+
155
+ - name : Install system dependencies
156
+ run : |
157
+ sudo apt-get update
158
+ sudo apt-get install -y xvfb
159
+
160
+ - name : Install dependencies
161
+ run : |
162
+ python -m pip install --upgrade pip
163
+ pip install -e ".[dev]"
164
+ pip install jsonschema
165
+ # Install temporary Google GenAI wheel
166
+ pip install temp/google_genai-1.14.0-py3-none-any.whl
167
+ # Install Playwright browsers for integration tests
168
+ playwright install chromium
169
+ playwright install-deps chromium
170
+
171
+ - name : Run slow integration tests
172
+ run : |
173
+ # Run integration tests marked as 'slow' and 'local'
174
+ xvfb-run -a pytest tests/integration/ -v \
175
+ --cov=stagehand \
176
+ --cov-report=xml \
177
+ --junit-xml=junit-integration-slow.xml \
178
+ -m "slow and local" \
179
+ --tb=short \
180
+ --maxfail=3
181
+ env :
182
+ MODEL_API_KEY : ${{ secrets.MODEL_API_KEY || 'mock-model-key' }}
183
+ OPENAI_API_KEY : ${{ secrets.OPENAI_API_KEY || 'mock-openai-key' }}
184
+ DISPLAY : " :99"
185
+
186
+ - name : Upload slow test results
187
+ uses : actions/upload-artifact@v4
188
+ if : always()
189
+ with :
190
+ name : integration-test-results-slow
191
+ path : junit-integration-slow.xml
192
+
140
193
test-browserbase :
141
194
name : Browserbase Integration Tests
142
195
runs-on : ubuntu-latest
@@ -449,7 +502,7 @@ jobs:
449
502
coverage-report :
450
503
name : Coverage Report
451
504
runs-on : ubuntu-latest
452
- needs : [test-unit, test-integration]
505
+ needs : [test-unit, test-integration-local ]
453
506
if : always() && (needs.test-unit.result == 'success')
454
507
455
508
steps :
@@ -514,7 +567,7 @@ jobs:
514
567
test-summary :
515
568
name : Test Summary
516
569
runs-on : ubuntu-latest
517
- needs : [test-unit, test-integration, smoke-tests]
570
+ needs : [test-unit, test-integration-local , smoke-tests]
518
571
if : always()
519
572
520
573
steps :
0 commit comments