Skip to content

Commit 99d4d3a

Browse files
refactor: refactor test、build depts (#216)
- use turbo build - use vitest replace jest - delete unuse config\dept * chore(deps): update dependency rollup to v4 * build: upgrade rollup4 * refactor: vitest replace jest * ci: add compatibility for Yarn 4 * chore: modify yarn.lock * chore: ignore unhandled vitest errors * style: compatible with yjs tsconfig * test: coverage testing with c8 --------- Co-authored-by: cycleccc <2991205548@qq.com> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
1 parent 1f42f9c commit 99d4d3a

File tree

93 files changed

+28531
-20693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+28531
-20693
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ module.exports = {
3131
},
3232
globals: {
3333
globalThis:'readonly',
34+
vi: "readonly"
3435
},
3536
extends: [
3637
'plugin:@typescript-eslint/eslint-recommended',

.github/workflows/coverage.yml

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions
4-
5-
name: coverage test
1+
name: coverage test
62

73
on:
84
push:
@@ -18,22 +14,46 @@ jobs:
1814
test:
1915
runs-on: ubuntu-latest
2016
steps:
21-
- name: Checkout repo
22-
uses: actions/checkout@v4
23-
with:
24-
fetch-depth: 0
25-
- name: Setup node
26-
uses: actions/setup-node@v4
27-
with:
28-
node-version: 18.x
29-
registry-url: https://registry.npmjs.com
30-
- name: Install dependencies
31-
run: yarn install
32-
- name: Build packages
33-
run: yarn build
34-
- name: Unit test
35-
run: yarn run test-c
36-
- name: Upload coverage reports to Codecov
37-
uses: codecov/codecov-action@v4.6.0
38-
with:
39-
token: ${{ secrets.CODECOV_TOKEN }}
17+
# 检出代码库
18+
- name: Checkout repo
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
# 设置 Node.js 版本
24+
- name: Setup node
25+
uses: actions/setup-node@v4
26+
with:
27+
node-version: 18.x
28+
registry-url: https://registry.npmjs.com
29+
30+
# 启用 Corepack 以支持 Yarn 4
31+
- name: Enable Corepack
32+
run: corepack enable
33+
34+
# 准备 Yarn 4.x
35+
- name: Prepare Yarn
36+
run: corepack prepare yarn@4.4.1 --activate
37+
38+
# 安装依赖
39+
- name: Install dependencies
40+
run: yarn install
41+
42+
# 构建项目
43+
- name: Build packages
44+
run: yarn build
45+
46+
# 运行单元测试并生成覆盖率报告
47+
- name: Unit test
48+
run: yarn run test-c
49+
50+
# 上传覆盖率报告到 Codecov
51+
- name: Upload coverage reports to Codecov
52+
uses: codecov/codecov-action@v4.6.0
53+
with:
54+
token: ${{ secrets.CODECOV_TOKEN }}
55+
- name: Upload test results to Codecov
56+
if: ${{ !cancelled() }}
57+
uses: codecov/test-results-action@v1
58+
with:
59+
token: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/e2e.yml

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions
4-
51
name: Cypress tests
62

73
on:
@@ -31,21 +27,37 @@ on:
3127
jobs:
3228
test-e2e:
3329
runs-on: ubuntu-latest
34-
container:
30+
container:
3531
image: cypress/browsers:latest
3632
options: --user 1001
3733
steps:
38-
- uses: actions/checkout@v4
39-
- name: Use Node.js 18
40-
uses: actions/setup-node@v4
41-
with:
34+
- uses: actions/checkout@v4
35+
36+
# 设置 Node.js 版本
37+
- name: Use Node.js 18
38+
uses: actions/setup-node@v4
39+
with:
4240
node-version: '18'
43-
- name: Install dependencies
44-
run: yarn install
45-
- name: Build packages
46-
run: yarn build
47-
- uses: cypress-io/github-action@v6
48-
with:
49-
browser: chrome
50-
start: yarn run example
51-
wait-on: 'http://localhost:8881/examples/default-mode.html'
41+
42+
# 启用 Corepack
43+
- name: Enable Corepack
44+
run: corepack enable
45+
46+
# 安装并激活 Yarn 4.x
47+
- name: Prepare Yarn
48+
run: corepack prepare yarn@4.4.1 --activate
49+
50+
# 安装项目依赖
51+
- name: Install dependencies
52+
run: yarn install
53+
54+
# 构建项目
55+
- name: Build packages
56+
run: yarn build
57+
58+
# 运行 Cypress 测试
59+
- uses: cypress-io/github-action@v6
60+
with:
61+
browser: chrome
62+
start: yarn run example
63+
wait-on: 'http://localhost:8881/examples/default-mode.html'

.github/workflows/release.yml

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,28 @@ jobs:
2626
node-version: [18]
2727

2828
steps:
29+
# 检出代码库
2930
- name: Checkout repo
3031
uses: actions/checkout@v4
3132
with:
3233
fetch-depth: 0
3334

35+
# 设置 Node.js 版本
3436
- name: Setup Node ${{ matrix.node-version }}
3537
uses: actions/setup-node@v4
36-
3738
with:
3839
node-version: ${{ matrix.node-version }}
3940
registry-url: 'https://registry.npmjs.org/'
4041

42+
# 启用 Corepack 以支持 Yarn 4
43+
- name: Enable Corepack
44+
run: corepack enable
45+
46+
# 准备 Yarn 4.x
47+
- name: Prepare Yarn
48+
run: corepack prepare yarn@4.4.1 --activate
49+
50+
# 加载依赖缓存
4151
- name: Load cached dependencies
4252
uses: actions/cache@v4.1.0
4353
id: cache
@@ -48,32 +58,27 @@ jobs:
4858
/home/runner/.cache/Cypress
4959
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
5060

61+
# 安装依赖
5162
- name: Install dependencies
5263
run: yarn install
5364

54-
# - name: Load cached dependencies
55-
# uses: actions/cache@v4.0.2
56-
# id: cache
57-
# with:
58-
# path: |
59-
# **/node_modules
60-
# **/.turbo
61-
# /home/runner/.cache/Cypress
62-
# key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
63-
64-
- name: Install Dependencies
65+
# 构建项目
66+
- name: Build packages
6567
run: yarn build
6668

69+
# 运行单元测试
6770
- name: Unit test
68-
run: yarn run test
71+
run: yarn run test
6972

73+
# 运行 E2E 测试
7074
- name: E2E test
7175
uses: cypress-io/github-action@v6
7276
with:
7377
browser: chrome
7478
start: yarn run example
7579
wait-on: 'http://localhost:8881/examples/default-mode.html'
7680

81+
# 创建 Release PR 或发布稳定版本到 npm
7782
- name: Create Release PR or publish stable version to npm
7883
id: changesets
7984
uses: changesets/action@v1
@@ -85,4 +90,4 @@ jobs:
8590
${{ github.ref_name == 'master' && 'chore(release): publish a new release version' || 'chore(release): publish a new pre-release version' }}
8691
env:
8792
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
88-
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
93+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/test.yml

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2-
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3-
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions
4-
5-
name: unit test
1+
name: Unit Test
62

73
on:
84
push:
@@ -29,19 +25,37 @@ on:
2925
jobs:
3026
test:
3127
runs-on: ubuntu-latest
28+
3229
steps:
33-
- name: Checkout repo
34-
uses: actions/checkout@v4
35-
with:
36-
fetch-depth: 0
37-
- name: Setup node
38-
uses: actions/setup-node@v4
39-
with:
40-
node-version: 18.x
41-
registry-url: https://registry.npmjs.com
42-
- name: Install dependencies
43-
run: yarn install
44-
- name: Build packages
45-
run: yarn build
46-
- name: Unit test
47-
run: yarn run test
30+
# 检出代码库
31+
- name: Checkout repo
32+
uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
# 设置 Node.js 版本
37+
- name: Setup Node.js
38+
uses: actions/setup-node@v4
39+
with:
40+
node-version: 18.x
41+
registry-url: https://registry.npmjs.com
42+
43+
# 启用 Corepack 以支持 Yarn 4
44+
- name: Enable Corepack
45+
run: corepack enable
46+
47+
# 准备 Yarn 4.x
48+
- name: Prepare Yarn
49+
run: corepack prepare yarn@4.4.1 --activate
50+
51+
# 安装依赖
52+
- name: Install dependencies
53+
run: yarn install
54+
55+
# 构建项目
56+
- name: Build packages
57+
run: yarn build
58+
59+
# 运行单元测试
60+
- name: Unit test
61+
run: yarn run test

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ typings/
6767

6868
# Yarn Integrity file
6969
.yarn-integrity
70+
.pnp.*
71+
.yarn/*
72+
!.yarn/patches
73+
!.yarn/plugins
74+
!.yarn/releases
75+
!.yarn/sdks
76+
!.yarn/versions
7077

7178
# dotenv environment variables file
7279
.env
@@ -127,4 +134,4 @@ stats.html
127134

128135

129136
# Turbo cache
130-
.turbo
137+
.turbo

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/usr/bin/env sh
22
. "$(dirname -- "$0")/_/husky.sh"
33

4-
yarn lint:staged
4+
yarn lint:staged
File renamed without changes.

.vscode/launch.json

Lines changed: 0 additions & 29 deletions
This file was deleted.

.yarnrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

.yarnrc.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nodeLinker: node-modules
2+
3+
npmRegistryServer: "https://registry.npmjs.org/"

0 commit comments

Comments
 (0)