From 09fae64f1f25c2c54ec84c322376fb0e7548a749 Mon Sep 17 00:00:00 2001 From: lofyer Date: Wed, 5 Aug 2026 19:35:57 +0800 Subject: [PATCH] =?UTF-8?q?ci:=20=E6=B5=8B=E8=AF=95=E5=A4=B1=E8=B4=A5?= =?UTF-8?q?=E6=97=B6=E8=BE=93=E5=87=BA=E6=B3=A8=E8=A7=A3=EF=BC=8C=E4=BE=BF?= =?UTF-8?q?=E4=BA=8E=E6=97=A0=E7=AE=A1=E7=90=86=E5=91=98=E6=9D=83=E9=99=90?= =?UTF-8?q?=E6=97=B6=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 40ddbba..cb9b50d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,17 +43,31 @@ jobs: - name: 安装依赖 run: npm ci + # 下载完整日志需要仓库管理员权限,失败详情转成注解才能在提交页直接看到 - name: 单元测试 - run: npm test + shell: bash + run: | + set -o pipefail + npm test 2>&1 | tee /tmp/unit.log && exit 0 + echo "::error title=单元测试失败::$(grep -A 15 '^not ok' /tmp/unit.log \ + | head -150 | sed 's/%/%25/g; s/\r//g' | awk '{printf "%s%%0A", $0}')" + exit 1 # Electron 集成测试要开真实窗口,无头环境靠 xvfb 提供 X server - name: Electron 集成测试 + shell: bash run: | + set -o pipefail sudo apt-get update sudo apt-get install -y xvfb libnss3 libatk1.0-0t64 libatk-bridge2.0-0t64 libcups2t64 libgbm1 libasound2t64 libgtk-3-0t64 for suite in startup download cover annotation reader-features library-notes ai-scope; do echo "::group::$suite" - xvfb-run -a npx electron "src/_test/electron/$suite.integration.js" + if ! xvfb-run -a npx electron "src/_test/electron/$suite.integration.js" 2>&1 | tee "/tmp/$suite.log"; then + echo "::endgroup::" + echo "::error title=集成测试失败 $suite::$(grep -iE 'FAIL|Error|失败' "/tmp/$suite.log" \ + | head -60 | sed 's/%/%25/g; s/\r//g' | awk '{printf "%s%%0A", $0}')" + exit 1 + fi echo "::endgroup::" done