55 artifact-folder :
66 description : Device Farm artifact folder produced by the test action
77 required : true
8+ aws-region :
9+ description : AWS region where the Device Farm run was scheduled
10+ required : false
11+ console-url :
12+ description : AWS Device Farm console URL for the run
13+ required : false
814 platform :
915 description : Platform label used in filenames and log output
1016 required : true
17+ run-arn :
18+ description : AWS Device Farm run ARN
19+ required : false
1120 test-step-outcome :
1221 description : Outcome of the upstream Device Farm execution step
1322 required : false
@@ -23,6 +32,77 @@ outputs:
2332runs :
2433 using : composite
2534 steps :
35+ - name : Print Device Farm result tree
36+ if : inputs.run-arn != ''
37+ shell : bash
38+ run : |
39+ set -euo pipefail
40+
41+ RUN_ARN="${{ inputs.run-arn }}"
42+ AWS_REGION="${{ inputs.aws-region }}"
43+ CONSOLE_URL="${{ inputs.console-url }}"
44+
45+ echo "===== Device Farm run ====="
46+ echo "Run ARN: $RUN_ARN"
47+ if [[ -n "$CONSOLE_URL" ]]; then
48+ echo "Console URL: $CONSOLE_URL"
49+ fi
50+
51+ if [[ -z "$AWS_REGION" ]]; then
52+ echo "No AWS region was provided; skipping Device Farm result tree." >&2
53+ exit 0
54+ fi
55+
56+ if ! command -v aws >/dev/null 2>&1 || ! command -v jq >/dev/null 2>&1; then
57+ echo "aws and jq are required to print the Device Farm result tree." >&2
58+ exit 0
59+ fi
60+
61+ JOBS_JSON="$(aws devicefarm list-jobs --region "$AWS_REGION" --arn "$RUN_ARN" --output json || true)"
62+ if [[ -z "$JOBS_JSON" ]]; then
63+ echo "Could not list Device Farm jobs." >&2
64+ exit 0
65+ fi
66+
67+ echo "Jobs:"
68+ jq -r '
69+ .jobs[]
70+ | "- \(.name): status=\(.status) result=\(.result // "UNKNOWN") counters=\(.counters)"
71+ ' <<< "$JOBS_JSON"
72+
73+ while IFS= read -r JOB_ARN; do
74+ [[ -z "$JOB_ARN" ]] && continue
75+
76+ SUITES_JSON="$(aws devicefarm list-suites --region "$AWS_REGION" --arn "$JOB_ARN" --output json || true)"
77+ if [[ -z "$SUITES_JSON" ]]; then
78+ echo "Could not list suites for job $JOB_ARN." >&2
79+ continue
80+ fi
81+
82+ echo "Suites for job $JOB_ARN:"
83+ jq -r '
84+ .suites[]
85+ | "- \(.name): status=\(.status) result=\(.result // "UNKNOWN") counters=\(.counters)"
86+ ' <<< "$SUITES_JSON"
87+
88+ while IFS= read -r SUITE_ARN; do
89+ [[ -z "$SUITE_ARN" ]] && continue
90+
91+ TESTS_JSON="$(aws devicefarm list-tests --region "$AWS_REGION" --arn "$SUITE_ARN" --output json || true)"
92+ if [[ -z "$TESTS_JSON" ]]; then
93+ echo "Could not list tests for suite $SUITE_ARN." >&2
94+ continue
95+ fi
96+
97+ jq -r '
98+ .tests[]
99+ | " - \(.name): status=\(.status) result=\(.result // "UNKNOWN") counters=\(.counters)"
100+ + (if (.message // "") != "" then " message=\(.message)" else "" end)
101+ ' <<< "$TESTS_JSON"
102+ done < <(jq -r '.suites[].arn' <<< "$SUITES_JSON")
103+ done < <(jq -r '.jobs[].arn' <<< "$JOBS_JSON")
104+ echo "===== End Device Farm run ====="
105+
26106 - name : Find Harness JUnit result
27107 id : find-harness-junit
28108 shell : bash
@@ -31,11 +111,14 @@ runs:
31111 ARTIFACT_DIR="${{ inputs.artifact-folder }}"
32112 PLATFORM="${{ inputs.platform }}"
33113 WORKSPACE_JUNIT=".github/test-results/harness-results-${PLATFORM}.junit.xml"
34- bash "$GITHUB_ACTION_PATH/../../scripts/find-devicefarm-artifact.sh" \
114+ if bash "$GITHUB_ACTION_PATH/../../scripts/find-devicefarm-artifact.sh" \
35115 "$ARTIFACT_DIR" \
36116 'harness-results.junit.xml' \
37- "$WORKSPACE_JUNIT"
38- echo "junit_file=$WORKSPACE_JUNIT" >> "$GITHUB_OUTPUT"
117+ "$WORKSPACE_JUNIT"; then
118+ echo "junit_file=$WORKSPACE_JUNIT" >> "$GITHUB_OUTPUT"
119+ else
120+ echo "junit_file=" >> "$GITHUB_OUTPUT"
121+ fi
39122
40123 - name : Find Harness output log
41124 id : find-harness-log
@@ -45,11 +128,14 @@ runs:
45128 ARTIFACT_DIR="${{ inputs.artifact-folder }}"
46129 PLATFORM="${{ inputs.platform }}"
47130 WORKSPACE_LOG=".github/test-results/harness-output-${PLATFORM}.log"
48- bash "$GITHUB_ACTION_PATH/../../scripts/find-devicefarm-artifact.sh" \
131+ if bash "$GITHUB_ACTION_PATH/../../scripts/find-devicefarm-artifact.sh" \
49132 "$ARTIFACT_DIR" \
50133 'harness-output.log' \
51- "$WORKSPACE_LOG"
52- echo "log_file=$WORKSPACE_LOG" >> "$GITHUB_OUTPUT"
134+ "$WORKSPACE_LOG"; then
135+ echo "log_file=$WORKSPACE_LOG" >> "$GITHUB_OUTPUT"
136+ else
137+ echo "log_file=" >> "$GITHUB_OUTPUT"
138+ fi
53139
54140 - name : Publish Harness test results
55141 id : publish-harness-results
@@ -71,11 +157,67 @@ runs:
71157 set -euo pipefail
72158 LOG_FILE="${{ steps.find-harness-log.outputs.log_file }}"
73159 PLATFORM="${{ inputs.platform }}"
160+ if [[ -n "$LOG_FILE" ]]; then
161+ echo "===== Harness ${PLATFORM} output log ====="
162+ cat "$LOG_FILE"
163+ echo "===== End Harness ${PLATFORM} output log ====="
164+ else
165+ echo "No Harness ${PLATFORM} output log was found in Device Farm artifacts."
166+ fi
167+
168+ - name : Print Device Farm raw artifacts
169+ if : always()
170+ shell : bash
171+ run : |
172+ set -euo pipefail
173+
174+ ARTIFACT_DIR="${{ inputs.artifact-folder }}"
175+ TEST_STEP_OUTCOME="${{ inputs.test-step-outcome }}"
176+ JUNIT_FILE="${{ steps.find-harness-junit.outputs.junit_file }}"
177+ LOG_FILE="${{ steps.find-harness-log.outputs.log_file }}"
178+
179+ if [[ "$TEST_STEP_OUTCOME" != "failure" && -n "$JUNIT_FILE" && -n "$LOG_FILE" ]]; then
180+ exit 0
181+ fi
182+
183+ if [[ -z "$ARTIFACT_DIR" || ! -d "$ARTIFACT_DIR" ]]; then
184+ echo "Device Farm artifact folder missing: '$ARTIFACT_DIR'" >&2
185+ exit 0
186+ fi
187+
188+ echo "===== Device Farm artifact files ====="
189+ find "$ARTIFACT_DIR" -type f | sort
190+ echo "===== End Device Farm artifact files ====="
191+
192+ while IFS= read -r FILE; do
193+ NAME="$(basename "$FILE")"
194+ case "$NAME" in
195+ *"Test spec output.txt"|*"Test spec timestamped output.txt"|*"Customer Artifacts Log.txt")
196+ echo "===== $NAME ====="
197+ cat "$FILE"
198+ echo "===== End $NAME ====="
199+ ;;
200+ *"Logcat.logcat"|*"Syslog.log"|*"xcodebuild.log")
201+ echo "===== Last 400 lines of $NAME ====="
202+ tail -n 400 "$FILE"
203+ echo "===== End $NAME ====="
204+ ;;
205+ esac
206+ done < <(find "$ARTIFACT_DIR" -type f | sort)
207+
208+ - name : Validate Device Farm result
209+ if : always()
210+ shell : bash
211+ run : |
212+ set -euo pipefail
74213 PUBLISH_OUTCOME="${{ steps.publish-harness-results.outcome }}"
75214 TEST_STEP_OUTCOME="${{ inputs.test-step-outcome }}"
76- echo "===== Harness ${PLATFORM} output log ====="
77- cat "$LOG_FILE"
78- echo "===== End Harness ${PLATFORM} output log ====="
215+ JUNIT_FILE="${{ steps.find-harness-junit.outputs.junit_file }}"
216+
217+ if [[ -z "$JUNIT_FILE" ]]; then
218+ echo "Harness JUnit result was not found in Device Farm artifacts." >&2
219+ exit 1
220+ fi
79221
80222 if [[ "$PUBLISH_OUTCOME" == "failure" ]]; then
81223 echo "Harness test result publication reported failures." >&2
0 commit comments