diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 01f04c0d4c..424b7110d7 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -35,10 +35,10 @@ jobs: run: pnpm i - name: Build site - run: pnpm scripts run build + run: pnpm build - name: ESLint run: pnpm cli --filter vue-devui -- code-check -t eslint - name: Unit test - run: pnpm scripts run tests.test + run: pnpm cli --filter vue-devui -- code-check -t unit-test diff --git a/.ls-lint.yml b/.ls-lint.yml index a049ccc6cb..aed0aae972 100644 --- a/.ls-lint.yml +++ b/.ls-lint.yml @@ -16,6 +16,7 @@ ignore: - packages/devui-cli/node_modules # devui-theme - packages/devui-theme/dist + - packages/devui-theme/build - packages/devui-theme/node_modules - packages/devui-theme/src/styles-var # devui-vue diff --git a/package.json b/package.json index 629fe8c94b..3f9930e957 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,9 @@ "precommit": "lint-staged", "scripts": "better-scripts", "dev": "pnpm scripts run dev", - "build": "pnpm scripts run build" + "build": "pnpm scripts run build", + "build:lib": "pnpm scripts run build:lib", + "test": "pnpm scripts run tests.test" }, "devDependencies": { "@commitlint/cli": "^11.0.0", diff --git a/packages/devui-vue/devui-cli/commands/code-check.js b/packages/devui-vue/devui-cli/commands/code-check.js index b7ee00fdf8..342c3ac495 100644 --- a/packages/devui-vue/devui-cli/commands/code-check.js +++ b/packages/devui-vue/devui-cli/commands/code-check.js @@ -5,17 +5,11 @@ const chalk = require('chalk'); const { isReadyToRelease } = require('../shared/utils'); const log = console.log; - const chalkEslint = chalk.hex('#4b32c3'); - const chalkUnitTest = chalk.hex('#99425b'); - const chalkError = chalk.hex('#F66F6A'); - const chalkSuccess = chalk.hex('#3DCCA6'); - const entryDir = path.resolve(__dirname, '../../devui'); - const unitTestFailedComponents = []; const completeComponents = fs.readdirSync(entryDir).filter((name) => { @@ -87,8 +81,16 @@ const unitTestSome = async (components) => { }; const unitTestAll = async () => { - for (const name of completeComponents) { - await unitTestSingle(name); + // 单个组件执行单元测试,总耗时太长 + // for (const name of completeComponents) { + // await unitTestSingle(name); + // } + + const unitTestResult = await shell.exec('pnpm --filter vue-devui test --reporter default'); + // 解决单元测试报错,但PR合入门禁不中断问题 + if (/failed|ERR_/.test(unitTestResult.stderr)) { + shell.echo(chalkError('Error: Unit test failed.')); + shell.exit(1); } log(chalkSuccess('\nCongratulations, all components have passed the unit test!')); diff --git a/scripts.json b/scripts.json index 9012f16d62..2b6a9d496e 100644 --- a/scripts.json +++ b/scripts.json @@ -8,12 +8,12 @@ "build": { "alias": "Build", "desc": "Build theme and docs", - "command": "pnpm --filter vue-devui build" + "command": "pnpm --filter vue-devui build --reporter default" }, "build:lib": { "alias": "Build lib", "desc": "Build components and release", - "command": "pnpm --filter vue-devui build:lib" + "command": "pnpm --filter vue-devui build:lib --reporter default" }, "build:cli": { "alias": "Build cli", @@ -34,7 +34,7 @@ "alias": "Tests", "desc": "Select a test script to run", "scripts": { - "test": ["pnpm --filter vue-devui test", "Test vue-devui"], + "test": ["pnpm --filter vue-devui test --reporter default", "Test vue-devui"], "coverage": ["pnpm --filter vue-devui coverage", "Test vue-devui and gen coverage"] } }