ci: 任何失败路径都输出注解
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
构建与发布 / 单测与集成测试 (push) Waiting to run
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, linux, ubuntu-24.04-arm) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (arm64, macos, macos-15) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, linux, ubuntu-24.04) (push) Blocked by required conditions
构建与发布 / 打包 ${{ matrix.platform }} ${{ matrix.arch }} (x64, windows, windows-2025) (push) Blocked by required conditions
构建与发布 / 发布 GitHub Release (push) Blocked by required conditions
This commit is contained in:
+19
-15
@@ -43,31 +43,35 @@ jobs:
|
||||
- name: 安装依赖
|
||||
run: npm ci
|
||||
|
||||
# 下载完整日志需要仓库管理员权限,失败详情转成注解才能在提交页直接看到
|
||||
# 下载完整日志需要仓库管理员权限。失败详情转成注解,这样没有管理员权限
|
||||
# 的人也能在提交页直接看到是哪条断言挂了,不必去翻日志。
|
||||
- name: 单元测试
|
||||
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
|
||||
npm test > /tmp/unit.log 2>&1 || {
|
||||
echo "::error title=单元测试失败::$(tail -120 /tmp/unit.log \
|
||||
| sed 's/%/%25/g; s/\r//g' | awk '{printf "%s%%0A", $0}')"
|
||||
exit 1
|
||||
}
|
||||
tail -6 /tmp/unit.log
|
||||
|
||||
# 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
|
||||
annotate() {
|
||||
echo "::error title=$1::$(tail -80 "$2" | sed 's/%/%25/g; s/\r//g' | awk '{printf "%s%%0A", $0}')"
|
||||
exit 1
|
||||
}
|
||||
sudo apt-get update > /tmp/apt.log 2>&1 || annotate "apt 更新失败" /tmp/apt.log
|
||||
sudo apt-get install -y xvfb libnss3 libatk1.0-0t64 libatk-bridge2.0-0t64 \
|
||||
libcups2t64 libgbm1 libasound2t64 libgtk-3-0t64 >> /tmp/apt.log 2>&1 \
|
||||
|| annotate "运行库安装失败" /tmp/apt.log
|
||||
for suite in startup download cover annotation reader-features library-notes ai-scope; do
|
||||
echo "::group::$suite"
|
||||
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
|
||||
xvfb-run -a npx electron "src/_test/electron/$suite.integration.js" \
|
||||
> "/tmp/$suite.log" 2>&1 || { echo "::endgroup::"; annotate "集成测试失败 $suite" "/tmp/$suite.log"; }
|
||||
tail -3 "/tmp/$suite.log"
|
||||
echo "::endgroup::"
|
||||
done
|
||||
|
||||
|
||||
Reference in New Issue
Block a user