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
171 changes: 171 additions & 0 deletions .github/actions/post-maestro-screenshot/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
name: 'Post Maestro Screenshot'
description: 'Posts the final Maestro test screenshot using external image hosting'
inputs:
platform:
description: 'Platform (ios or android)'
required: true
github-token:
description: 'GitHub token for posting comments'
required: true
default: ${{ github.token }}
test-outcome:
description: 'Test outcome (success or failure)'
required: false
default: 'unknown'
imgbb-api-key:
description: 'ImgBB API key for image hosting'
required: true

runs:
using: 'composite'
steps:
- name: Check if screenshot exists
id: check-screenshot
shell: bash
run: |
# First try the expected location with new naming
SS_FILE="$HOME/output/screenshots/${{ inputs.platform }}-test-result.png"

if [ -f "$SS_FILE" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "file_path=$SS_FILE" >> $GITHUB_OUTPUT
echo "Screenshot found at $SS_FILE"
else
# If not found, look in the timestamped directories
echo "Screenshot not found at expected location: $SS_FILE"
echo "Searching for screenshots in timestamped directories..."

# Find the most recent timestamped directory
LATEST_DIR=$(find $HOME/output -maxdepth 1 -type d -name "20*" 2>/dev/null | sort -r | head -1)

if [ -n "$LATEST_DIR" ]; then
echo "Found timestamped directory: $LATEST_DIR"

# Look for screenshot matching our naming pattern (Maestro may add emojis/timestamps to the filename)
# We use the name we specified: ${PLATFORM}-test-result
SCREENSHOT=$(find "$LATEST_DIR" -name "*${{ inputs.platform }}-test-result*.png" 2>/dev/null | head -1)

if [ -z "$SCREENSHOT" ]; then
# Fallback: look for any screenshot file
echo "No platform-specific screenshot found, looking for any screenshot..."
SCREENSHOT=$(find "$LATEST_DIR" -name "screenshot-*.png" 2>/dev/null | head -1)
fi

if [ -n "$SCREENSHOT" ] && [ -f "$SCREENSHOT" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
echo "file_path=$SCREENSHOT" >> $GITHUB_OUTPUT
echo "Screenshot found at $SCREENSHOT"
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "No screenshots found in $LATEST_DIR"
ls -la "$LATEST_DIR" || true
fi
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "No timestamped directories found"
echo "Listing output directory contents:"
ls -lR $HOME/output/ || echo "Output directory does not exist"
fi
fi

- name: Upload screenshot to ImgBB
if: steps.check-screenshot.outputs.exists == 'true' && github.event_name == 'pull_request'
id: upload-screenshot
uses: McCzarny/upload-image@v2.0.0
with:
path: ${{ steps.check-screenshot.outputs.file_path }}
upload-method: imgbb
api-key: ${{ inputs.imgbb-api-key }}
expiration: 2592000 # 30 days

- name: Find Comment
uses: peter-evans/find-comment@v3
id: find-comment
if: github.event_name == 'pull_request'
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}

- name: Create or update PR comment (with screenshot)
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && steps.upload-screenshot.outputs.url
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ inputs.github-token }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: |
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}

**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

### 📸 Final Test Screenshot

![Maestro Test Results - ${{ inputs.platform }}](${{ steps.upload-screenshot.outputs.url }})

*Screenshot automatically captured from End-to-End tests and will expire in 30 days*

---
*This comment is automatically updated on each test run.*
edit-mode: replace

- name: Create or update PR comment (no screenshot)
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists != 'true'
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ inputs.github-token }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: |
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}

**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

### 📸 Final Test Screenshot

⚠️ No final screenshot available

---
*This comment is automatically updated on each test run.*
edit-mode: replace

- name: Create or update PR comment (upload failed)
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && !steps.upload-screenshot.outputs.url
uses: peter-evans/create-or-update-comment@v4
with:
token: ${{ inputs.github-token }}
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
body: |
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}

**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})

### 📸 Final Test Screenshot

⚠️ Screenshot was captured but failed to upload. Check workflow logs for details.

---
*This comment is automatically updated on each test run.*
edit-mode: replace

- name: Log screenshot status
shell: bash
run: |
if [ "${{ steps.check-screenshot.outputs.exists }}" = "true" ]; then
if [ -n "${{ steps.upload-screenshot.outputs.url }}" ]; then
echo "✅ Screenshot uploaded and embedded in PR comment for ${{ inputs.platform }}"
echo "🔗 Image URL: ${{ steps.upload-screenshot.outputs.url }}"
echo "🗑️ Delete URL: ${{ steps.upload-screenshot.outputs.delete-url }}"
else
echo "❌ Screenshot upload failed for ${{ inputs.platform }}"
fi
else
echo "⚠️ No screenshot found for ${{ inputs.platform }}"
fi
72 changes: 0 additions & 72 deletions .github/workflows/build-android.yml

This file was deleted.

94 changes: 0 additions & 94 deletions .github/workflows/build-ios.yml

This file was deleted.

Loading
Loading