-
Notifications
You must be signed in to change notification settings - Fork 3
152 lines (127 loc) · 3.71 KB
/
Copy pathcode-quality.yml
File metadata and controls
152 lines (127 loc) · 3.71 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Code Quality
on:
pull_request:
branches:
- master
- release
push:
branches:
- master
- release
schedule:
- cron: '17 5 * * 1'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
dependency-review:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Review dependency changes
uses: actions/dependency-review-action@v4
with:
fail-on-severity: high
license-check: false
unit-quality:
if: github.event_name != 'schedule'
name: Unit Quality (Node ${{ matrix.node-version }})
timeout-minutes: 20
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
node-version:
- 22.x
- 24.x
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
cache: npm
- name: Install dependencies
run: npm ci
- name: Type-check source
run: npm run typecheck
- name: Run unit tests with coverage gate
run: npm run test:ci
- name: Build package
if: matrix.node-version == '24.x'
run: npm run build
- name: Upload coverage artifact
if: always() && matrix.node-version == '24.x' && hashFiles('coverage/**/*') != ''
uses: actions/upload-artifact@v7
with:
name: coverage-node-${{ matrix.node-version }}
path: coverage
- name: Publish coverage summary
if: always() && matrix.node-version == '24.x' && hashFiles('coverage/coverage-summary.json') != ''
shell: bash
run: |
node <<'EOF'
const fs = require('node:fs');
const summaryPath = 'coverage/coverage-summary.json';
const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8')).total;
const metrics = ['lines', 'functions', 'statements', 'branches'];
const rows = metrics.map((metric) => {
const value = summary[metric]?.pct ?? 0;
return `| ${metric} | ${value.toFixed(2)}% |`;
});
const markdown = [
'## Coverage Summary',
'',
'| Metric | Coverage |',
'| --- | ---: |',
...rows,
'',
'Coverage thresholds are enforced by the test runner configuration.',
'',
].join('\n');
fs.appendFileSync(process.env.GITHUB_STEP_SUMMARY, markdown);
EOF
codeql:
name: CodeQL (JavaScript/TypeScript)
timeout-minutes: 20
runs-on: ubuntu-latest
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language:
- javascript
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24.x'
cache: npm
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
build-mode: none
config-file: ./.github/codeql/codeql-config.yml
- name: Install dependencies
run: npm ci
- name: Build package
run: npm run build
- name: Perform CodeQL analysis
uses: github/codeql-action/analyze@v3
with:
category: /language:${{ matrix.language }}