Skip to content

Commit 1378b32

Browse files
authored
ci(workflows): the full test case pipeline adds the ability to configure URL addresses (#2809)
1 parent ab0b14b commit 1378b32

File tree

6 files changed

+41
-3
lines changed

6 files changed

+41
-3
lines changed

.github/workflows/test-e2e-all.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
name: E2E Test ALL
2-
run-name: E2E Test All
2+
run-name: E2E Test All origin--${{ inputs.origin }}
33
on:
44
workflow_dispatch:
5+
inputs:
6+
origin:
7+
description: |
8+
输入需要测试的域名地址,包括微服务路径,如果不输入则采用本地启动服务测试,
9+
例如: `https://opentiny.github.io/tiny-vue-web-doc`.
10+
required: false
11+
type: string
512
concurrency:
613
group: ${{ github.workflow }}-${{ github.sha }}
714
cancel-in-progress: true
@@ -37,15 +44,24 @@ jobs:
3744
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
3845
restore-keys: |
3946
${{ runner.os }}-pnpm-store-
47+
4048
- name: Install dependencies
4149
run: pnpm i --no-frozen-lockfile
4250

4351
- name: dev start
52+
if: contains(inputs.origin, 'http') == false
4453
run: pnpm site & sleep 5
54+
55+
- name: Release E2E Config
56+
if: contains(inputs.origin, 'http') == true
57+
run: pnpm release:e2eConfig -o ${{ inputs.origin }}
58+
4559
- name: update playwright
4660
run: pnpm recursive update @playwright/test
61+
4762
- name: Install Playwright browsers
4863
run: pnpm install:browser --with-deps chromium
64+
4965
- name: Run Playwright tests
5066
run: pnpm test:e2e3 --shard=${{ matrix.shard }} --reporter=blob
5167

examples/vue3/playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import Config from '@opentiny-internal/playwright-config'
44
* 本地开发环境链接:'http://localhost:7130/pc/'
55
* 本地官网链接:'http://localhost:3101'
66
*/
7-
const origin = 'http://localhost:3101'
7+
const origin = 'http://localhost:3101/tiny-vue'
88

9-
const baseURL = `${origin}/tiny-vue/zh-CN/os-theme/components/`
9+
const baseURL = `${origin}/zh-CN/os-theme/components/`
1010
const devServerCommon = 'pnpm run -w site'
1111

1212
export default Config({

internals/cli/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"// ---------------------全局适配@aurora包名--------------------- ": "",
2323
"release:aurora": "esno src/index.ts release:aurora",
2424
"release:alpha": "esno src/index.ts release:alpha",
25+
"release:e2eConfig": "esno src/index.ts release:e2eConfig",
2526
"// ----------------------辅助脚本---------------------- ": "",
2627
"create:ui": "esno src/commands/create/create-ui.ts",
2728
"sync-icons": "esno src/commands/create/sync-icons.ts",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import fs from 'fs-extra'
2+
import { pathFromWorkspaceRoot } from '../../config/vite'
3+
4+
const pathFromExamples = (...args) => pathFromWorkspaceRoot('examples', ...args)
5+
6+
const playWrightConfigPath = pathFromExamples('vue3/playwright.config.js')
7+
8+
export const releaseE2EConfig = ({ origin }) => {
9+
const content = fs.readFileSync(playWrightConfigPath).toString('UTF-8' as BufferEncoding)
10+
const result = origin ? content.replace('http://localhost:3101/tiny-vue', origin) : content
11+
12+
fs.writeFileSync(playWrightConfigPath, result)
13+
}

internals/cli/src/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { createIconSaas } from './commands/create/index.js'
44
import { buildUi, buildEntry, buildRuntime, buildReact, buildEntryReact, chartTheme } from './commands/build'
55
import { releaseAurora } from './commands/release/releaseAurora'
66
import { releaseAlpha } from './commands/release/releaseAlpha'
7+
import { releaseE2EConfig } from './commands/release/releaseE2EConfig'
78

89
const program = new Command()
910

@@ -15,6 +16,12 @@ program
1516
.option('-u, --updateVersion', '是否自动升级patch版本号', false)
1617
.action(releaseAlpha)
1718

19+
program
20+
.command('release:e2eConfig')
21+
.description('定制E2E测试配置的origin源')
22+
.addOption(new Option('-o --origin <origin>', 'origin源地址'))
23+
.action(releaseE2EConfig)
24+
1825
program.command('create:icon-saas').description('同步生成 icon-saas').action(createIconSaas)
1926

2027
program.command('build:entry-react').description('生成 react 组件库入口').action(buildEntryReact)

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"build:site": "pnpm i -g pnpm && pnpm build:vite-import && pnpm build:virtual-template && pnpm -C examples/sites build",
7373
"release:aurora": "pnpm -C internals/cli release:aurora",
7474
"release:alpha": "pnpm -C internals/cli release:alpha",
75+
"release:e2eConfig": "pnpm -C internals/cli release:e2eConfig",
7576
"// ---------- 使用pnpm批量发布npm包 ----------": "",
7677
"pub2": "pnpm --filter=\"./packages/dist2/**\" publish --tag v2-latest --no-git-checks --access=public",
7778
"pub3": "pnpm --filter=\"./packages/dist3/**\" publish --no-git-checks --access=public",

0 commit comments

Comments
 (0)