Skip to content

Commit 082aaf1

Browse files
authored
Merge pull request #8 from chitcommit/copilot/create-cicd-integration-examples
Add CI/CD integration examples for automated code review
2 parents c2fe3ca + 6e0230e commit 082aaf1

10 files changed

Lines changed: 2342 additions & 0 deletions

File tree

.github/workflows/billy-review.yml

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
name: Billy Code Review
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
paths:
7+
- '**.js'
8+
- '**.ts'
9+
- '**.jsx'
10+
- '**.tsx'
11+
- '**.py'
12+
- '**.java'
13+
- '**.go'
14+
- '**.rs'
15+
- '**.rb'
16+
- '**.php'
17+
- '**.cpp'
18+
- '**.c'
19+
- '**.cs'
20+
21+
jobs:
22+
billy-review:
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
pull-requests: write
27+
28+
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
31+
with:
32+
fetch-depth: 0
33+
34+
- name: Get changed files
35+
id: changed-files
36+
uses: tj-actions/changed-files@v41
37+
with:
38+
files: |
39+
**.js
40+
**.ts
41+
**.jsx
42+
**.tsx
43+
**.py
44+
**.java
45+
**.go
46+
**.rs
47+
**.rb
48+
**.php
49+
**.cpp
50+
**.c
51+
**.cs
52+
53+
- name: Review changed files with Billy
54+
if: steps.changed-files.outputs.any_changed == 'true'
55+
env:
56+
BILLY_API_URL: ${{ secrets.BILLY_API_URL || 'https://billy.chitty.cc' }}
57+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58+
run: |
59+
# Initialize review results
60+
REVIEW_COMMENT="## 💩 Billy's Code Review\n\n"
61+
REVIEW_COMMENT+="> Calling BS on your BS code since 2024\n\n"
62+
63+
# Track if we found any issues
64+
FOUND_ISSUES=false
65+
66+
# Review each changed file
67+
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
68+
echo "Reviewing: $file"
69+
70+
# Detect language from extension
71+
ext="${file##*.}"
72+
case "$ext" in
73+
js) lang="javascript" ;;
74+
ts) lang="typescript" ;;
75+
jsx) lang="javascript" ;;
76+
tsx) lang="typescript" ;;
77+
py) lang="python" ;;
78+
java) lang="java" ;;
79+
go) lang="go" ;;
80+
rs) lang="rust" ;;
81+
rb) lang="ruby" ;;
82+
php) lang="php" ;;
83+
cpp|cc|cxx) lang="cpp" ;;
84+
c) lang="c" ;;
85+
cs) lang="csharp" ;;
86+
*) lang="unknown" ;;
87+
esac
88+
89+
# Read file content
90+
if [ ! -f "$file" ]; then
91+
echo "File not found: $file"
92+
continue
93+
fi
94+
95+
# Read file content and create JSON payload with proper escaping
96+
payload=$(jq -n \
97+
--rawfile code "$file" \
98+
--arg language "$lang" \
99+
--arg context "File: $file (GitHub PR Review)" \
100+
'{code: $code, language: $language, context: $context}')
101+
102+
# Call Billy's API
103+
response=$(curl -s -X POST "$BILLY_API_URL/review" \
104+
-H "Content-Type: application/json" \
105+
-d "$payload")
106+
107+
# Check if we got a valid response
108+
if [ $? -eq 0 ] && [ -n "$response" ]; then
109+
review=$(echo "$response" | jq -r '.review // empty')
110+
111+
if [ -n "$review" ]; then
112+
FOUND_ISSUES=true
113+
REVIEW_COMMENT+="### 📄 \`$file\`\n\n"
114+
REVIEW_COMMENT+="\`\`\`\n$review\n\`\`\`\n\n"
115+
REVIEW_COMMENT+="---\n\n"
116+
fi
117+
else
118+
echo "Failed to get review for $file"
119+
fi
120+
done
121+
122+
# Post review comment if we found issues
123+
if [ "$FOUND_ISSUES" = true ]; then
124+
REVIEW_COMMENT+="\n\n**Billy says:** 💩 BS detected and called out. You're welcome.\n\n"
125+
REVIEW_COMMENT+="_Powered by [Billy Bullshit](https://billy.chitty.cc) - Your brutally honest code reviewer_"
126+
127+
# Post comment to PR
128+
curl -X POST \
129+
-H "Authorization: token $GITHUB_TOKEN" \
130+
-H "Accept: application/vnd.github.v3+json" \
131+
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
132+
-d "$(jq -n --arg body "$REVIEW_COMMENT" '{body: $body}')"
133+
134+
echo "✅ Review posted to PR"
135+
else
136+
echo "ℹ️ No issues found or no reviewable files changed"
137+
fi
138+
139+
- name: Review summary
140+
if: steps.changed-files.outputs.any_changed == 'true'
141+
run: |
142+
echo "## Billy Review Complete"
143+
echo "Reviewed ${{ steps.changed-files.outputs.all_changed_files_count }} file(s)"
144+
echo "Check PR comments for Billy's brutally honest feedback"

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,43 @@ npm run tail
339339
wrangler tail
340340
```
341341

342+
## CI/CD Integration
343+
344+
Integrate Billy into your development workflow to automatically review code in your CI/CD pipeline.
345+
346+
### Available Integrations
347+
348+
- **GitHub Actions** - Automatic PR code reviews with comments
349+
- **GitLab CI** - MR reviews with artifacts and optional comments
350+
- **Jenkins** - Pipeline integration with build artifacts
351+
- **Pre-commit Hook** - Local code review before every commit
352+
353+
### Quick Examples
354+
355+
**GitHub Actions** - Add to `.github/workflows/billy-review.yml`:
356+
```yaml
357+
name: Billy Code Review
358+
on:
359+
pull_request:
360+
types: [opened, synchronize, reopened]
361+
jobs:
362+
billy-review:
363+
runs-on: ubuntu-latest
364+
steps:
365+
- uses: actions/checkout@v4
366+
- name: Review with Billy
367+
run: |
368+
# Review changed files...
369+
```
370+
371+
**Pre-commit Hook** - Install locally:
372+
```bash
373+
cp examples/pre-commit/billy-pre-commit.sh .git/hooks/pre-commit
374+
chmod +x .git/hooks/pre-commit
375+
```
376+
377+
📚 **Full documentation**: [CI/CD Integration Guide](docs/CI_CD_INTEGRATIONS.md)
378+
342379
## Performance
343380

344381
- **Cold start**: <50ms

0 commit comments

Comments
 (0)