-
Notifications
You must be signed in to change notification settings - Fork 2
57 lines (57 loc) · 2.09 KB
/
codegraph-impact.yml
File metadata and controls
57 lines (57 loc) · 2.09 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
name: Codegraph Impact Analysis
on: [pull_request]
jobs:
impact:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: '22'
- name: Install dependencies
shell: bash
run: |
for attempt in 1 2 3; do
npm install && break
if [ "$attempt" -lt 3 ]; then
echo "::warning::npm install attempt $attempt failed, retrying in 15s..."
sleep 15
else
echo "::error::npm install failed after 3 attempts"
exit 1
fi
done
- uses: actions/cache@v5
with:
path: .codegraph/
key: codegraph-${{ hashFiles('src/**', 'package.json') }}
restore-keys: codegraph-
- run: npx codegraph build
- name: Run impact analysis
run: |
npx codegraph diff-impact --ref origin/${{ github.base_ref }} --json -T > impact.json || echo '{"affectedFiles":[],"summary":null}' > impact.json
- name: Comment on PR
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const impact = JSON.parse(fs.readFileSync('impact.json', 'utf-8'));
if (!impact.summary) {
console.log('No impact data to report.');
return;
}
const body = `## Codegraph Impact Analysis\n\n` +
`**${impact.summary.functionsChanged} functions changed** -> ` +
`**${impact.summary.callersAffected} callers affected** across ` +
`**${impact.summary.filesAffected} files**.\n\n` +
(impact.affectedFunctions || []).slice(0, 20).map(f =>
`- \`${f.name}\` in \`${f.file}:${f.line}\` (${f.transitiveCallers} transitive callers)`
).join('\n');
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body
});