Skip to content

Commit 852bcb2

Browse files
committed
Add demo migrations to test GitHub comment generation
- Add normal comment generation test (001_demo_normal_comment.sql) - Add SQL truncation test (002_demo_sql_truncation.sql) - Add GitHub Actions workflow for testing - Add documentation explaining the demo This allows testing of the GitHub comment size limit fix in a real PR environment to capture screenshots for documentation.
1 parent 16723cf commit 852bcb2

File tree

4 files changed

+177
-0
lines changed

4 files changed

+177
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Demo GitHub Comment Generation
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
paths:
7+
- 'migrations/**'
8+
- 'DEMO_README.md'
9+
10+
jobs:
11+
test-github-comments:
12+
runs-on: ubuntu-latest
13+
if: github.event.pull_request.head.repo.full_name == github.repository
14+
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Rust
20+
uses: dtolnay/rust-toolchain@stable
21+
22+
- name: Build Squawk
23+
run: cargo build --release
24+
25+
- name: Test Migration 1 (Normal Comment)
26+
run: |
27+
echo "Testing normal comment generation..."
28+
./target/release/squawk migrations/001_demo_normal_comment.sql
29+
30+
- name: Test Migration 2 (SQL Truncation)
31+
run: |
32+
echo "Testing SQL truncation..."
33+
./target/release/squawk migrations/002_demo_sql_truncation.sql
34+
35+
- name: Comment on PR - Migration 1
36+
if: github.event_name == 'pull_request'
37+
run: |
38+
echo "Would comment on PR with results from migration 1"
39+
# In a real scenario, this would use the upload-to-github command
40+
# ./target/release/squawk upload-to-github migrations/001_demo_normal_comment.sql
41+
42+
- name: Comment on PR - Migration 2
43+
if: github.event_name == 'pull_request'
44+
run: |
45+
echo "Would comment on PR with results from migration 2"
46+
# In a real scenario, this would use the upload-to-github command
47+
# ./target/release/squawk upload-to-github migrations/002_demo_sql_truncation.sql

DEMO_README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# GitHub Comment Generation Demo
2+
3+
This PR demonstrates the fix for issue #603 where Squawk fails to upload large linting reports to GitHub with a 422 "Unprocessable Entity" error.
4+
5+
## Test Migrations
6+
7+
This PR includes test migrations that demonstrate different GitHub comment generation scenarios:
8+
9+
### 1. `001_demo_normal_comment.sql`
10+
- **Purpose**: Demonstrates normal GitHub comment generation
11+
- **Expected Behavior**: Full SQL content displayed with violations
12+
- **Violations**: 4-6 typical migration violations
13+
- **Comment Size**: Within normal limits
14+
15+
### 2. `002_demo_sql_truncation.sql`
16+
- **Purpose**: Demonstrates SQL truncation functionality
17+
- **Expected Behavior**: SQL content truncated at 50 lines with notice
18+
- **Violations**: Multiple violations detected across all lines
19+
- **Comment Size**: Reduced due to truncation
20+
21+
## Key Features Being Tested
22+
23+
1. **Size Limit Enforcement**: Pre-check comment size before GitHub API calls
24+
2. **Smart Truncation**: Limit SQL preview while preserving all violations
25+
3. **Summary Mode**: For very large reports, switch to summary-only mode
26+
4. **Error Handling**: Better user feedback for size limit issues
27+
28+
## Expected GitHub Comments
29+
30+
Each migration should generate a different style of GitHub comment:
31+
32+
- **Normal comments** for typical cases (< 65K chars)
33+
- **Truncated comments** for medium files (SQL truncated at 50 lines)
34+
- **Summary comments** for very large files (no SQL content, just violations)
35+
36+
## Testing Instructions
37+
38+
1. The GitHub Actions workflow should run Squawk on these migrations
39+
2. Comments should be posted to this PR demonstrating each behavior
40+
3. All comments should be within GitHub's 65,536 character limit
41+
4. All violations should be properly detected and reported
42+
43+
This allows reviewers to see the actual behavior of the fix in a real GitHub environment.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Demo Migration 001: Normal GitHub Comment Generation
2+
-- This migration demonstrates typical violations that should generate
3+
-- a normal GitHub comment with full SQL content
4+
5+
BEGIN;
6+
7+
-- Adding NOT NULL field without default (violation)
8+
ALTER TABLE users ADD COLUMN email varchar(255) NOT NULL;
9+
10+
-- Adding foreign key constraint (violation)
11+
ALTER TABLE posts ADD CONSTRAINT fk_posts_user_id
12+
FOREIGN KEY (user_id) REFERENCES users(id);
13+
14+
-- Changing column type (violation)
15+
ALTER TABLE products ALTER COLUMN price TYPE decimal(10,2);
16+
17+
-- Adding field with default value (violation)
18+
ALTER TABLE users ADD COLUMN status integer DEFAULT 1;
19+
20+
COMMIT;
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
-- Demo Migration 002: SQL Truncation Test
2+
-- This migration has 60+ lines to test the SQL truncation feature
3+
-- Expected: SQL content truncated at 50 lines with truncation notice
4+
5+
BEGIN;
6+
7+
-- Adding NOT NULL field (violation at the beginning)
8+
ALTER TABLE users ADD COLUMN phone varchar(20) NOT NULL;
9+
10+
-- Generate enough content to trigger truncation
11+
CREATE TABLE demo_table_1 (
12+
id SERIAL PRIMARY KEY,
13+
name VARCHAR(100),
14+
created_at TIMESTAMP DEFAULT NOW(),
15+
updated_at TIMESTAMP
16+
);
17+
18+
CREATE TABLE demo_table_2 (
19+
id SERIAL PRIMARY KEY,
20+
name VARCHAR(100),
21+
created_at TIMESTAMP DEFAULT NOW(),
22+
updated_at TIMESTAMP
23+
);
24+
25+
CREATE TABLE demo_table_3 (
26+
id SERIAL PRIMARY KEY,
27+
name VARCHAR(100),
28+
created_at TIMESTAMP DEFAULT NOW(),
29+
updated_at TIMESTAMP
30+
);
31+
32+
CREATE TABLE demo_table_4 (
33+
id SERIAL PRIMARY KEY,
34+
name VARCHAR(100),
35+
created_at TIMESTAMP DEFAULT NOW(),
36+
updated_at TIMESTAMP
37+
);
38+
39+
CREATE TABLE demo_table_5 (
40+
id SERIAL PRIMARY KEY,
41+
name VARCHAR(100),
42+
created_at TIMESTAMP DEFAULT NOW(),
43+
updated_at TIMESTAMP
44+
);
45+
46+
CREATE TABLE demo_table_6 (
47+
id SERIAL PRIMARY KEY,
48+
name VARCHAR(100),
49+
created_at TIMESTAMP DEFAULT NOW(),
50+
updated_at TIMESTAMP
51+
);
52+
53+
-- Line 51: This should be truncated
54+
-- Line 52: This should be truncated
55+
-- Line 53: This should be truncated
56+
-- Line 54: This should be truncated
57+
-- Line 55: This should be truncated
58+
-- Line 56: This should be truncated
59+
-- Line 57: This should be truncated
60+
-- Line 58: This should be truncated
61+
-- Line 59: This should be truncated
62+
-- Line 60: This should be truncated
63+
64+
-- Adding another violation at the end (should still be detected)
65+
ALTER TABLE products ALTER COLUMN description TYPE text;
66+
67+
COMMIT;

0 commit comments

Comments
 (0)