Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 133 additions & 0 deletions .github/workflows/midscene.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Midscene E2E

on:
workflow_dispatch:
push:
branches: [main, test/midscene]
paths:
- src/**
- static/**
- prisma/schema.prisma
- tests/midscene/**
- package.json
- pnpm-lock.yaml
- pnpm-workspace.yaml
- vite.config.ts
- .github/workflows/midscene.yml

permissions:
contents: read

concurrency:
group: midscene-${{ github.ref }}
cancel-in-progress: false

jobs:
browser:
if: vars.MIDSCENE_E2E_ENABLED == 'true'
runs-on: ubuntu-24.04
timeout-minutes: 30
services:
mysql:
image: mysql:8.4
env:
MYSQL_ROOT_PASSWORD: syntax
MYSQL_DATABASE: syntax_midscene
ports: ['3306:3306']
options: >-
--health-cmd="mysqladmin ping -h 127.0.0.1 -psyntax"
--health-interval=10s --health-timeout=5s --health-retries=10
env:
DATABASE_URL: mysql://root:syntax@127.0.0.1:3306/syntax_midscene
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22.22.0
cache: pnpm
- run: pnpm install --frozen-lockfile --registry=https://registry.npmjs.org
- run: cp .env.example .env
- run: pnpm db:push && pnpm db:generate && pnpm test:midscene:seed
- run: pnpm test:midscene:check
- run: pnpm check
- run: pnpm exec vitest run
- run: pnpm lint
- run: pnpm build
- run: pnpm exec playwright install --with-deps chromium
- name: Run browser workflows
id: tests
timeout-minutes: 22
env:
BROWSER_CHANNEL: chromium
MIDSCENE_MODEL_NAME: ${{ vars.MIDSCENE_MODEL_NAME }}
MIDSCENE_MODEL_FAMILY: ${{ vars.MIDSCENE_MODEL_FAMILY }}
MIDSCENE_MODEL_PROTOCOL: ${{ vars.MIDSCENE_MODEL_PROTOCOL }}
MIDSCENE_MODEL_BASE_URL: ${{ vars.MIDSCENE_MODEL_BASE_URL }}
MIDSCENE_MODEL_REASONING_EFFORT: ${{ vars.MIDSCENE_MODEL_REASONING_EFFORT }}
MIDSCENE_MODEL_API_KEY: ${{ secrets.MIDSCENE_MODEL_API_KEY }}
run: |
for name in MIDSCENE_MODEL_NAME MIDSCENE_MODEL_FAMILY MIDSCENE_MODEL_BASE_URL MIDSCENE_MODEL_API_KEY; do
if [ -z "${!name}" ]; then
echo "::error::Missing $name"
exit 1
fi
done
pnpm test:midscene
- name: Preserve reports and screenshots
id: artifacts
if: ${{ always() && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
uses: actions/upload-artifact@v4
with:
name: midscene-report-${{ github.run_attempt }}
path: |
tests/midscene/midscene_run/
tests/midscene/.midscene/test-results/
include-hidden-files: true
if-no-files-found: warn
retention-days: 14
- name: Locate report for Cloudflare Pages
id: report
if: ${{ always() && vars.MIDSCENE_PAGES_PROJECT != '' && (steps.tests.outcome == 'success' || steps.tests.outcome == 'failure') }}
run: |
mkdir -p "$RUNNER_TEMP/midscene-publish"
shopt -s nullglob
reports=(tests/midscene/midscene_run/report/midscene-e2e-*/index.html)
if [ "${#reports[@]}" -ne 1 ]; then
echo "::error::Expected exactly one Midscene HTML report"
exit 1
fi
echo "directory=${reports[0]%/index.html}" >> "$GITHUB_OUTPUT"
- name: Publish interactive report
id: deploy
if: ${{ always() && steps.report.outcome == 'success' }}
uses: cloudflare/wrangler-action@953926a2e2182532811c01a25e53647d93bf07c0 # v4
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
wranglerVersion: '4.151.1'
packageManager: npm
workingDirectory: ${{ runner.temp }}/midscene-publish
command: pages deploy "${{ github.workspace }}/${{ steps.report.outputs.directory }}" --project-name=${{ vars.MIDSCENE_PAGES_PROJECT }} --branch=run-${{ github.run_id }}-${{ github.run_attempt }} --commit-hash=${{ github.sha }}
- name: Write report links to Summary
if: always()
env:
TEST_OUTCOME: ${{ steps.tests.outcome }}
REPORT_URL: ${{ steps.deploy.outputs.deployment-url }}
ARTIFACT_URL: ${{ steps.artifacts.outputs.artifact-url }}
run: |
{
echo '## Midscene E2E report'
echo "Revision: $GITHUB_SHA"
echo "Test outcome: ${TEST_OUTCOME:-not run}"
if [ -n "$REPORT_URL" ]; then
echo "[Open interactive HTML report]($REPORT_URL)"
else
echo 'Online report unavailable. Check the publishing steps and download the artifacts below.'
fi
if [ -n "$ARTIFACT_URL" ]; then
echo "[Download reports and screenshots]($ARTIFACT_URL)"
fi
} >> "$GITHUB_STEP_SUMMARY"
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ bin
db-data

core.wasm
core.worker.cjs
core.worker.cjs

# Midscene browser reports
tests/midscene/**/midscene_run/
tests/midscene/**/.midscene/
tests/midscene/midscene-node-spec.*.md
8 changes: 7 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
"db:seed": "prisma db seed",
"i-changed-the-schema": "pnpm run db:push && pnpm run db:generate",
"postinstall": "pnpm db:generate && pnpm exec playwright install",
"stylelint": "NODE_OPTIONS=--no-deprecation stylelint \"**/*.css\""
"stylelint": "NODE_OPTIONS=--no-deprecation stylelint \"**/*.css\"",
"test:midscene:seed": "node tests/midscene/seed.mjs",
"test:midscene:check": "tsc -p tests/midscene/tsconfig.json && cd tests/midscene && midscene-test nodes",
"test:midscene": "cd tests/midscene && midscene-test --config midscene.config.ts"
},
"devDependencies": {
"@codecov/sveltekit-plugin": "^2.0.1",
"@eslint/compat": "^2.1.1",
"@eslint/js": "^10.0.1",
"@midscene/test": "1.16.5",
"@midscene/web": "1.16.5",
"@playwright/test": "^1.64.1",
"@sveltejs/kit": "^3.1.0",
"@sveltejs/vite-plugin-svelte": "^7.3.1",
Expand All @@ -44,6 +49,7 @@
"eslint": "^10.13.0",
"globals": "^17.13.0",
"mysql2": "^3.14.1",
"playwright": "1.64.1",
"postcss": "^8.5.6",
"postcss-import": "^17.0.1",
"postcss-preset-env": "^11.6.1",
Expand Down
Loading