Skip to content
Merged
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
27 changes: 26 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unit Test
name: CI

on:
push:
Expand All @@ -13,6 +13,31 @@ jobs:
unit-test:
uses: sxzz/workflows/.github/workflows/unit-test.yml@main

e2e:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Cache Playwright browsers
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ hashFiles('pnpm-lock.yaml') }}
- run: pnpm exec playwright install --with-deps chromium
- run: pnpm test:e2e
- if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: playwright-report/
retention-days: 7

# coverage:
# uses: sxzz/workflows/.github/workflows/coverage.yml@main
# needs: unit-test
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ temp
**/.vitepress/cache
**/.vitepress/dist
packages/devframe/skills
test-results
playwright-report
playwright/.cache
blob-report
1 change: 0 additions & 1 deletion docs/guide/built-with.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,5 @@ Real-world devtools shipping on Devframe:

End-to-end examples in this repo, exercising the full adapter surface:

- [**counter**](https://github.com/devframes/devframe/tree/main/examples/counter) — smallest possible demo, exercises all adapters.
- [**files-inspector**](https://github.com/devframes/devframe/tree/main/examples/files-inspector) — lists files in cwd via RPC; exercises CLI dev/build/spa surfaces.
- [**streaming-chat**](https://github.com/devframes/devframe/tree/main/examples/streaming-chat) — streams synthetic chat tokens from server to client via `ctx.rpc.streaming`.
14 changes: 0 additions & 14 deletions examples/counter/bin.mjs

This file was deleted.

18 changes: 0 additions & 18 deletions examples/counter/package.json

This file was deleted.

13 changes: 0 additions & 13 deletions examples/counter/src/client/index.html

This file was deleted.

21 changes: 0 additions & 21 deletions examples/counter/src/client/main.ts

This file was deleted.

77 changes: 0 additions & 77 deletions examples/counter/src/devframe.ts

This file was deleted.

7 changes: 5 additions & 2 deletions examples/files-inspector/src/devframe.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { defineRpcFunction } from 'devframe'
import { defineDevframe } from 'devframe/types'
Expand All @@ -18,19 +19,21 @@ export default defineDevframe({
},
spa: { loader: 'none' },
async setup(ctx) {
const targetCwd = process.env.DEVFRAME_E2E_CWD || ctx.cwd

ctx.rpc.register(defineRpcFunction({
name: 'devframe-files-inspector:get-cwd',
type: 'static',
jsonSerializable: true,
handler: () => ({ cwd: ctx.cwd }),
handler: () => ({ cwd: targetCwd }),
}))

ctx.rpc.register(defineRpcFunction({
name: 'devframe-files-inspector:list-files',
type: 'query',
jsonSerializable: true,
handler: async () => {
const files = await glob(['*'], { cwd: ctx.cwd, onlyFiles: true, dot: false })
const files = await glob(['*'], { cwd: targetCwd, onlyFiles: true, dot: false })
return files.map(f => f.replace(/\\/g, '/')).sort()
},
snapshot: true,
Expand Down
1 change: 1 addition & 0 deletions examples/streaming-chat/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
},
"scripts": {
"build": "vite build --config src/client/vite.config.ts",
"cli:build": "node bin.mjs build --out-dir dist/static",
"dev": "node bin.mjs",
"test": "vitest run"
},
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
"docs:serve": "pnpm -C docs run docs:serve",
"lint": "eslint --cache",
"test": "turbo run build && vitest",
"test:e2e": "turbo run build && playwright test",
"test:e2e:ui": "turbo run build && playwright test --ui",
"release": "bumpp -r",
"typecheck": "tsc -b",
"postinstall": "npx simple-git-hooks && skills-npm"
Expand All @@ -29,6 +31,7 @@
"@antfu/eslint-config": "catalog:devtools",
"@antfu/ni": "catalog:build",
"@antfu/utils": "catalog:inlined",
"@playwright/test": "catalog:testing",
"@types/node": "catalog:types",
"@types/ws": "catalog:types",
"bumpp": "catalog:devtools",
Expand Down
64 changes: 64 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import process from 'node:process'
import { fileURLToPath } from 'node:url'
import { defineConfig, devices } from '@playwright/test'

const fixtureCwd = fileURLToPath(new URL('./tests/e2e/fixtures', import.meta.url))
const serveStatic = fileURLToPath(new URL('./tests/e2e/_support/serve-static.mjs', import.meta.url))

export default defineConfig({
testDir: './tests/e2e',
testIgnore: ['_support/**'],
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
reporter: process.env.CI ? [['github'], ['html']] : 'list',
use: {
trace: 'on-first-retry',
},
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
],
webServer: [
{
command: 'node bin.mjs',
cwd: 'examples/files-inspector',
env: { DEVFRAME_E2E_CWD: fixtureCwd },
url: 'http://localhost:9876/__devframe-files-inspector/',
timeout: 60_000,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: 'node bin.mjs',
cwd: 'examples/streaming-chat',
url: 'http://localhost:9897/__devframe-streaming-chat/',
timeout: 60_000,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: `node bin.mjs build --out-dir dist/static && node ${JSON.stringify(serveStatic)} dist/static 9886`,
cwd: 'examples/files-inspector',
env: { DEVFRAME_E2E_CWD: fixtureCwd },
url: 'http://127.0.0.1:9886/',
timeout: 60_000,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
},
{
command: `node bin.mjs build --out-dir dist/static && node ${JSON.stringify(serveStatic)} dist/static 9898`,
cwd: 'examples/streaming-chat',
url: 'http://127.0.0.1:9898/',
timeout: 60_000,
reuseExistingServer: !process.env.CI,
stdout: 'pipe',
stderr: 'pipe',
},
],
})
Loading
Loading