Repository navigation
105 lines (87 loc) · 4.01 KB
/
Copy pathci.yml
File metadata and controls
105 lines (87 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CI
on:
# 仓库已关闭 Pull Requests,只保留直接 push 和手动触发。
push:
branches: [dev, main]
paths-ignore:
- "**/*.md"
- "docs/**"
workflow_dispatch:
inputs:
run_tests:
description: "Run full unit tests (slow)"
required: false
default: false
type: boolean
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
env:
NODE_VERSION: "24.14.0"
HUSKY: "0"
jobs:
checks:
name: Version / Typecheck / Lint
runs-on: windows-latest
timeout-minutes: 20
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Verify version identity
shell: pwsh
run: |
node -e "const root=require('./package.json').version; const cli=require('./apps/zcode-cli/package.json').version; if (!/^\d+\.\d+\.\d+\+\d+\.\d+\.\d+$/.test(root)) throw new Error('root version does not match private+official: ' + root); if (cli !== root) throw new Error('cli version=' + cli + ' != root ' + root); console.log('[version] root=' + root + ' cli=' + cli)"
node -e "const { getBuildMetadata } = require('./packages/desktop/scripts/build-metadata.mjs'); const root=require('./package.json').version; const version = getBuildMetadata().appVersion; if (version !== root) throw new Error('desktop build version=' + version); console.log('[version] desktop=' + version)"
node --input-type=module -e "import { readFile } from 'node:fs/promises'; import { readRootPackageVersion } from './apps/zcode-cli/packages/cli/scripts/build.mjs'; const root=JSON.parse(await readFile('./package.json','utf8')).version; const version = await readRootPackageVersion(); if (version !== root) throw new Error('cli bundle version=' + version); console.log('[version] cli-bundle=' + version)"
- name: Typecheck
run: pnpm typecheck
- name: Lint
run: pnpm lint
tests:
name: Full unit tests (manual)
if: github.event_name == 'workflow_dispatch' && inputs.run_tests == true
runs-on: windows-latest
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup pnpm
uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
# e2e-report 的入口指向 dist-node(见 packages/e2e-report/package.json exports);
# checks job 里 pnpm typecheck 会顺带产出它,本 job 不跑 typecheck,需显式构建,
# 否则 desktop e2eReporting* 三个单测在新检出上会因「Failed to resolve entry」收集失败。
- name: Build e2e-report entry
run: pnpm --filter @zcode/e2e-report build:node
# 修复原因:storagePreparationProtocol 单测 import 了 apps/zcode-cli 的 bootstrap 源码,而 CLI 包的
# exports 指向 dist(.gitignore 忽略);不构建就只有「曾经构建过 CLI 的开发机」能通过,CI 新检出必然收集失败。
# 用 @zcode/bootstrap... 只构建该测试需要的依赖闭包(本机实测约 68s)。
- name: Build CLI packages needed by root tests
run: pnpm -r --filter "@zcode/bootstrap..." run build
# 修复原因:全量 16000+ 用例在 threads 池(4 workers)下曾在 CI 触发
# ERR_WORKER_OUT_OF_MEMORY,worker 被杀会把在跑文件一并计为失败;提高堆上限后再评估。
- name: Unit tests
env:
NODE_OPTIONS: "--max-old-space-size=6144"
run: pnpm test:unit