Skip to content

remove streaming from experimental in agent #229

remove streaming from experimental in agent

remove streaming from experimental in agent #229

name: Stagehand Server Tests
on:
pull_request:
paths:
- "packages/server/**"
- "packages/core/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- ".github/workflows/stagehand-server-api-tests.yml"
- ".github/workflows/stagehand-server-sea-build.yml"
push:
branches:
- main
paths:
- "packages/server/**"
- "packages/core/**"
- "pnpm-lock.yaml"
- "pnpm-workspace.yaml"
- ".github/workflows/stagehand-server-api-tests.yml"
- ".github/workflows/stagehand-server-sea-build.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: true
jobs:
build-sea:
name: Build SEA binary
uses: ./.github/workflows/stagehand-server-sea-build.yml
with:
matrix: |
[
{"os":"ubuntu-latest","platform":"linux","arch":"x64","binary_name":"stagehand-server-linux-x64"}
]
discover-tests:
name: Discover test files
runs-on: ubuntu-latest
outputs:
unit-tests: ${{ steps.set-matrix.outputs.unit-tests }}
integration-tests: ${{ steps.set-matrix.outputs.integration-tests }}
has-unit-tests: ${{ steps.set-matrix.outputs.has-unit-tests }}
has-integration-tests: ${{ steps.set-matrix.outputs.has-integration-tests }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Discover test files
id: set-matrix
run: |
cd packages/server
unit_tests=$(find ./test/unit -type f -name "*.test.ts" 2>/dev/null | sort || true)
integration_tests=$(find ./test/integration -type f -name "*.test.ts" 2>/dev/null | sort || true)
unit_json="["
first=true
for test_file in $unit_tests; do
if [ "$first" = true ]; then
first=false
else
unit_json+=","
fi
name=$(basename "$test_file" .test.ts)
unit_json+="{\"path\":\"$test_file\",\"name\":\"$name\"}"
done
unit_json+="]"
int_json="["
first=true
for test_file in $integration_tests; do
if [ "$first" = true ]; then
first=false
else
int_json+=","
fi
name=$(echo "$test_file" | sed 's|^\./test/integration/||' | sed 's|\.test\.ts$||')
int_json+="{\"path\":\"$test_file\",\"name\":\"$name\"}"
done
int_json+="]"
echo "unit-tests=$unit_json" >> $GITHUB_OUTPUT
echo "integration-tests=$int_json" >> $GITHUB_OUTPUT
if [ "$unit_json" = "[]" ]; then
echo "has-unit-tests=false" >> $GITHUB_OUTPUT
else
echo "has-unit-tests=true" >> $GITHUB_OUTPUT
fi
if [ "$int_json" = "[]" ]; then
echo "has-integration-tests=false" >> $GITHUB_OUTPUT
else
echo "has-integration-tests=true" >> $GITHUB_OUTPUT
fi
echo "Found unit tests: $unit_json"
echo "Found integration tests: $int_json"
unit-tests:
name: unit/${{ matrix.test.name }}
runs-on: ubuntu-latest
needs: [discover-tests]
if: needs.discover-tests.outputs.has-unit-tests == 'true'
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.discover-tests.outputs.unit-tests) }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Enable Corepack
run: |
npm install -g corepack@latest
corepack enable
- name: Get pnpm store directory
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ runner.arch }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pnpm-store-
- name: Install dependencies (stagehand-server only)
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Run test - ${{ matrix.test.name }}
run: |
cd packages/server
pnpm run node:test "${{ matrix.test.path }}"
integration-tests:
name: integration/${{ matrix.test.name }}
runs-on: ubuntu-latest
needs: [build-sea, discover-tests]
if: needs.discover-tests.outputs.has-integration-tests == 'true'
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.discover-tests.outputs.integration-tests) }}
env:
BB_ENV: local
PORT: "3107"
STAGEHAND_API_URL: http://127.0.0.1:3107
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 1
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
- name: Enable Corepack
run: |
npm install -g corepack@latest
corepack enable
- name: Get pnpm store directory
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: Setup pnpm cache
uses: actions/cache@v4
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-${{ runner.arch }}-pnpm-store-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-pnpm-store-
- name: Install dependencies (stagehand-server only)
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1"
run: |
pnpm install --frozen-lockfile --prefer-offline
- name: Download SEA binary
uses: actions/download-artifact@v4
with:
name: stagehand-server-linux-x64
path: packages/server/dist/sea
- name: Ensure SEA binary is executable
run: |
chmod +x packages/server/dist/sea/stagehand-server-linux-x64
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: |
~/.cache/ms-playwright
key: ${{ runner.os }}-${{ runner.arch }}-playwright-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-${{ runner.arch }}-playwright-
- name: Install Playwright browsers
run: |
pnpm dlx playwright install --with-deps chromium
- name: Start stagehand server (SEA binary)
env:
NODE_ENV: production
run: |
packages/server/dist/sea/stagehand-server-linux-x64 &
echo $! > /tmp/server.pid
echo "Waiting for server to start..."
for i in {1..30}; do
if curl -s http://127.0.0.1:3107/healthz > /dev/null 2>&1; then
echo "Server is ready!"
break
fi
if [ $i -eq 30 ]; then
echo "Server failed to start within 30 seconds"
exit 1
fi
sleep 1
done
- name: Run test - ${{ matrix.test.name }}
run: |
cd packages/server
pnpm run node:test "${{ matrix.test.path }}"
- name: Stop server
if: always()
run: |
if [ -f /tmp/server.pid ]; then
kill $(cat /tmp/server.pid) 2>/dev/null || true
fi