Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .github/workflows/ci-tests-e2e-forks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
workflows: ['CI: Tests E2E']
types: [requested, completed]

env:
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'

jobs:
deploy-and-comment-forked-pr:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,8 +60,7 @@ jobs:
./scripts/cicd/pr-playwright-deploy-and-comment.sh \
"${{ steps.pr.outputs.result }}" \
"${{ github.event.workflow_run.head_branch }}" \
"starting" \
"$(date -u '${{ env.DATE_FORMAT }}')"
"starting"
- name: Download and Deploy Reports
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed'
Expand Down
7 changes: 1 addition & 6 deletions .github/workflows/ci-tests-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v6

- name: Get start time
id: start-time
run: echo "time=$(date -u '+%m/%d/%Y, %I:%M:%S %p')" >> $GITHUB_OUTPUT

- name: Post starting comment
env:
GITHUB_TOKEN: ${{ github.token }}
Expand All @@ -194,8 +190,7 @@ jobs:
./scripts/cicd/pr-playwright-deploy-and-comment.sh \
"${{ github.event.pull_request.number }}" \
"${{ github.head_ref }}" \
"starting" \
"${{ steps.start-time.outputs.time }}"
"starting"
# Deploy and comment for non-forked PRs only
deploy-and-comment:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/ci-tests-storybook-forks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ on:
workflows: ['CI: Tests Storybook']
types: [requested, completed]

env:
DATE_FORMAT: '+%m/%d/%Y, %I:%M:%S %p'

jobs:
deploy-and-comment-forked-pr:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -63,8 +60,7 @@ jobs:
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
"${{ steps.pr.outputs.result }}" \
"${{ github.event.workflow_run.head_branch }}" \
"starting" \
"$(date -u '${{ env.DATE_FORMAT }}')"
"starting"
- name: Download and Deploy Storybook
if: steps.pr.outputs.result != 'null' && github.event.action == 'completed' && github.event.workflow_run.conclusion == 'success'
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/ci-tests-storybook.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ jobs:
./scripts/cicd/pr-storybook-deploy-and-comment.sh \
"${{ github.event.pull_request.number }}" \
"${{ github.head_ref }}" \
"starting" \
"$(date -u '+%m/%d/%Y, %I:%M:%S %p')"
"starting"
# Build Storybook for all PRs (free Cloudflare deployment)
storybook-build:
Expand Down
25 changes: 4 additions & 21 deletions scripts/cicd/pr-playwright-deploy-and-comment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

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

# Input validation
# Validate PR number is numeric
Expand Down Expand Up @@ -31,8 +31,6 @@ case "$STATUS" in
;;
esac

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

# Required environment variables
: "${GITHUB_TOKEN:?GITHUB_TOKEN is required}"
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
Expand Down Expand Up @@ -135,23 +133,8 @@ post_comment() {
# Main execution
if [ "$STATUS" = "starting" ]; then
# Post concise starting comment
comment=$(cat <<EOF
$COMMENT_MARKER
## 🎭 Playwright Tests: ⏳ Running...

Tests started at $START_TIME UTC

<details>
<summary>πŸ“Š Browser Tests</summary>

- **chromium**: Running...
- **chromium-0.5x**: Running...
- **chromium-2x**: Running...
- **mobile-chrome**: Running...

</details>
EOF
)
comment="$COMMENT_MARKER
## 🎭 Playwright: ⏳ Running..."
post_comment "$comment"

else
Expand Down Expand Up @@ -300,7 +283,7 @@ else

# Generate compact single-line comment
comment="$COMMENT_MARKER
**Playwright:** $status_icon $total_passed passed, $total_failed failed$flaky_note"
## 🎭 Playwright: $status_icon $total_passed passed, $total_failed failed$flaky_note"

# Extract and display failed tests from all browsers (flaky tests are treated as passing)
if [ $total_failed -gt 0 ]; then
Expand Down
107 changes: 33 additions & 74 deletions scripts/cicd/pr-storybook-deploy-and-comment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -e

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

# Input validation
# Validate PR number is numeric
Expand Down Expand Up @@ -31,7 +31,6 @@ case "$STATUS" in
;;
esac

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

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

# Main execution
if [ "$STATUS" = "starting" ]; then
# Check if this is a version-bump branch
IS_VERSION_BUMP="false"
if echo "$BRANCH_NAME" | grep -q "^version-bump-"; then
IS_VERSION_BUMP="true"
fi

# Post starting comment with appropriate message
if [ "$IS_VERSION_BUMP" = "true" ]; then
comment=$(cat <<EOF
$COMMENT_MARKER
## 🎨 Storybook Build Status

<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**

⏰ Started at: $START_TIME UTC

### πŸš€ Building Storybook
- πŸ“¦ Installing dependencies...
- πŸ”§ Building Storybook components...
- 🎨 Running Chromatic visual tests...

---
⏱️ Please wait while the Storybook build is in progress...
EOF
)
else
comment=$(cat <<EOF
$COMMENT_MARKER
## 🎨 Storybook Build Status

<img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> **Build is starting...**

⏰ Started at: $START_TIME UTC

### πŸš€ Building Storybook
- πŸ“¦ Installing dependencies...
- πŸ”§ Building Storybook components...
- 🌐 Preparing deployment to Cloudflare Pages...

---
⏱️ Please wait while the Storybook build is in progress...
EOF
)
fi
# Post starting comment
comment="$COMMENT_MARKER
## 🎨 Storybook: <img alt='loading' src='https://github.com/user-attachments/assets/755c86ee-e445-4ea8-bc2c-cca85df48686' width='14px' height='14px'/> Building..."
post_comment "$comment"

elif [ "$STATUS" = "completed" ]; then
Expand Down Expand Up @@ -192,56 +150,57 @@ elif [ "$STATUS" = "completed" ]; then
WORKFLOW_CONCLUSION="${WORKFLOW_CONCLUSION:-success}"
WORKFLOW_URL="${WORKFLOW_URL:-}"

# Generate completion comment based on conclusion
# Generate compact header based on conclusion
if [ "$WORKFLOW_CONCLUSION" = "success" ]; then
status_icon="βœ…"
status_text="Build completed successfully!"
footer_text="πŸŽ‰ Your Storybook is ready for review!"
status_text="Built"
elif [ "$WORKFLOW_CONCLUSION" = "skipped" ]; then
status_icon="⏭️"
status_text="Build skipped."
footer_text="ℹ️ Chromatic was skipped for this PR."
status_text="Skipped"
elif [ "$WORKFLOW_CONCLUSION" = "cancelled" ]; then
status_icon="🚫"
status_text="Build cancelled."
footer_text="ℹ️ The Chromatic run was cancelled."
status_text="Cancelled"
else
status_icon="❌"
status_text="Build failed!"
footer_text="⚠️ Please check the workflow logs for error details."
status_text="Failed"
fi

# Build compact header with optional storybook link
header="## 🎨 Storybook: $status_icon $status_text"
if [ "$deployment_url" != "Not deployed" ] && [ "$deployment_url" != "Deployment failed" ] && [ "$WORKFLOW_CONCLUSION" = "success" ]; then
header="$header β€” $deployment_url"
fi

comment="$COMMENT_MARKER
## 🎨 Storybook Build Status

$status_icon **$status_text**
# Build details section
details="<details>
<summary>Details</summary>

⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC

### πŸ”— Links
**Links**
- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"

# Add deployment status

if [ "$deployment_url" != "Not deployed" ]; then
if [ "$deployment_url" = "Deployment failed" ]; then
comment="$comment
details="$details
- ❌ Storybook deployment failed"
elif [ "$WORKFLOW_CONCLUSION" = "success" ]; then
comment="$comment
- 🎨 $deployment_url"
else
comment="$comment
- ⚠️ Build failed - $deployment_url"
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
details="$details
- ⚠️ Build failed β€” $deployment_url"
fi
elif [ "$WORKFLOW_CONCLUSION" != "success" ]; then
comment="$comment
details="$details
- ⏭️ Storybook deployment skipped (build did not succeed)"
fi

comment="$comment

---
$footer_text"
details="$details

</details>"

comment="$COMMENT_MARKER
$header

$details"
Comment on lines +174 to +203
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟑 Minor

Avoid emitting an empty workflow-run link.

If WORKFLOW_URL is unset, the current output renders a dead markdown link. Guard the link so the details block doesn’t include an empty URL.

πŸ”§ Proposed fix
-    details="<details>
-<summary>Details</summary>
-
-⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
-
-**Links**
-- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"
+    details="<details>
+<summary>Details</summary>
+
+⏰ Completed at: $(date -u '+%m/%d/%Y, %I:%M:%S %p') UTC
+
+**Links**"
+
+    if [ -n "$WORKFLOW_URL" ]; then
+        details="$details
+- [πŸ“Š View Workflow Run]($WORKFLOW_URL)"
+    fi
πŸ€– Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/cicd/pr-storybook-deploy-and-comment.sh` around lines 175 - 204, The
details block currently always includes a markdown link using $WORKFLOW_URL
which may be empty; update the construction of the details string so the "[πŸ“Š
View Workflow Run]" link is only appended when WORKFLOW_URL is non-empty (e.g.,
test $WORKFLOW_URL and append the "- [πŸ“Š View Workflow Run]($WORKFLOW_URL)" line
into details only if it exists), keeping the rest of the details/header assembly
(variables details, header, comment) unchanged.


post_comment "$comment"
fi
Loading