-
Notifications
You must be signed in to change notification settings - Fork 134
166 lines (142 loc) · 5.25 KB
/
Copy pathe2e.yml
File metadata and controls
166 lines (142 loc) · 5.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
name: E2E Tests — Maestro on EAS Preview APK
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]
workflow_dispatch:
concurrency:
group: e2e-${{ github.ref }}
cancel-in-progress: true
jobs:
build-preview-apk:
name: Build Preview APK via EAS
runs-on: ubuntu-latest
outputs:
apk-url: ${{ steps.wait-build.outputs.apk-url }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build Preview APK
id: eas-build
run: |
BUILD_URL=$(eas build \
--platform android \
--profile preview \
--non-interactive \
--json \
--no-wait | jq -r '.[0].buildDetailsPageUrl')
echo "build-page-url=$BUILD_URL" >> $GITHUB_OUTPUT
- name: Wait for EAS Build to complete
id: wait-build
run: |
echo "Waiting for EAS build to complete..."
for i in $(seq 1 60); do
STATUS=$(eas build:list --platform android --limit 1 --json | jq -r '.[0].status')
echo "Build status: $STATUS (attempt $i/60)"
if [ "$STATUS" = "FINISHED" ]; then
URL=$(eas build:list --platform android --limit 1 --json | jq -r '.[0].artifacts.buildUrl')
echo "apk-url=$URL" >> $GITHUB_OUTPUT
echo "✅ Build finished. APK URL: $URL"
break
elif [ "$STATUS" = "ERRORED" ] || [ "$STATUS" = "CANCELLED" ]; then
echo "❌ Build failed with status: $STATUS"
exit 1
fi
sleep 30
done
- name: Download APK
run: |
curl -L "${{ steps.wait-build.outputs.apk-url }}" -o petchain-preview.apk
- name: Upload APK artifact
uses: actions/upload-artifact@v4
with:
name: petchain-preview-apk
path: petchain-preview.apk
retention-days: 7
e2e-android:
name: Run Maestro E2E Tests
runs-on: ubuntu-latest
needs: build-preview-apk
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download Preview APK
uses: actions/download-artifact@v4
with:
name: petchain-preview-apk
- name: Enable KVM (hardware acceleration)
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
| sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Setup JDK
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17
- name: Setup Android SDK
uses: android-actions/setup-android@v3
- name: Start Android Emulator
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 33
target: google_apis
arch: x86_64
profile: pixel_6
disable-animations: true
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim
script: echo "Emulator started"
- name: Install Maestro CLI
run: |
curl -Ls "https://get.maestro.mobile.dev" | bash
echo "$HOME/.maestro/bin" >> $GITHUB_PATH
- name: Install APK on emulator
run: adb install petchain-preview.apk
- name: Run Maestro smoke test
run: maestro test .maestro/flows/smoke-test.yaml --format junit --output maestro-results.xml
continue-on-error: true
id: maestro-run
- name: Upload Maestro test results
if: always()
uses: actions/upload-artifact@v4
with:
name: maestro-test-results
path: maestro-results.xml
retention-days: 14
- name: Notify Slack — E2E Result
if: always()
uses: slackapi/slack-github-action@v1.27.0
with:
payload: |
{
"text": "${{ steps.maestro-run.outcome == 'success' && '✅' || '❌' }} *PetChain E2E Tests — ${{ steps.maestro-run.outcome == 'success' && 'PASSED' || 'FAILED' }}*",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "${{ steps.maestro-run.outcome == 'success' && '✅' || '❌' }} *Maestro E2E Tests — ${{ steps.maestro-run.outcome == 'success' && 'PASSED' || 'FAILED' }}*\n*Branch:* `${{ github.ref_name }}`\n*Commit:* <${{ github.event.head_commit.url }}|`${{ github.sha }}`>\n*Triggered by:* ${{ github.actor }}\n<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Run>"
}
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
- name: Fail if Maestro tests failed
if: steps.maestro-run.outcome == 'failure'
run: exit 1