Skip to content

Commit b41f162

Browse files
dx: compact storybook PR comment to single-line header (#9078)
## Summary Compact the Storybook build status PR comment to a single-line header with collapsible details, matching the approach from #8677. ## Changes - **Starting**: Collapsed from multi-line with build steps to `## 🎨 Storybook: ⏳ Building...` - **Completed (success)**: `## 🎨 Storybook: ✅ Built — [View Storybook](url)` with timestamp/links in `<details>` - **Completed (failure)**: `## 🎨 Storybook: ❌ Failed` with details collapsed - Removed version-bump branch check (starting comment no longer varies by branch type) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-9078-dx-compact-storybook-PR-comment-to-single-line-header-30f6d73d365081b98666c48a94542b70) by [Unito](https://www.unito.io)
1 parent 3678e65 commit b41f162

File tree

6 files changed

+41
-113
lines changed

6 files changed

+41
-113
lines changed

.github/workflows/ci-tests-e2e-forks.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
workflows: ['CI: Tests E2E']
77
types: [requested, completed]
88

9-
env:
10-
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'
11-
129
jobs:
1310
deploy-and-comment-forked-pr:
1411
runs-on: ubuntu-latest
@@ -63,8 +60,7 @@ jobs:
6360
./scripts/cicd/pr-playwright-deploy-and-comment.sh \
6461
"${{ steps.pr.outputs.result }}" \
6562
"${{ github.event.workflow_run.head_branch }}" \
66-
"starting" \
67-
"$(date -u '${{ env.DATE_FORMAT }}')"
63+
"starting"
6864
6965
- name: Download and Deploy Reports
7066
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'

.github/workflows/ci-tests-e2e.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,6 @@ jobs:
182182
- name: Checkout repository
183183
uses: actions/checkout@v6
184184

185-
- name: Get start time
186-
id: start-time
187-
run: echo "time=$(date -u '+%m/%d/%Y, %I:%M:%S %p')" >> $GITHUB_OUTPUT
188-
189185
- name: Post starting comment
190186
env:
191187
GITHUB_TOKEN: ${{ github.token }}
@@ -194,8 +190,7 @@ jobs:
194190
./scripts/cicd/pr-playwright-deploy-and-comment.sh \
195191
"${{ github.event.pull_request.number }}" \
196192
"${{ github.head_ref }}" \
197-
"starting" \
198-
"${{ steps.start-time.outputs.time }}"
193+
"starting"
199194
200195
# Deploy and comment for non-forked PRs only
201196
deploy-and-comment:

.github/workflows/ci-tests-storybook-forks.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
workflows: ['CI: Tests Storybook']
77
types: [requested, completed]
88

9-
env:
10-
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'
11-
129
jobs:
1310
deploy-and-comment-forked-pr:
1411
runs-on: ubuntu-latest
@@ -63,8 +60,7 @@ jobs:
6360
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
6461
"${{ steps.pr.outputs.result }}" \
6562
"${{ github.event.workflow_run.head_branch }}" \
66-
"starting" \
67-
"$(date -u '${{ env.DATE_FORMAT }}')"
63+
"starting"
6864
6965
- name: Download and Deploy Storybook
7066
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success'

.github/workflows/ci-tests-storybook.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ jobs:
2424
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
2525
"${{ github.event.pull_request.number }}" \
2626
"${{ github.head_ref }}" \
27-
"starting" \
28-
"$(date -u '+%m/%d/%Y, %I:%M:%S %p')"
27+
"starting"
2928
3029
# Build Storybook for all PRs (free Cloudflare deployment)
3130
storybook-build:

scripts/cicd/pr-playwright-deploy-and-comment.sh

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Deploy Playwright test reports to Cloudflare Pages and comment on PR
5-
# Usage: ./pr-playwright-deploy-and-comment.sh <pr_number> <branch_name> <status> [start_time]
5+
# Usage: ./pr-playwright-deploy-and-comment.sh <pr_number> <branch_name> <status>
66

77
# Input validation
88
# Validate PR number is numeric
@@ -31,8 +31,6 @@ case "$STATUS" in
3131
;;
3232
esac
3333

34-
START_TIME="${4:-$(date -u '+%m/%d/%Y, %I:%M:%S %p')}"
35-
3634
# Required environment variables
3735
: "${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
3836
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
@@ -135,23 +133,8 @@ post_comment() {
135133
# Main execution
136134
if [ "$STATUS" = "starting" ]; then
137135
# Post concise starting comment
138-
comment=$(cat <<EOF
139-
$COMMENT_MARKER
140-
## 🎭 Playwright Tests: ⏳ Running...
141-
142-
Tests started at $START_TIME UTC
143-
144-
<details>
145-
<summary>📊 Browser Tests</summary>
146-
147-
- **chromium**: Running...
148-
- **chromium-0.5x**: Running...
149-
- **chromium-2x**: Running...
150-
- **mobile-chrome**: Running...
151-
152-
</details>
153-
EOF
154-
)
136+
comment="$COMMENT_MARKER
137+
## 🎭 Playwright: ⏳ Running..."
155138
post_comment "$comment"
156139

157140
else
@@ -300,7 +283,7 @@ else
300283

301284
# Generate compact single-line comment
302285
comment="$COMMENT_MARKER
303-
**Playwright:** $status_icon $total_passed passed, $total_failed failed$flaky_note"
286+
## 🎭 Playwright: $status_icon $total_passed passed, $total_failed failed$flaky_note"
304287

305288
# Extract and display failed tests from all browsers (flaky tests are treated as passing)
306289
if [ $total_failed -gt 0 ]; then

scripts/cicd/pr-storybook-deploy-and-comment.sh

Lines changed: 33 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33

44
# Deploy Storybook to Cloudflare Pages and comment on PR
5-
# Usage: ./pr-storybook-deploy-and-comment.sh <pr_number> <branch_name> <status> [start_time]
5+
# Usage: ./pr-storybook-deploy-and-comment.sh <pr_number> <branch_name> <status>
66

77
# Input validation
88
# Validate PR number is numeric
@@ -31,7 +31,6 @@ case "$STATUS" in
3131
;;
3232
esac
3333

34-
START_TIME="${4:-$(date -u '+%m/%d/%Y, %I:%M:%S %p')}"
3534

3635
# Required environment variables
3736
: "${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
@@ -120,50 +119,9 @@ post_comment() {
120119

121120
# Main execution
122121
if [ "$STATUS" = "starting" ]; then
123-
# Check if this is a version-bump branch
124-
IS_VERSION_BUMP="false"
125-
if echo "$BRANCH_NAME" | grep -q "^version-bump-"; then
126-
IS_VERSION_BUMP="true"
127-
fi
128-
129-
# Post starting comment with appropriate message
130-
if [ "$IS_VERSION_BUMP" = "true" ]; then
131-
comment=$(cat <<EOF
132-
$COMMENT_MARKER
133-
## 🎨 Storybook Build Status
134-
135-
<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**
136-
137-
⏰ Started at: $START_TIME UTC
138-
139-
### 🚀 Building Storybook
140-
- 📦 Installing dependencies...
141-
- 🔧 Building Storybook components...
142-
- 🎨 Running Chromatic visual tests...
143-
144-
---
145-
⏱️ Please wait while the Storybook build is in progress...
146-
EOF
147-
)
148-
else
149-
comment=$(cat <<EOF
150-
$COMMENT_MARKER
151-
## 🎨 Storybook Build Status
152-
153-
<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**
154-
155-
⏰ Started at: $START_TIME UTC
156-
157-
### 🚀 Building Storybook
158-
- 📦 Installing dependencies...
159-
- 🔧 Building Storybook components...
160-
- 🌐 Preparing deployment to Cloudflare Pages...
161-
162-
---
163-
⏱️ Please wait while the Storybook build is in progress...
164-
EOF
165-
)
166-
fi
122+
# Post starting comment
123+
comment="$COMMENT_MARKER
124+
## 🎨 Storybook: <img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> Building..."
167125
post_comment "$comment"
168126

169127
elif [ "$STATUS" = "completed" ]; then
@@ -192,56 +150,57 @@ elif [ "$STATUS" = "completed" ]; then
192150
WORKFLOW_CONCLUSION="${WORKFLOW_CONCLUSION:-success}"
193151
WORKFLOW_URL="${WORKFLOW_URL:-}"
194152

195-
# Generate completion comment based on conclusion
153+
# Generate compact header based on conclusion
196154
if [ "$WORKFLOW_CONCLUSION" = "success" ]; then
197155
status_icon=""
198-
status_text="Build completed successfully!"
199-
footer_text="🎉 Your Storybook is ready for review!"
156+
status_text="Built"
200157
elif [ "$WORKFLOW_CONCLUSION" = "skipped" ]; then
201158
status_icon="⏭️"
202-
status_text="Build skipped."
203-
footer_text="ℹ️ Chromatic was skipped for this PR."
159+
status_text="Skipped"
204160
elif [ "$WORKFLOW_CONCLUSION" = "cancelled" ]; then
205161
status_icon="🚫"
206-
status_text="Build cancelled."
207-
footer_text="ℹ️ The Chromatic run was cancelled."
162+
status_text="Cancelled"
208163
else
209164
status_icon=""
210-
status_text="Build failed!"
211-
footer_text="⚠️ Please check the workflow logs for error details."
165+
status_text="Failed"
166+
fi
167+
168+
# Build compact header with optional storybook link
169+
header="## 🎨 Storybook: $status_icon $status_text"
170+
if [ "$deployment_url" != "Not deployed" ] && [ "$deployment_url" != "Deployment failed" ] && [ "$WORKFLOW_CONCLUSION" = "success" ]; then
171+
header="$header$deployment_url"
212172
fi
213-
214-
comment="$COMMENT_MARKER
215-
## 🎨 Storybook Build Status
216173

217-
$status_icon **$status_text**
174+
# Build details section
175+
details="<details>
176+
<summary>Details</summary>
218177
219178
⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
220179
221-
### 🔗 Links
180+
**Links**
222181
- [📊 View Workflow Run]($WORKFLOW_URL)"
223-
224-
# Add deployment status
182+
225183
if [ "$deployment_url" != "Not deployed" ]; then
226184
if [ "$deployment_url" = "Deployment failed" ]; then
227-
comment="$comment
185+
details="$details
228186
- ❌ Storybook deployment failed"
229-
elif [ "$WORKFLOW_CONCLUSION" = "success" ]; then
230-
comment="$comment
231-
- 🎨 $deployment_url"
232-
else
233-
comment="$comment
234-
- ⚠️ Build failed - $deployment_url"
187+
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
188+
details="$details
189+
- ⚠️ Build failed — $deployment_url"
235190
fi
236191
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
237-
comment="$comment
192+
details="$details
238193
- ⏭️ Storybook deployment skipped (build did not succeed)"
239194
fi
240-
241-
comment="$comment
242195

243-
---
244-
$footer_text"
196+
details="$details
197+
198+
</details>"
199+
200+
comment="$COMMENT_MARKER
201+
$header
202+
203+
$details"
245204

246205
post_comment "$comment"
247206
fi

0 commit comments

Comments
 (0)