-
Notifications
You must be signed in to change notification settings - Fork 513
98 lines (92 loc) · 4.29 KB
/
Copy pathissue-quality-tests.yml
File metadata and controls
98 lines (92 loc) · 4.29 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
name: Issue quality tests
on:
pull_request:
paths:
- ".github/ISSUE_TEMPLATE/**"
- ".github/scripts/issue-quality.cjs"
- ".github/scripts/issue-quality.test.cjs"
- ".github/scripts/pr-quality.cjs"
- ".github/scripts/pr-quality.test.cjs"
- ".github/scripts/pr-labeler.cjs"
- ".github/scripts/pr-labeler.test.cjs"
- ".github/scripts/enforce-pr-target.test.cjs"
- ".github/scripts/issue-translation.cjs"
- ".github/scripts/issue-translation.test.cjs"
- ".github/scripts/issue-triage.cjs"
- ".github/scripts/issue-triage.test.cjs"
- ".github/scripts/parse-issue-translation-response.cjs"
- ".github/scripts/parse-issue-translation-response.test.cjs"
- ".github/workflows/enforce-issue-quality.yml"
- ".github/workflows/enforce-pr-target.yml"
- ".github/workflows/pr-labeler.yml"
- ".github/workflows/issue-triage.yml"
- ".github/workflows/issue-quality-tests.yml"
push:
paths:
- ".github/ISSUE_TEMPLATE/**"
- ".github/scripts/issue-quality.cjs"
- ".github/scripts/issue-quality.test.cjs"
- ".github/scripts/pr-quality.cjs"
- ".github/scripts/pr-quality.test.cjs"
- ".github/scripts/pr-labeler.cjs"
- ".github/scripts/pr-labeler.test.cjs"
- ".github/scripts/enforce-pr-target.test.cjs"
- ".github/scripts/issue-translation.cjs"
- ".github/scripts/issue-translation.test.cjs"
- ".github/scripts/issue-triage.cjs"
- ".github/scripts/issue-triage.test.cjs"
- ".github/scripts/parse-issue-translation-response.cjs"
- ".github/scripts/parse-issue-translation-response.test.cjs"
- ".github/workflows/enforce-issue-quality.yml"
- ".github/workflows/enforce-pr-target.yml"
- ".github/workflows/pr-labeler.yml"
- ".github/workflows/issue-triage.yml"
- ".github/workflows/issue-quality-tests.yml"
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
persist-credentials: false
- name: Run validator tests
run: |
node --test .github/scripts/issue-quality.test.cjs
node --test .github/scripts/pr-quality.test.cjs
node --test .github/scripts/pr-labeler.test.cjs
node --test .github/scripts/enforce-pr-target.test.cjs
node --test .github/scripts/issue-translation.test.cjs
node --test .github/scripts/issue-triage.test.cjs
node --test .github/scripts/parse-issue-translation-response.test.cjs
- name: Validate issue-form YAML
run: |
node -e "
const fs = require('fs');
const path = require('path');
const dir = '.github/ISSUE_TEMPLATE';
const files = fs.readdirSync(dir).filter(f => f.endsWith('.yml') && f !== 'config.yml');
const VALID_TYPES = new Set(['markdown','textarea','input','dropdown','checkboxes']);
let ok = true;
for (const file of files) {
const raw = fs.readFileSync(path.join(dir, file), 'utf8');
// Minimal YAML validation: check for required keys and valid types.
if (!raw.includes('name:')) { console.error(file + ': missing name'); ok = false; }
if (!raw.includes('description:')) { console.error(file + ': missing description'); ok = false; }
if (!raw.includes('body:')) { console.error(file + ': missing body'); ok = false; }
// Check element types.
const types = [...raw.matchAll(/type:\s*(\w+)/g)].map(m => m[1]);
for (const t of types) {
if (!VALID_TYPES.has(t)) { console.error(file + ': unsupported element type: ' + t); ok = false; }
}
// Check unique IDs.
const ids = [...raw.matchAll(/id:\s*([\w-]+)/g)].map(m => m[1]);
const dupes = ids.filter((id, i) => ids.indexOf(id) !== i);
if (dupes.length) { console.error(file + ': duplicate IDs: ' + dupes.join(', ')); ok = false; }
console.log(file + ': ' + types.length + ' elements, ' + ids.length + ' IDs — OK');
}
if (!ok) process.exit(1);
console.log('All issue forms valid.');
"