Skip to content

Commit 30516e3

Browse files
authored
feat: ✨ tests in CI (#807)
1 parent df23eb9 commit 30516e3

31 files changed

Lines changed: 1944 additions & 867 deletions

File tree

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
name: 'Post Maestro Screenshot'
2+
description: 'Posts the final Maestro test screenshot using external image hosting'
3+
inputs:
4+
platform:
5+
description: 'Platform (ios or android)'
6+
required: true
7+
github-token:
8+
description: 'GitHub token for posting comments'
9+
required: true
10+
default: ${{ github.token }}
11+
test-outcome:
12+
description: 'Test outcome (success or failure)'
13+
required: false
14+
default: 'unknown'
15+
imgbb-api-key:
16+
description: 'ImgBB API key for image hosting'
17+
required: true
18+
19+
runs:
20+
using: 'composite'
21+
steps:
22+
- name: Check if screenshot exists
23+
id: check-screenshot
24+
shell: bash
25+
run: |
26+
# First try the expected location with new naming
27+
SS_FILE="$HOME/output/screenshots/${{ inputs.platform }}-test-result.png"
28+
29+
if [ -f "$SS_FILE" ]; then
30+
echo "exists=true" >> $GITHUB_OUTPUT
31+
echo "file_path=$SS_FILE" >> $GITHUB_OUTPUT
32+
echo "Screenshot found at $SS_FILE"
33+
else
34+
# If not found, look in the timestamped directories
35+
echo "Screenshot not found at expected location: $SS_FILE"
36+
echo "Searching for screenshots in timestamped directories..."
37+
38+
# Find the most recent timestamped directory
39+
LATEST_DIR=$(find $HOME/output -maxdepth 1 -type d -name "20*" 2>/dev/null | sort -r | head -1)
40+
41+
if [ -n "$LATEST_DIR" ]; then
42+
echo "Found timestamped directory: $LATEST_DIR"
43+
44+
# Look for screenshot matching our naming pattern (Maestro may add emojis/timestamps to the filename)
45+
# We use the name we specified: ${PLATFORM}-test-result
46+
SCREENSHOT=$(find "$LATEST_DIR" -name "*${{ inputs.platform }}-test-result*.png" 2>/dev/null | head -1)
47+
48+
if [ -z "$SCREENSHOT" ]; then
49+
# Fallback: look for any screenshot file
50+
echo "No platform-specific screenshot found, looking for any screenshot..."
51+
SCREENSHOT=$(find "$LATEST_DIR" -name "screenshot-*.png" 2>/dev/null | head -1)
52+
fi
53+
54+
if [ -n "$SCREENSHOT" ] && [ -f "$SCREENSHOT" ]; then
55+
echo "exists=true" >> $GITHUB_OUTPUT
56+
echo "file_path=$SCREENSHOT" >> $GITHUB_OUTPUT
57+
echo "Screenshot found at $SCREENSHOT"
58+
else
59+
echo "exists=false" >> $GITHUB_OUTPUT
60+
echo "No screenshots found in $LATEST_DIR"
61+
ls -la "$LATEST_DIR" || true
62+
fi
63+
else
64+
echo "exists=false" >> $GITHUB_OUTPUT
65+
echo "No timestamped directories found"
66+
echo "Listing output directory contents:"
67+
ls -lR $HOME/output/ || echo "Output directory does not exist"
68+
fi
69+
fi
70+
71+
- name: Upload screenshot to ImgBB
72+
if: steps.check-screenshot.outputs.exists == 'true' && github.event_name == 'pull_request'
73+
id: upload-screenshot
74+
uses: McCzarny/upload-image@v2.0.0
75+
with:
76+
path: ${{ steps.check-screenshot.outputs.file_path }}
77+
upload-method: imgbb
78+
api-key: ${{ inputs.imgbb-api-key }}
79+
expiration: 2592000 # 30 days
80+
81+
- name: Find Comment
82+
uses: peter-evans/find-comment@v3
83+
id: find-comment
84+
if: github.event_name == 'pull_request'
85+
with:
86+
issue-number: ${{ github.event.pull_request.number }}
87+
comment-author: 'github-actions[bot]'
88+
body-includes: End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
89+
90+
- name: Create or update PR comment (with screenshot)
91+
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && steps.upload-screenshot.outputs.url
92+
uses: peter-evans/create-or-update-comment@v4
93+
with:
94+
token: ${{ inputs.github-token }}
95+
issue-number: ${{ github.event.pull_request.number }}
96+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
97+
body: |
98+
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
99+
100+
**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
101+
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
102+
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
103+
104+
### 📸 Final Test Screenshot
105+
106+
![Maestro Test Results - ${{ inputs.platform }}](${{ steps.upload-screenshot.outputs.url }})
107+
108+
*Screenshot automatically captured from End-to-End tests and will expire in 30 days*
109+
110+
---
111+
*This comment is automatically updated on each test run.*
112+
edit-mode: replace
113+
114+
- name: Create or update PR comment (no screenshot)
115+
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists != 'true'
116+
uses: peter-evans/create-or-update-comment@v4
117+
with:
118+
token: ${{ inputs.github-token }}
119+
issue-number: ${{ github.event.pull_request.number }}
120+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
121+
body: |
122+
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
123+
124+
**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
125+
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
126+
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
127+
128+
### 📸 Final Test Screenshot
129+
130+
⚠️ No final screenshot available
131+
132+
---
133+
*This comment is automatically updated on each test run.*
134+
edit-mode: replace
135+
136+
- name: Create or update PR comment (upload failed)
137+
if: github.event_name == 'pull_request' && steps.check-screenshot.outputs.exists == 'true' && !steps.upload-screenshot.outputs.url
138+
uses: peter-evans/create-or-update-comment@v4
139+
with:
140+
token: ${{ inputs.github-token }}
141+
issue-number: ${{ github.event.pull_request.number }}
142+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
143+
body: |
144+
## 🤖 End-to-End Test Results - ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
145+
146+
**Status**: ${{ inputs.test-outcome == 'success' && '✅ Passed' || '❌ Failed' }}
147+
**Platform**: ${{ inputs.platform == 'ios' && 'iOS' || 'Android' }}
148+
**Run**: [${{ github.run_id }}](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
149+
150+
### 📸 Final Test Screenshot
151+
152+
⚠️ Screenshot was captured but failed to upload. Check workflow logs for details.
153+
154+
---
155+
*This comment is automatically updated on each test run.*
156+
edit-mode: replace
157+
158+
- name: Log screenshot status
159+
shell: bash
160+
run: |
161+
if [ "${{ steps.check-screenshot.outputs.exists }}" = "true" ]; then
162+
if [ -n "${{ steps.upload-screenshot.outputs.url }}" ]; then
163+
echo "✅ Screenshot uploaded and embedded in PR comment for ${{ inputs.platform }}"
164+
echo "🔗 Image URL: ${{ steps.upload-screenshot.outputs.url }}"
165+
echo "🗑️ Delete URL: ${{ steps.upload-screenshot.outputs.delete-url }}"
166+
else
167+
echo "❌ Screenshot upload failed for ${{ inputs.platform }}"
168+
fi
169+
else
170+
echo "⚠️ No screenshot found for ${{ inputs.platform }}"
171+
fi

.github/workflows/build-android.yml

Lines changed: 0 additions & 72 deletions
This file was deleted.

.github/workflows/build-ios.yml

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)