blob: d07f984f94d276042d45890be30b1c01d2792e23 [file] [log] [blame]
name: On Device Test
description: Runs on-device tests.
runs:
using: "composite"
steps:
- name: Install requirements
run: |
pip3 install grpcio==1.38.0 grpcio-tools==1.38.0
shell: bash
- name: Generate gRPC files
run: |
python -m grpc_tools.protoc -Itools/ --python_out=tools/ --grpc_python_out=tools/ tools/on_device_tests_gateway.proto
shell: bash
- name: Set up Cloud SDK
uses: isarkis/setup-gcloud@40dce7857b354839efac498d3632050f568090b6 # v1.1.1
- name: Set env vars
env:
WORKFLOW: ${{ github.workflow }}
run: |
echo "PROJECT_NAME=$(gcloud config get-value project)" >> $GITHUB_ENV
echo "GITHUB_RUN_NUMBER=${GITHUB_RUN_NUMBER}" >> $GITHUB_ENV
echo "WORKFLOW=${WORKFLOW}" >> $GITHUB_ENV
# Boot loader env
if [ "${COBALT_BOOTLOADER}" != "null" ]; then
echo "LOADER_CONFIG=${{ matrix.config }}" >> $GITHUB_ENV
echo "LOADER_PLATFORM=${COBALT_BOOTLOADER}" >> $GITHUB_ENV
fi
# Dimension env
if [ "${{ matrix.dimension }}" != "null" ]; then
echo "DIMENSION=${{ matrix.dimension }}" >> $GITHUB_ENV
fi
# Shard env
if [[ "${{matrix.shard}}" == 'black_box_test' || "${{matrix.shard}}" == 'evergreen_test' || "${{matrix.shard}}" == 'unit_test' ]]; then
echo "SHARD_NAME=${{ matrix.shard }}" >> $GITHUB_ENV
echo "TEST_TYPE=${{ matrix.shard }}" >> $GITHUB_ENV
else
echo "SHARD_NAME=unit_test_${{ matrix.shard }}" >> $GITHUB_ENV
echo "TEST_TYPE=unit_test" >> $GITHUB_ENV
echo "USE_SHARDING=1" >> $GITHUB_ENV
fi
shell: bash
- name: trigger ${{ env.SHARD_NAME }} tests on ${{ matrix.platform }} platform
env:
GITHUB_SHA: ${{ github.sha }}
GITHUB_TOKEN: ${{ github.token }}
GITHUB_PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
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 }}
run: |
set -uxe
SESSION_ID=$(
python3 tools/on_device_tests_gateway_client.py \
--token ${GITHUB_TOKEN} \
--change_id "${GITHUB_PR_HEAD_SHA:-$GITHUB_SHA}" \
trigger \
--test_type ${{ env.TEST_TYPE }} \
--platform ${{ matrix.target_platform }} \
--config ${{ matrix.config }} \
--tag cobalt_github_${GITHUB_EVENT_NAME} \
--builder_name github_${{ matrix.platform }}_tests \
--build_number ${GITHUB_RUN_NUMBER} \
${LOADER_PLATFORM:+"--loader_config" "$LOADER_CONFIG"} \
${LOADER_PLATFORM:+"--loader_platform" "$LOADER_PLATFORM"} \
${DIMENSION:+"--dimension" "$DIMENSION"} \
${USE_SHARDING:+"--unittest_shard_index" "${{ matrix.shard }}"} \
${ON_DEVICE_TEST_ATTEMPTS:+"--test_attempts" "$ON_DEVICE_TEST_ATTEMPTS"} \
--archive_path gs://${PROJECT_NAME}-test-artifacts/${WORKFLOW}/${GITHUB_RUN_NUMBER}/${{ matrix.platform }}_${{ matrix.config }}/artifacts.tar \
--label github \
--label ${GITHUB_EVENT_NAME} \
--label ${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}
)
echo "SESSION_ID=$SESSION_ID" >> $GITHUB_ENV
shell: bash
- name: watch ${{ env.SHARD_NAME }} tests on ${{ matrix.platform }} platform
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_SHA: ${{ github.sha }}
run: |
set -uxe
python3 tools/on_device_tests_gateway_client.py \
--token "${GITHUB_TOKEN}" \
--change_id "${GITHUB_SHA}" \
watch ${{ env.SESSION_ID }}
shell: bash