Skip to content

Commit

Permalink
Merge pull request #76 from eric2788/develop
Browse files Browse the repository at this point in the history
Update: v2.0.1
  • Loading branch information
eric2788 authored Mar 14, 2024
2 parents 66cf4ef + 3e23f1d commit 6e42fdf
Show file tree
Hide file tree
Showing 33 changed files with 688 additions and 111 deletions.
81 changes: 81 additions & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
name: 问题回报
description: 创建一个问题回报
title: "[Bug]: <title>"
labels: ["问题反映/修复", "求助"]
projects: ["eric2788/4"]
body:
- type: checkboxes
attributes:
label: 感谢您抽出时间填写此问题回报!
description: 在提交问题之前,请确保您已经搜索了现有的问题,以确保您的问题是独特的。
options:
- label: 我已经搜索了现有的问题,并且确认我的问题是独特的
required: true
- type: textarea
id: problem
attributes:
label: 问题描述
description: 清楚简明扼要地描述你所遇到的问题
Tip: 可以添加图片或其他文件作为补充
validations:
required: true
- type: textarea
id: expected-result
attributes:
label: 期望结果
description: 描述一下正常的时候理应出现的结果是如何?
Tip: 可以添加图片或其他文件作为补充
validations:
required: true
- type: textarea
id: reproduce
attributes:
label: 复现步骤
description: 请提供详细的复现步骤
Tip: 可以添加图片或其他文件作为补充
placeholder: |
1. 进入 '...'
2. 点进 '....'
3. 打开 '....'
4. 无法使用
validations:
required: true
- type: input
id: browser
attributes:
label: 浏览器
description: 你所使用的浏览器以及版本?
placeholder: e.g. Chrome 版本 122.0.6261.113 (64 位元)
validations:
required: true
- type: dropdown
id: other-browsers
attributes:
label: 其他浏览器上的复现
description: 除了你所使用的浏览器外,你还有在其他浏览器上复现了这个问题吗?
multiple: true
options:
- Chrome
- Microsoft Edge
- Opera
- Brave
- type: inpput
id: extension-version
attributes:
label: 扩展版本
description: 你所使用的扩展版本?
placeholder: e.g. 2.0.0
- type: textarea
id: logs
attributes:
label: 相关的日志(如有)
description: 你可以打开 F12 的控制台查找相关的日志
validations:
required: false
- type: textarea
id: others
attributes:
label: 补充(如有)
description: 你还有其他补充吗?
validations:
required: false
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: 功能请求
description: 创建一个功能请求
title: "[功能请求]: <title>"
labels: ["功能请求/增強"]
projects: ["eric2788/4"]
body:
- type: textarea
id: feature
attributes:
label: 功能描述
description: 请描述你所希望的功能是什么?
Tip: 可以添加图片或其他文件作为补充
validations:
required: true
- type: textarea
id: why
attributes:
label: 为什么需要这个功能?
description: 请描述为什么你需要这个功能?
placeholder: |
e.g. 我经常需要在 '...' 时做 '....',但是现在无法做到
Tip: 可以添加图片或其他文件作为补充
validations:
required: true
- type: textarea
id: others
attributes:
label: 补充(如有)
description: 你还有其他补充吗?
validations:
required: false
20 changes: 16 additions & 4 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- 'develop'
- 'hotfix/**'
- 'feature/**'
paths:
- 'src/**'
- 'tests/**'
Expand All @@ -14,6 +12,11 @@ on:
- '.github/workflows/build-test.yml'
pull_request:
branches: [develop]
types:
- opened
- reopened
- ready_for_review
- review_requested
workflow_dispatch:
inputs:
debug:
Expand Down Expand Up @@ -58,6 +61,8 @@ jobs:
theme: ['', '-theme']
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"
- name: Download artifacts
uses: actions/download-artifact@v4
id: download
Expand All @@ -76,8 +81,15 @@ jobs:
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: Setup Project
id: project
run: |
Expand All @@ -92,7 +104,7 @@ jobs:
fi
pnpm test -- --project=${{ steps.project.outputs.project }}
- name: Upload Test Results
if: always()
if: always() && steps.test.conclusion != 'skipped'
uses: actions/upload-artifact@v4
with:
name: ${{ steps.project.outputs.project }}-test-results
Expand All @@ -101,7 +113,7 @@ jobs:
playwright-report/
if-no-files-found: ignore
- name: Upload Results To R2
if: ${{ failure() && steps.test.conclusion == 'failure' }}
if: failure() && steps.test.conclusion == 'failure'
uses: eric2788/r2-upload-action@master
id: upload
continue-on-error: true
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/partial-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Test Only @scoped

on:
push:
branches:
- 'hotfix/**'
- 'feature/**'
paths:
- 'src/**'
- 'tests/**'
- 'playwright.config.ts'
- 'pnpm-lock.yaml'
- '.github/workflows/build-test.yml'
workflow_dispatch:
inputs:
debug:
description: 'Enable debug logging'
required: false
default: 'false'

jobs:
fast-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
browser: [chrome, edge]
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: Build Extension and Prepare Tests
run: pnpm test:rebuild
- 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.browser }} \
--grep=@scoped \
--pass-with-no-tests \
--global-timeout=3600000 \
--timeout=60000 \
--max-failures=5
env:
DEBUG: true
3 changes: 2 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ jobs:
"clientSecret": "${{ secrets.EDGE_CLIENT_SECRET}}",
"productId": "${{ secrets.EDGE_PRODUCT_ID }}",
"accessTokenUrl": "${{ secrets.EDGE_ACCESS_TOKEN_URL }}",
"uploadOnly": ${{ inputs.dry-run }}
"uploadOnly": ${{ inputs.dry-run }},
"notes": "https://github.com/eric2788/bilibili-vup-stream-enhancer"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ npm-debug.log*
out/
build/
dist/
*.local.yml
*-local.tsx
*-local.ts

# plasmo - https://www.plasmo.com
.plasmo
Expand Down
40 changes: 34 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
- [事前准备](#事前准备)
- [贡献流程](#贡献流程)
- [程式码规范](#程式码规范)
- [提交规范](#提交规范)
- [项目架构](#项目架构)
- [源代码](#源代码)
- [测试代码](#测试代码)
- [快速开始](#快速开始)
- [关于自动测试](#关于自动测试)
- [问题回报](#问题回报)
- [讨论与支援](#讨论与支援)

Expand All @@ -30,8 +32,8 @@

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

## 程式码规范
Expand All @@ -43,6 +45,13 @@

> 请放心,我们会在您提交 Pull Request 时进行代码检查,如有任何问题我们会在检查时提出。
### 提交规范

- 本项目在 commit message 上没有限制, 清晰明了即可
- PR分支请确保是基于 `develop` 分支创建,且分支名称应该为 `[类型]/[issue号]-[概要]` 的格式;例如 `feature/123-new-feature`
- 请确保你的每一条 commits 都有意义,如有必要请使用 `git rebase` 合并 commits
- 如果你的 PR 是为了修复某个 issue,请在 PR 描述中写明 `Fixed|Resolved #issue号`,以便自动连结 issue

## 项目架构

本项目的架构如下:
Expand Down Expand Up @@ -84,12 +93,12 @@ src/

```
tests/
├── features/ # 功能模块的集成测试代码
├── features/ # 功能模块的端到端测试代码
├── fixtures/ # 测试中需要用到的前置依赖。
├── helpers/ # 使用类形式包装的测试辅助工具。
├── pages/ # 扩展页面的集成测试代码
├── pages/ # 扩展页面的端到端测试代码
├── utils/ # 辅助测试的函数和工具。
├── content.spec.ts # 内容脚本的集成测试代码
├── content.spec.ts # 内容脚本的端到端测试代码
├── options.ts # fixtures 选项类型定义文件。
└── theme.setup.ts # 大海报房间测试的前置依赖。
```
Expand All @@ -103,12 +112,31 @@ tests/
5. 有关如何编写贡献代码,请参阅 [入门指南](#入门指南)


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

### 关于自动测试

本项目的自动测试分为两种类型:快速测试和完整测试。

快速测试: 只测试所有刻上了 `@scoped` 标签的测试用例。

完整测试: 从头开始测试所有测试用例,进行前需要先移除所有 `@scoped` 标签。

- 当以下格式的分支被推送时,会触发快速测试:
- `feature/**`: 新功能分支
- `hotfix/**`: 修复分支

- 当向 `develop` 分支提交 PR 时,以下条件会触发完整测试:
- 当用户开启了 PR 时
- 当用户从草稿状态转为正式状态时
- 当用户请求检查时

- 必要时,我们会在 PR 检查时手动触发完整测试。

#### 入门指南

请参阅 [`docs/`](/docs/) 下的 `.md` 文件来查看详细的代码编写流程。
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
- FireFox 不需要在 2024 年 6 月前强制进入 mv3 阶段。
- FireFox 目前对于 mv3 支援依然尚未完善,包括众多的BUG和未知问题。

## 先行版本

安装先行版本需要手动下载及安装,且可能会有未知问题。
如发现问题,欢迎到 issue 进行回报。(连带 `先行版本` 标签)


- [从 Artifacts 下载](https://github.com/eric2788/bilibili-vup-stream-enhancer/actions/workflows/build-test.yml?query=branch%3Adevelop)

- [安装方式](https://jingyan.baidu.com/article/3065b3b6cc6cf6ffcef8a444.html)


## ➵ 简介

本浏览器插件透过挂接 WebSocket 为管人观众提供众多功能。 本插件虽然功能众多,但全部主要功能均为可选,你仍可为界面保持简化。
Expand Down
2 changes: 1 addition & 1 deletion docs/background.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export type ForwardBody = {
room: string
}

// 支援 await 函数
// 支援 async 函数
const handler: ForwardHandler<ForwardBody, ResponseBody> = (req) => {

let pos: 'scroll' | 'top' | 'bottom' = 'scroll'
Expand Down
2 changes: 1 addition & 1 deletion docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

> 本扩展基于 [Plasmo CSUI](https://docs.plasmo.com/framework/content-scripts-ui) 进行前端渲染。
如要新增功能,你需要到以下地方新增(其余未列明的地方均为可选)
如要新增功能,你需要到以下地方新增:

```
src/
Expand Down
Loading

0 comments on commit 6e42fdf

Please sign in to comment.