-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (140 loc) · 4.8 KB
/
docs-review.yml
File metadata and controls
175 lines (140 loc) · 4.8 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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Documentation Review
on:
pull_request:
paths:
- 'docs/**'
- '*.md'
push:
branches:
- main
paths:
- 'docs/**'
- '*.md'
workflow_dispatch:
jobs:
review-docs:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install PDM
run: pip install pdm
- name: Install dependencies
run: pdm install
- name: Build documentation
run: pdm run docs
continue-on-error: true
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Claude Code
run: npm install -g @anthropic-ai/claude-code
- name: Review documentation with Claude Code
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: |
# Create the review prompt
cat > /tmp/review-prompt.txt << 'PROMPT_EOF'
Review the ChipFlow documentation for quality, accuracy, and consistency.
## Context
ChipFlow is a platform for designing and building hardware systems (SoCs) using Python and Amaranth HDL.
## Review the following:
1. **Technical Accuracy**
- Do code examples work with the current API?
- Are command-line examples correct?
- Are configuration file examples valid?
2. **Consistency**
- Is terminology used consistently?
- Are code style conventions consistent?
3. **Flow and Organization**
- Does the getting-started guide provide a clear path?
- Do topics build logically on each other?
4. **Completeness**
- Are all major features documented?
- Are there gaps that would confuse users?
## Output Format
Provide findings as:
## Summary
[1-2 sentence assessment]
## Issues Found
### Critical
[Issues preventing users from following docs]
### Major
[Significant inaccuracies]
### Minor
[Small improvements]
## Recommendations
[Top 3-5 actionable improvements]
Focus on docs/source/ and .md files. Report actual issues only.
PROMPT_EOF
# Run Claude Code in print mode (non-interactive)
claude --print "$(cat /tmp/review-prompt.txt)" > review-results.txt 2>&1 || true
# Show the results
cat review-results.txt
- name: Process review results
id: process-review
run: |
if [ -f review-results.txt ] && [ -s review-results.txt ]; then
# Use heredoc to handle multiline output
{
echo 'review<<EOF'
cat review-results.txt
echo 'EOF'
} >> $GITHUB_OUTPUT
else
echo "review=Documentation review did not produce output" >> $GITHUB_OUTPUT
fi
- name: Comment on PR
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const review = process.env.REVIEW_CONTENT;
// Find existing comment from this workflow
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const botComment = comments.find(comment =>
comment.user.type === 'Bot' &&
comment.body.includes('## 📚 Documentation Review')
);
const body = `## 📚 Documentation Review
${review}
---
*This review was automatically generated by Claude Code*`;
if (botComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: botComment.id,
body: body
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: body
});
}
env:
REVIEW_CONTENT: ${{ steps.process-review.outputs.review }}
- name: Upload review results
uses: actions/upload-artifact@v4
if: always()
with:
name: docs-review-results
path: review-results.txt
retention-days: 30