Skip to content

Commit

Permalink
[PR feat] 功能 - 新增快速切片 (#79)
Browse files Browse the repository at this point in the history
* initialized recorder feature

* finished settings fragment and fixed layout problem of feature settings

* added unit and integration testing mechanism

* added unit and integration test cases for recorder

* finished recorder feature and test cases
  • Loading branch information
eric2788 authored Apr 6, 2024
1 parent acda39d commit 4a1aff2
Show file tree
Hide file tree
Showing 81 changed files with 24,172 additions and 379 deletions.
71 changes: 58 additions & 13 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
name: Build And Test Extensions

on:
push:
branches:
- 'develop'
paths:
- 'src/**'
- 'tests/**'
- 'playwright.config.ts'
- 'pnpm-lock.yaml'
- '.github/workflows/build-test.yml'
pull_request:
branches: [develop]
branches: [develop, master]
types:
- opened
- reopened
- ready_for_review
- review_requested
paths:
- 'src/**'
- 'tests/**'
- 'playwright.config.ts'
- 'pnpm-lock.yaml'
- '.github/workflows/build-test.yml'
workflow_dispatch:
inputs:
debug:
Expand Down Expand Up @@ -45,15 +42,63 @@ jobs:
run: pnpm install --frozen-lockfile
- name: Build And Package Extensions
run: pnpm build --zip --target=${{ matrix.browser }}-mv3
env:
DEBUG: true
# upload to github artifacts for each browser with matrix
- name: Upload to GitHub Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.browser }}-mv3
path: build/
test:
test: # non-e2e test no need upload to r2
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
project: [integrations, units]
steps:
- uses: actions/checkout@v4
- name: Ensure No @Scoped Test
run: grep -r --include "*.spec.ts" "@scoped" && echo "please remove @scoped from tests" && exit 1 || echo "No @scoped tests found"
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
- name: Install Playwright Browsers
run: pnpm exec playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Test
id: test
run: |
if [ "${{ inputs.debug }}" == "true" ]; then
echo "Enabled Debug Mode"
export DEBUG=true
fi
pnpm test -- --project=${{ matrix.project }} --max-failures=5
- name: Upload Test Results
if: always() && steps.test.conclusion != 'skipped'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.project }}-test-results
path: |
test-results/
playwright-report/
if-no-files-found: ignore
e2e-test:
runs-on: ubuntu-latest
needs: build
needs: [build, test]
strategy:
fail-fast: false
matrix:
Expand Down Expand Up @@ -100,7 +145,7 @@ jobs:
run: |
if [ "${{ inputs.debug }}" == "true" ]; then
echo "Enabled Debug Mode"
export DEBUG="pw:api"
export DEBUG=true
fi
pnpm test -- --project=${{ steps.project.outputs.project }}
- name: Upload Test Results
Expand Down
51 changes: 49 additions & 2 deletions .github/workflows/partial-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ on:
- 'tests/**'
- 'playwright.config.ts'
- 'pnpm-lock.yaml'
- '.github/workflows/build-test.yml'
workflow_dispatch:
inputs:
debug:
Expand All @@ -21,6 +20,43 @@ on:
jobs:
fast-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project: [units, integrations]
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v2
with:
version: 8
- name: Setup Node.js
uses: actions/[email protected]
with:
node-version: 20
cache: 'pnpm'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ hashFiles('**/pnpm-lock.yaml') }}
- run: pnpm exec playwright install --with-deps
if: steps.playwright-cache.outputs.cache-hit != 'true'
- name: Test
id: test
run: |
pnpm test -- --project=${{ matrix.project }} \
--grep=@scoped \
--pass-with-no-tests \
--global-timeout=3600000 \
--max-failures=2
env:
DEBUG: true
fast-e2e-test:
runs-on: ubuntu-latest
needs: fast-test
strategy:
fail-fast: false
matrix:
Expand All @@ -39,6 +75,8 @@ jobs:
run: pnpm install --frozen-lockfile
- name: Build Extension and Prepare Tests
run: pnpm test:rebuild
env:
DEBUG: true
- name: Cache playwright binaries
uses: actions/cache@v3
id: playwright-cache
Expand All @@ -57,4 +95,13 @@ jobs:
--timeout=60000 \
--max-failures=5
env:
DEBUG: true
DEBUG: true
- name: Upload Test Results
if: failure() && steps.test.conclusion != 'skipped'
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.browser }}-test-results
path: |
test-results/
playwright-report/
if-no-files-found: ignore
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@

1. Fork 本仓库到你的本地仓库
2. 在你的本地仓库中进行修改
3. 如开发新功能,请自行添加合理且可行的端到端测试
4. 完成后,确保你的代码通过所有端到端测试
3. 如开发新功能,请自行添加合理且可行的测试
4. 完成后,确保你的代码通过所有测试
5. 提交 Pull Request 到本仓库的 `develop` 分支

## 程式码规范
Expand Down Expand Up @@ -76,6 +76,7 @@ src/
├── contexts/ # 全局用 React 状态管理。
├── database/ # 数据库相关代码,包括模型定义和数据库迁移操作。
├── features/ # 特性模块,每个特性模块包含一组相关的功能。
├── ffmpeg/ # FFmpeg 相关代码。
├── hooks/ # 全局用的自定义 React Hooks。
├── migrations/ # 设定迁移脚本(从MV2到MV3)。
├── players/ # 直播解析器相关代码。
Expand All @@ -97,6 +98,9 @@ tests/
├── features/ # 功能模块的端到端测试代码。
├── fixtures/ # 测试中需要用到的前置依赖。
├── helpers/ # 使用类形式包装的测试辅助工具。
├── integrations/ # 集成测试代码。
├── units/ # 单元测试代码。
├── modules/ # 用于注入到集成测试的模块JS。
├── pages/ # 扩展页面的端到端测试代码。
├── utils/ # 辅助测试的函数和工具。
├── content.spec.ts # 内容脚本的端到端测试代码。
Expand All @@ -113,7 +117,7 @@ tests/
5. 有关如何编写贡献代码,请参阅 [入门指南](#入门指南)


#### 如要在本地运行端到端测试:
#### 如要在本地运行测试:
- 请先运行 `pnpm dlx playwright install` 安装 PlayWright 的浏览器引擎
- 完成后,运行 `pnpm build && pnpm test:prepare` 编译并部署测试环境
- 最后,运行 `pnpm test` 运行测试 (或者用 playwright vscode 插件运行测试)
Expand Down
Loading

0 comments on commit 4a1aff2

Please sign in to comment.