Skip to content

Commit

Permalink
refactor: refactor test、build depts (#216)
Browse files Browse the repository at this point in the history
- 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>
  • Loading branch information
cycleccc and renovate[bot] committed Oct 8, 2024
1 parent 1f42f9c commit 99d4d3a
Show file tree
Hide file tree
Showing 93 changed files with 28,531 additions and 20,693 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module.exports = {
},
globals: {
globalThis:'readonly',
vi: "readonly"
},
extends: [
'plugin:@typescript-eslint/eslint-recommended',
Expand Down
68 changes: 44 additions & 24 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions

name: coverage test
name: coverage test

on:
push:
Expand All @@ -18,22 +14,46 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.com
- name: Install dependencies
run: yarn install
- name: Build packages
run: yarn build
- name: Unit test
run: yarn run test-c
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
# 检出代码库
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

# 设置 Node.js 版本
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.com

# 启用 Corepack 以支持 Yarn 4
- name: Enable Corepack
run: corepack enable

# 准备 Yarn 4.x
- name: Prepare Yarn
run: corepack prepare yarn@4.4.1 --activate

# 安装依赖
- name: Install dependencies
run: yarn install

# 构建项目
- name: Build packages
run: yarn build

# 运行单元测试并生成覆盖率报告
- name: Unit test
run: yarn run test-c

# 上传覆盖率报告到 Codecov
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.6.0
with:
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload test results to Codecov
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
48 changes: 30 additions & 18 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions

name: Cypress tests

on:
Expand Down Expand Up @@ -31,21 +27,37 @@ on:
jobs:
test-e2e:
runs-on: ubuntu-latest
container:
container:
image: cypress/browsers:latest
options: --user 1001
steps:
- uses: actions/checkout@v4
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
- uses: actions/checkout@v4

# 设置 Node.js 版本
- name: Use Node.js 18
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install dependencies
run: yarn install
- name: Build packages
run: yarn build
- uses: cypress-io/github-action@v6
with:
browser: chrome
start: yarn run example
wait-on: 'http://localhost:8881/examples/default-mode.html'

# 启用 Corepack
- name: Enable Corepack
run: corepack enable

# 安装并激活 Yarn 4.x
- name: Prepare Yarn
run: corepack prepare yarn@4.4.1 --activate

# 安装项目依赖
- name: Install dependencies
run: yarn install

# 构建项目
- name: Build packages
run: yarn build

# 运行 Cypress 测试
- uses: cypress-io/github-action@v6
with:
browser: chrome
start: yarn run example
wait-on: 'http://localhost:8881/examples/default-mode.html'
33 changes: 19 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ jobs:
node-version: [18]

steps:
# 检出代码库
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

# 设置 Node.js 版本
- name: Setup Node ${{ matrix.node-version }}
uses: actions/setup-node@v4

with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://registry.npmjs.org/'

# 启用 Corepack 以支持 Yarn 4
- name: Enable Corepack
run: corepack enable

# 准备 Yarn 4.x
- name: Prepare Yarn
run: corepack prepare yarn@4.4.1 --activate

# 加载依赖缓存
- name: Load cached dependencies
uses: actions/cache@v4.1.0
id: cache
Expand All @@ -48,32 +58,27 @@ jobs:
/home/runner/.cache/Cypress
key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

# 安装依赖
- name: Install dependencies
run: yarn install

# - name: Load cached dependencies
# uses: actions/cache@v4.0.2
# id: cache
# with:
# path: |
# **/node_modules
# **/.turbo
# /home/runner/.cache/Cypress
# key: ${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}

- name: Install Dependencies
# 构建项目
- name: Build packages
run: yarn build

# 运行单元测试
- name: Unit test
run: yarn run test
run: yarn run test

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

# 创建 Release PR 或发布稳定版本到 npm
- name: Create Release PR or publish stable version to npm
id: changesets
uses: changesets/action@v1
Expand All @@ -85,4 +90,4 @@ jobs:
${{ github.ref_name == 'master' && 'chore(release): publish a new release version' || 'chore(release): publish a new pre-release version' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
54 changes: 34 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# github actions 中文文档 https://docs.github.com/cn/actions/getting-started-with-github-actions

name: unit test
name: Unit Test

on:
push:
Expand All @@ -29,19 +25,37 @@ on:
jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.com
- name: Install dependencies
run: yarn install
- name: Build packages
run: yarn build
- name: Unit test
run: yarn run test
# 检出代码库
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0

# 设置 Node.js 版本
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 18.x
registry-url: https://registry.npmjs.com

# 启用 Corepack 以支持 Yarn 4
- name: Enable Corepack
run: corepack enable

# 准备 Yarn 4.x
- name: Prepare Yarn
run: corepack prepare yarn@4.4.1 --activate

# 安装依赖
- name: Install dependencies
run: yarn install

# 构建项目
- name: Build packages
run: yarn build

# 运行单元测试
- name: Unit test
run: yarn run test
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ typings/

# Yarn Integrity file
.yarn-integrity
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# dotenv environment variables file
.env
Expand Down Expand Up @@ -127,4 +134,4 @@ stats.html


# Turbo cache
.turbo
.turbo
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn lint:staged
yarn lint:staged
File renamed without changes.
29 changes: 0 additions & 29 deletions .vscode/launch.json

This file was deleted.

2 changes: 0 additions & 2 deletions .yarnrc

This file was deleted.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

npmRegistryServer: "https://registry.npmjs.org/"
Loading

0 comments on commit 99d4d3a

Please sign in to comment.