Skip to content

Commit 0c1f4ef

Browse files
Fixed errors in summary
1 parent d8c38be commit 0c1f4ef

File tree

1 file changed

+25
-54
lines changed

1 file changed

+25
-54
lines changed

.github/workflows/Android_test.yml

Lines changed: 25 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ jobs:
132132
- name: Create Android test plan
133133
working-directory: Melmac
134134
run: |
135-
# If you have multiple test plans, increment this index or use a unique name
136135
PLAN_INDEX=1
137136
curl -s -X POST http://localhost:8080/test-plans \
138137
-H "Content-Type: application/json" \
@@ -242,80 +241,55 @@ jobs:
242241
continue
243242
fi
244243
245-
# Get test plan name
244+
appPackage=$(echo "$planVersion" | jq -r '.appPackage // "N/A"')
245+
mainActivity=$(echo "$planVersion" | jq -r '.mainActivity // "N/A"')
246+
executionTypeId=$(echo "$planVersion" | jq '.executionTypeExecutionTypeId // empty')
247+
appVersionId=$(echo "$planVersion" | jq '.appVersionAppVersionId // empty')
248+
deviceId=$(echo "$planVersion" | jq '.deviceDeviceId // empty')
246249
testPlanId=$(echo "$planVersion" | jq '.testPlanTestPlanId // .testPlanId // empty')
247-
testName=$(curl -s "http://localhost:8080/test-plans/$testPlanId")
248-
if ! echo "$testName" | jq empty > /dev/null 2>&1; then
249-
echo "❌ Invalid JSON for testName: $testName" >> results/summary.md
250-
log_summary
251-
continue
252-
fi
253-
testName=$(echo "$testName" | jq -r '.testName // "N/A"')
250+
appName=$(echo "$planVersion" | jq -r '.appName // "N/A"')
251+
252+
# Get testName and metricId from /test-plans/{id}
253+
planInfo=$(curl -s "http://localhost:8080/test-plans/$testPlanId")
254+
testName=$(echo "$planInfo" | jq -r '.testName // "N/A"')
255+
metricId=$(echo "$planInfo" | jq -r '.metricMetricId // empty')
254256
255-
# Get metric name (always via /metrics)
256-
metricId=$(echo "$planVersion" | jq '.metricMetricId // empty')
257+
# Get metric name
257258
metricName="N/A"
258259
if [ -n "$metricId" ] && [ "$metricId" != "null" ]; then
259-
metricResp=$(curl -s "http://localhost:8080/metrics/$metricId")
260-
if echo "$metricResp" | jq empty > /dev/null 2>&1; then
261-
metricName=$(echo "$metricResp" | jq -r '.metricName // "N/A"')
262-
else
263-
echo "❌ Invalid JSON for metric: $metricResp" >> results/summary.md
264-
log_summary
265-
fi
260+
metricName=$(curl -s "http://localhost:8080/metrics/$metricId" | jq -r '.metricName // "N/A"')
266261
fi
267262
268263
# Get device name
269-
deviceId=$(echo "$planVersion" | jq '.deviceDeviceId // empty')
270264
deviceName="N/A"
271265
if [ -n "$deviceId" ] && [ "$deviceId" != "null" ]; then
272-
deviceResp=$(curl -s "http://localhost:8080/devices/$deviceId")
273-
if echo "$deviceResp" | jq empty > /dev/null 2>&1; then
274-
deviceName=$(echo "$deviceResp" | jq -r '.deviceName // "N/A"')
275-
else
276-
echo "❌ Invalid JSON for device: $deviceResp" >> results/summary.md
277-
log_summary
278-
fi
266+
deviceName=$(curl -s "http://localhost:8080/devices/$deviceId" | jq -r '.deviceName // "N/A"')
279267
fi
280268
281-
# Get app version and app name
282-
appVersionId=$(echo "$planVersion" | jq '.appVersionAppVersionId // empty')
283-
appName="N/A"
269+
# Get app version
284270
appVersion="N/A"
285-
if [ -n "$appVersionId" ] && [ "$appVersionId" != "null" ]; then
286-
appName=$(echo "$planVersion" | jq -r '.appName // empty')
287-
if [ -n "$appName" ] && [ "$appName" != "null" ]; then
288-
versionsResp=$(curl -s "http://localhost:8080/apps/folder/$appName/versions")
289-
if echo "$versionsResp" | jq empty > /dev/null 2>&1; then
290-
appVersion=$(echo "$versionsResp" | jq -r --arg vid "$appVersionId" '.[] | select(.appVersionId == ($vid|tonumber)) | .appVersion' | head -n1)
291-
if [ -z "$appVersion" ]; then appVersion="N/A"; fi
292-
else
293-
echo "❌ Invalid JSON for app versions: $versionsResp" >> results/summary.md
294-
log_summary
295-
fi
271+
if [ -n "$appName" ] && [ "$appName" != "null" ] && [ -n "$appVersionId" ] && [ "$appVersionId" != "null" ]; then
272+
versionsResp=$(curl -s "http://localhost:8080/apps/folder/$appName/versions")
273+
if echo "$versionsResp" | jq empty > /dev/null 2>&1; then
274+
appVersion=$(echo "$versionsResp" | jq -r --arg vid "$appVersionId" '.[] | select(.appVersionId == ($vid|tonumber)) | .appVersion' | head -n1)
275+
if [ -z "$appVersion" ]; then appVersion="N/A"; fi
296276
fi
297277
fi
298278
299-
echo "- **App Name:** $appName" >> results/summary.md
300-
echo "- **App Version:** $appVersion" >> results/summary.md
301-
302-
appPackage=$(echo "$planVersion" | jq -r '.appPackage // "N/A"')
303-
mainActivity=$(echo "$planVersion" | jq -r '.mainActivity // "N/A"')
304-
305279
# Get execution type name
306-
executionTypeId=$(echo "$planVersion" | jq '.executionTypeExecutionTypeId // empty')
307280
executionTypeName="N/A"
308281
if [ -n "$metricId" ] && [ "$metricId" != "null" ] && [ -n "$executionTypeId" ] && [ "$executionTypeId" != "null" ]; then
309282
executionTypesJson=$(curl -s "http://localhost:8080/metrics/$metricId/execution-types")
310283
if echo "$executionTypesJson" | jq empty > /dev/null 2>&1; then
311284
executionTypeName=$(echo "$executionTypesJson" | jq -r --arg id "$executionTypeId" '.[] | select(.executionTypeId == ($id|tonumber)) | .executionTypeName')
312285
if [ -z "$executionTypeName" ]; then executionTypeName="N/A"; fi
313-
else
314-
echo "❌ Invalid JSON for execution types: $executionTypesJson" >> results/summary.md
315-
log_summary
316286
fi
317287
fi
318288
289+
echo "- **App Name:** $appName" >> results/summary.md
290+
echo "- **App Version:** $appVersion" >> results/summary.md
291+
echo "- **App Package:** $appPackage" >> results/summary.md
292+
echo "- **Main Activity:** $mainActivity" >> results/summary.md
319293
echo "- **Execution Type:** $executionTypeName" >> results/summary.md
320294
321295
echo "#### Test Execution: $testName" >> results/summary.md
@@ -356,9 +330,6 @@ jobs:
356330
thresholdTypeResp=$(curl -s "http://localhost:8080/threshold-types/$thresholdTypeId")
357331
if echo "$thresholdTypeResp" | jq empty > /dev/null 2>&1; then
358332
thresholdTypeName=$(echo "$thresholdTypeResp" | jq -r '.thresholdTypeName // "N/A"')
359-
else
360-
echo "❌ Invalid JSON for threshold type: $thresholdTypeResp" >> results/summary.md
361-
log_summary
362333
fi
363334
fi
364335
@@ -415,7 +386,7 @@ jobs:
415386
fi
416387
log_summary
417388
fi
418-
389+
419390
- name: Upload test results artifact
420391
if: always()
421392
uses: actions/upload-artifact@v4

0 commit comments

Comments
 (0)