-
Notifications
You must be signed in to change notification settings - Fork 1
Screenshot feature #23
Changes from all commits
7d04f7d
905ea34
63889f4
e9eefb3
5d6888d
ec21c34
1a65cb1
3b3c88e
6417bc4
31ae72b
7f16749
39e4fb1
a56a3ab
edefe7b
a202684
96305e6
cf62c61
bc9fddb
ace0b77
9571ef0
20585b1
d621a5d
1c554c8
96339ab
11a009e
4346c3d
fb094a9
3287807
edc849d
79b94cd
1518ae1
4bfe625
892d49f
bd4d4ff
e6570eb
cf992cf
f2d64e7
5930382
1b97bb6
a62b880
17102b8
c0a14df
9a94ddf
3b66f9b
8fa3703
a4f3527
0e32018
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| name: GUI Screenshots in PR | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, reopened, synchronize] | ||
|
|
||
| permissions: | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| capture-screenshots: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 3 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install Playwright | ||
| run: | | ||
| npm install playwright | ||
| npx playwright install chromium # Fix: Install Chromium explicitly | ||
|
|
||
| - name: Create screenshots directory | ||
| run: mkdir -p screenshots | ||
|
|
||
| - name: Capture screenshots | ||
| run: node scripts/screenshot.js | ||
|
|
||
| - name: Generate base64 images | ||
| id: screenshots | ||
| run: | | ||
| IMAGES_MARKDOWN="" | ||
| for file in screenshots/*.jpg; do | ||
| [ -e "$file" ] || continue | ||
| base64_data=$(base64 -w0 "$file") | ||
| IMAGES_MARKDOWN+="\n\n" | ||
| done | ||
| # Escape newlines for GitHub output | ||
| IMAGES_MARKDOWN="${IMAGES_MARKDOWN//$'\n'/'%0A'}" | ||
| echo "images=$IMAGES_MARKDOWN" >> $GITHUB_OUTPUT | ||
|
|
||
| - name: Post images to PR | ||
| uses: marocchino/sticky-pull-request-comment@v2 | ||
| with: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| header: gui-screenshots | ||
| message: | | ||
| ## 🖼️ Automated UI Preview | ||
| ${{ steps.screenshots.outputs.images }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,46 @@ | ||||||||||||||||||
| const { chromium } = require('playwright'); | ||||||||||||||||||
|
|
||||||||||||||||||
| (async () => { | ||||||||||||||||||
| let browser; | ||||||||||||||||||
| try { | ||||||||||||||||||
| // Launch Chromium (explicitly specify) | ||||||||||||||||||
| browser = await chromium.launch({ | ||||||||||||||||||
| channel: 'chromium', | ||||||||||||||||||
| headless: true | ||||||||||||||||||
|
Comment on lines
+7
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| const page = await browser.newPage(); | ||||||||||||||||||
| await page.setViewportSize({ width: 800, height: 600 }); | ||||||||||||||||||
|
|
||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| // Capture homepage | ||||||||||||||||||
| await page.goto('https://example.com', { | ||||||||||||||||||
| waitUntil: 'networkidle', | ||||||||||||||||||
| timeout: 60000 | ||||||||||||||||||
|
Comment on lines
+16
to
+18
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| }); | ||||||||||||||||||
| await page.screenshot({ | ||||||||||||||||||
| path: 'screenshots/home.jpg', | ||||||||||||||||||
| type: 'jpeg', | ||||||||||||||||||
| quality: 70 | ||||||||||||||||||
|
Comment on lines
+20
to
+23
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| // Capture about page | ||||||||||||||||||
| await page.goto('https://example.com/about', { | ||||||||||||||||||
| waitUntil: 'networkidle', | ||||||||||||||||||
| timeout: 60000 | ||||||||||||||||||
|
Comment on lines
+27
to
+29
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| }); | ||||||||||||||||||
| await page.screenshot({ | ||||||||||||||||||
| path: 'screenshots/about.jpg', | ||||||||||||||||||
| type: 'jpeg', | ||||||||||||||||||
| quality: 70 | ||||||||||||||||||
|
Comment on lines
+31
to
+34
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| }); | ||||||||||||||||||
|
|
||||||||||||||||||
| console.log('✅ Screenshots captured successfully!'); | ||||||||||||||||||
|
Comment on lines
+36
to
+37
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| } catch (error) { | ||||||||||||||||||
| console.error('❌ Screenshot failed:', error); | ||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [prettier] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| process.exit(1); | ||||||||||||||||||
| } finally { | ||||||||||||||||||
| if (browser) { | ||||||||||||||||||
| await browser.close(); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| })(); | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[prettier] reported by reviewdog 🐶