-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathaction.yaml
More file actions
153 lines (147 loc) · 6.78 KB
/
Copy pathaction.yaml
File metadata and controls
153 lines (147 loc) · 6.78 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
name: On Device Test
description: Runs on-device tests.
inputs:
nightly:
description: "Indicates if this is a nightly job."
required: true
test_targets_json:
description: "The test targets in a JSON array."
required: true
gcs_results_path:
description: "GCS path for the test results."
required: true
test_results_key:
description: "Artifact key used to store test results."
required: true
test_dimensions:
description: "Test dimensions JSON string."
required: true
test_device_family:
description: "Test device family."
required: true
test_attempts:
description: "Number of attempts for the tests."
default: ""
runs:
using: "composite"
steps:
- name: Install Requirements
run: |
pip3 install --require-hashes --no-deps -r ${GITHUB_WORKSPACE}/cobalt/tools/requirements.txt
shell: bash
- name: Generate gRPC files
run: |
python -m grpc_tools.protoc -I${GITHUB_WORKSPACE}/cobalt/tools/ \
--python_out=${GITHUB_WORKSPACE}/cobalt/tools/ \
--grpc_python_out=${GITHUB_WORKSPACE}/cobalt/tools/ \
${GITHUB_WORKSPACE}/cobalt/tools/on_device_tests_gateway.proto
shell: bash
- name: Set Up Cloud SDK
uses: isarkis/setup-gcloud@40dce7857b354839efac498d3632050f568090b6 # v1.1.1
- name: Set GCS Project Name
run: |
echo "PROJECT_NAME=$(gcloud config get-value project)" >> $GITHUB_ENV
shell: bash
- name: Run Tests on ${{ matrix.platform }} Platform
env:
TEST_TARGETS_JSON: ${{ inputs.test_targets_json }}
GCS_ARTIFACTS_PATH: /bigstore/${{ env.PROJECT_NAME }}-test-artifacts/${{ github.workflow }}/${{ github.run_number }}/${{ matrix.platform }}
GITHUB_SHA: ${{ github.sha }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TRIGGERING_ACTOR: ${{ github.triggering_actor }}
GITHUB_ACTOR_ID: ${{ github.actor_id }}
GITHUB_REPO: ${{ github.repository }}
GITHUB_PR_HEAD_USER_LOGIN: ${{ github.event.pull_request.head.user.login }}
GITHUB_PR_HEAD_USER_ID: ${{ github.event.pull_request.head.user.id }}
GITHUB_COMMIT_AUTHOR_USERNAME: ${{ github.event.commits[0].author.username }}
GITHUB_COMMIT_AUTHOR_EMAIL: ${{ github.event.commits[0].author.email }}
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_RUN_NUMBER: ${{ github.run_number }}
GITHUB_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
GITHUB_WORKFLOW: ${{ github.workflow }}
TEST_ATTEMPTS: ${{ inputs.test_attempts }}
TEST_TYPE: unit_test
run: |
set -x
# TODO(oxv): Fix dimensions. Pass as json? key-value pair?
python3 -u cobalt/tools/on_device_tests_gateway_client.py \
--token ${GITHUB_TOKEN} \
trigger \
--test_type ${TEST_TYPE} \
--device_family '${{ inputs.test_device_family }}' \
--targets '${{ inputs.test_targets_json }}' \
--filter_json_dir "${GITHUB_WORKSPACE}/cobalt/testing/filters/${{ matrix.platform }}" \
--label chrobalt_on_device_test \
--label github_${GITHUB_PR_NUMBER:-postsubmit} \
--label builder-${{ matrix.platform }} \
--label builder_url-${GITHUB_RUN_URL} \
--label ${TEST_TYPE} \
--label github \
--label ${GITHUB_EVENT_NAME} \
--label ${GITHUB_WORKFLOW} \
--label actor-${GITHUB_ACTOR} \
--label actor_id-${GITHUB_ACTOR_ID} \
--label triggering_actor-${GITHUB_TRIGGERING_ACTOR} \
--label sha-${GITHUB_SHA} \
--label repository-${GITHUB_REPO} \
--label author-${GITHUB_PR_HEAD_USER_LOGIN:-$GITHUB_COMMIT_AUTHOR_USERNAME} \
--label author_id-${GITHUB_PR_HEAD_USER_ID:-$GITHUB_COMMIT_AUTHOR_EMAIL} \
--label branch:${GITHUB_REF_NAME} \
--dimensions '${{ inputs.test_dimensions }}' \
${TEST_ATTEMPTS:+"--test_attempts" "$TEST_ATTEMPTS"} \
--gcs_archive_path "${GCS_ARTIFACTS_PATH}" \
--gcs_result_path "${{ inputs.gcs_results_path }}" || {
echo "Finished running tests..."
echo "The test session failed. See logs for details."
# Fail the job so it's easy to retrigger.
exit 1
}
echo "Finished running tests..."
shell: bash
- name: Download ${{ matrix.platform }} Test Results from GCS
if: always()
env:
TEST_TARGETS_JSON: ${{ inputs.test_targets_json }}
run: |
set -uxe
shopt -s globstar nullglob
test_output="${GITHUB_WORKSPACE}/results"
echo "test_output=${test_output}" >> $GITHUB_ENV
# Test results (xml and logs) must be in a subfolder in results_dir.
# to be picked up by the test result processor.
mkdir -p "${test_output}/${{ matrix.platform }}"
gcloud storage cp -r "${{ inputs.gcs_results_path }}/" "${test_output}/${{ matrix.platform }}"
# Check for missing result xml files.
exit_code=0
readarray -t test_targets < <(echo "$TEST_TARGETS_JSON" | jq -r '.[]')
for test_target_with_path in "${test_targets[@]}"; do
# Trim path prefix (before :).
test_target=${test_target_with_path#*:}
xml_files=("${test_output}"/${{ matrix.platform }}/**/"${test_target}"*.xml)
if [[ "${#xml_files[@]}" -eq 0 ]]; then
# No matching XML results found. Check if the test target is filtered.
test_filter_file="${GITHUB_WORKSPACE}/cobalt/testing/filters/${{ matrix.platform }}/${test_target}_filter.json"
if [ ! -f "${test_filter_file}" ] || [ "$(jq -cr '.failing_tests[0]' "${test_filter_file}")" != '*' ]; then
echo "Test result xml is missing for ${test_target}."
# Try to find the crashed test in the log and create a fake junit xml for it.
log_path=("${test_output}"/${{ matrix.platform }}/**/"${test_target}"_log.txt)
xml_path=("${test_output}"/${{ matrix.platform }}/1/"${test_target}"_testoutput.xml)
python3 ${GITHUB_WORKSPACE}/.github/scripts/generate_crash_report.py "${log_path}" "${xml_path}"
exit_code=1
fi
elif grep -e '<failure' -e '<error' ${xml_files}; then
# Double-check the result XML for failures. ODT service has been known to report incorrect status.
echo "::error::Found failures in the test xml."
exit_code=1
fi
done
exit ${exit_code}
shell: bash
- name: Archive Test Results
uses: actions/upload-artifact@v4
if: always()
with:
name: ${{ inputs.test_results_key }}
path: ${{ env.test_output }}/*