-
Notifications
You must be signed in to change notification settings - Fork 1
106 lines (93 loc) · 3.3 KB
/
analysis.yml
File metadata and controls
106 lines (93 loc) · 3.3 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
name: Analysis
on:
pull_request:
types: [opened, synchronize, reopened]
jobs:
decompile-diff:
name: Decompile Diff
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-all-crates: true
- name: Build azoth CLI
run: cargo build --bin azoth --release
- name: Run decompile-diff analysis
id: analysis
run: |
DEPLOYMENT="examples/escrow-bytecode/artifacts/erc20_deployment.hex"
RUNTIME="examples/escrow-bytecode/artifacts/erc20_runtime.hex"
if [[ ! -f "$DEPLOYMENT" ]] || [[ ! -f "$RUNTIME" ]]; then
echo "::error::Bytecode artifacts not found"
exit 1
fi
# Run decompile-diff, capturing statistics to stdout and diff to file
RUST_LOG=error ./target/release/azoth decompile-diff \
--deployment "$DEPLOYMENT" \
--runtime "$RUNTIME" \
--iterations 50 \
--changed-only \
-o decompile-diff.txt \
> statistics.txt 2>&1 || true
- name: Create or update PR comment
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const statistics = fs.readFileSync('statistics.txt', 'utf8');
const diff = fs.readFileSync('decompile-diff.txt', 'utf8');
const sha = context.payload.pull_request.head.sha.substring(0, 7);
const commentMarker = '<!-- decompile-diff-analysis -->';
const body = [
commentMarker,
'## Decompile Diff Analysis',
'',
statistics,
'',
'<details>',
'<summary>Full Diff Output</summary>',
'',
'```diff',
diff,
'```',
'',
'</details>',
'',
`<sub>Commit ${sha}</sub>`,
].join('\n');
// Find existing comment
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const existingComment = comments.find(c => c.body.includes(commentMarker));
if (existingComment) {
// Update existing comment
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: body,
});
console.log(`Updated existing comment ${existingComment.id}`);
} else {
// Create new comment
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body,
});
console.log('Created new comment');
}