knowledgeWorkflow.test.mjs
2.22 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
import assert from 'node:assert/strict'
import fs from 'node:fs'
import path from 'node:path'
import test from 'node:test'
import { fileURLToPath } from 'node:url'
const projectRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..')
function read(relativePath) {
return fs.readFileSync(path.join(projectRoot, relativePath), 'utf8')
}
test('project quality workflow keeps advisory drift, affected PRs and master full tests', () => {
const workflow = read('.github/workflows/project-quality.yml')
assert.match(workflow, /pull_request:/)
assert.match(workflow, /branches:\s*\n\s*- master/)
assert.match(workflow, /knowledge-drift:[\s\S]*continue-on-error: true/)
assert.match(workflow, /test:affected[\s\S]*--base[\s\S]*--head/)
assert.match(workflow, /master-tests:[\s\S]*npm test/)
})
test('live workflow is manual, profile-bound, secret-only and write-gated', () => {
const workflow = read('.github/workflows/live-order-tests.yml')
assert.match(workflow, /workflow_dispatch:/)
assert.match(workflow, /mingming-dev/)
assert.match(workflow, /bobo-test/)
assert.match(workflow, /inputs\.allow_writes != true/)
assert.match(workflow, /LIVE_ALLOW_WRITES: '1'/)
assert.match(workflow, /secrets\.LIVE_MINGMING_MOBILE/)
assert.match(workflow, /secrets\.LIVE_BOBO_MOBILE/)
assert.doesNotMatch(workflow, /\b1\d{10}\b/)
})
test('documentation entry describes setup, querying, maintenance and Live boundaries', () => {
const documentation = read('docs/README.md')
for (const required of [
'npm run knowledge:build',
'npm run knowledge:check',
'npm run impact',
'npm run test:affected',
'npm test',
'### 日常维护',
'### Live 自动化',
]) {
assert.ok(documentation.includes(required), `missing docs entry: ${required}`)
}
})
test('root README exposes the knowledge workflow to first-time contributors', () => {
const readme = read('README.md')
for (const required of [
'领域知识图谱与增量测试',
'npm run knowledge:build',
'npm run knowledge:check',
'npm run impact',
'npm run test:affected',
'./docs/README.md#领域知识图谱搭建与使用',
]) {
assert.ok(readme.includes(required), `missing root README entry: ${required}`)
}
})