Skip to content

Commit af9e033

Browse files
first pass on integration tests
1 parent 6a7c449 commit af9e033

File tree

7 files changed

+2360
-26
lines changed

7 files changed

+2360
-26
lines changed

.github/workflows/test.yml

Lines changed: 79 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,10 @@ jobs:
7575
flags: unit
7676
name: unit-tests
7777

78-
test-integration:
79-
name: Integration Tests
78+
test-integration-local:
79+
name: Integration Tests (Local)
8080
runs-on: ubuntu-latest
8181
needs: test-unit
82-
strategy:
83-
matrix:
84-
test-category: ["api", "browser", "end_to_end"]
8582

8683
steps:
8784
- uses: actions/checkout@v4
@@ -91,6 +88,11 @@ jobs:
9188
with:
9289
python-version: "3.11"
9390

91+
- name: Install system dependencies
92+
run: |
93+
sudo apt-get update
94+
sudo apt-get install -y xvfb
95+
9496
- name: Install dependencies
9597
run: |
9698
python -m pip install --upgrade pip
@@ -100,43 +102,94 @@ jobs:
100102
pip install temp/google_genai-1.14.0-py3-none-any.whl
101103
# Install Playwright browsers for integration tests
102104
playwright install chromium
105+
playwright install-deps chromium
103106
104-
- name: Run integration tests - ${{ matrix.test-category }}
107+
- name: Run local integration tests
105108
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
117117
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' }}
121118
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"
123121

124122
- name: Upload integration test results
125123
uses: actions/upload-artifact@v4
126124
if: always()
127125
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
130128

131129
- name: Upload coverage data
132130
uses: actions/upload-artifact@v4
133131
if: always()
134132
with:
135-
name: coverage-data-integration-${{ matrix.test-category }}
133+
name: coverage-data-integration-local
136134
path: |
137135
.coverage
138136
coverage.xml
139137
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+
140193
test-browserbase:
141194
name: Browserbase Integration Tests
142195
runs-on: ubuntu-latest
@@ -449,7 +502,7 @@ jobs:
449502
coverage-report:
450503
name: Coverage Report
451504
runs-on: ubuntu-latest
452-
needs: [test-unit, test-integration]
505+
needs: [test-unit, test-integration-local]
453506
if: always() && (needs.test-unit.result == 'success')
454507

455508
steps:
@@ -514,7 +567,7 @@ jobs:
514567
test-summary:
515568
name: Test Summary
516569
runs-on: ubuntu-latest
517-
needs: [test-unit, test-integration, smoke-tests]
570+
needs: [test-unit, test-integration-local, smoke-tests]
518571
if: always()
519572

520573
steps:

0 commit comments

Comments
 (0)