diff --git a/.github/actions/on_device_tests/action.yaml b/.github/actions/on_device_tests/action.yaml index 4b69d75472be9..a0e53033c4c9b 100644 --- a/.github/actions/on_device_tests/action.yaml +++ b/.github/actions/on_device_tests/action.yaml @@ -7,6 +7,9 @@ inputs: results_dir: description: "Path to directory where test results are saved." required: true + test_results_key: + description: "Artifact key used to store test results." + required: true runs: using: "composite" @@ -88,9 +91,10 @@ runs: gsutil cp -r "${GCS_RESULTS_PATH}/" "${TEST_LOGS}" echo "TEST_LOGS=${TEST_LOGS}" >> $GITHUB_ENV shell: bash - - name: Archive Test Logs + - name: Archive Test Results uses: actions/upload-artifact@v3 if: always() with: - name: Test log - path: ${{ env.TEST_LOGS }} + name: ${{ inputs.test_results_key }} + path: ${{ env.TEST_LOGS }}/ + diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index be4776fe88b94..981b9ae1196c0 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -193,6 +193,54 @@ jobs: test_artifacts_key: ${{ env.TEST_ARTIFACTS_KEY }} on_host: ${{ needs.initialize.outputs.test_on_host }} on_device: ${{ needs.initialize.outputs.test_on_device }} + + # Runs on-device integration and unit tests. + on-device-test: + needs: [initialize, build] + # Run ODT when on_device label is applied on PR. + # Also, run ODT on push and schedule if not explicitly disabled via repo vars. + if: needs.initialize.outputs.test_on_device == 'true' && + (( + github.event_name == 'pull_request' && + contains(github.event.pull_request.labels.*.name, 'on_device') ) || (( + inputs.nightly == 'true' || github.event_name == 'schedule') && + vars.RUN_ODT_TESTS_ON_NIGHTLY != 'False') || + ( github.event_name == 'push' && vars.RUN_ODT_TESTS_ON_POSTSUBMIT != 'False' + )) + runs-on: [self-hosted, odt-runner] + name: ${{ matrix.name }}_on_device + permissions: {} + strategy: + fail-fast: false + matrix: + platform: ${{ fromJson(needs.initialize.outputs.platforms) }} + config: [devel] + include: ${{ fromJson(needs.initialize.outputs.includes) }} + env: + TEST_RESULTS_DIR: ${{ matrix.name }}_test_results + TEST_RESULTS_KEY: ${{ matrix.platform }}_${{ matrix.name }}_test_results + steps: + - name: Checkout + uses: kaidokert/checkout@v3.5.999 + timeout-minutes: 30 + with: + fetch-depth: 1 + persist-credentials: false + - name: Run On-Device Tests (${{ matrix.shard }}) + id: on-device-tests + uses: ./.github/actions/on_device_tests + with: + test_artifacts_key: ${{ env.TEST_ARTIFACTS_KEY }} + gcs_results_path: gs://cobalt-unittest-storage/results/${{ matrix.name }}/${{ github.run_id }} + results_dir: ${{ env.TEST_RESULTS_DIR }} + - name: Process Test Results + if: always() + uses: ./.github/actions/process_test_results + with: + results_dir: ${{ env.TEST_RESULTS_DIR }} + datadog_api_key: ${{ secrets.DD_API_KEY }} + is_postsubmit: ${{ github.event_name == 'schedule' || github.event_name == 'push' }} + continue-on-error: true on-host-test: needs: [initialize, docker-build-image, build] @@ -229,7 +277,11 @@ jobs: test-upload: needs: [initialize, docker-build-image, build, on-host-test] - if: always() && needs.initialize.outputs.test_on_host == 'true' + if: always() && + ( + needs.initialize.outputs.test_on_host == 'true' || + needs.initialize.outputs.test_on_device == 'true' + ) permissions: {} runs-on: [self-hosted, chrobalt-linux-runner] name: ${{ matrix.name }}_tests_upload @@ -277,49 +329,3 @@ jobs: run: | echo "Failing because at least one test shard had errors." exit 1 - - # Runs on-device integration and unit tests. - on-device-test: - needs: [initialize, build] - # Run ODT when on_device label is applied on PR. - # Also, run ODT on push and schedule if not explicitly disabled via repo vars. - if: needs.initialize.outputs.test_on_device == 'true' && - (( - github.event_name == 'pull_request' && - contains(github.event.pull_request.labels.*.name, 'on_device') ) || (( - inputs.nightly == 'true' || github.event_name == 'schedule') && - vars.RUN_ODT_TESTS_ON_NIGHTLY != 'False') || - ( github.event_name == 'push' && vars.RUN_ODT_TESTS_ON_POSTSUBMIT != 'False' - )) - runs-on: [self-hosted, odt-runner] - name: ${{ matrix.name }}_on_device - permissions: {} - strategy: - fail-fast: false - matrix: - platform: ${{ fromJson(needs.initialize.outputs.platforms) }} - config: [devel] - include: ${{ fromJson(needs.initialize.outputs.includes) }} - env: - TEST_RESULTS_DIR: ${{ matrix.name }}_test_results - steps: - - name: Checkout - uses: kaidokert/checkout@v3.5.999 - timeout-minutes: 30 - with: - fetch-depth: 1 - persist-credentials: false - - name: Run On-Device Tests (${{ matrix.shard }}) - id: on-device-tests - uses: ./.github/actions/on_device_tests - with: - gcs_results_path: gs://cobalt-unittest-storage/results/${{ matrix.name }}/${{ github.run_id }} - results_dir: ${{ env.TEST_RESULTS_DIR }} - - name: Process Test Results - if: always() - uses: ./.github/actions/process_test_results - with: - results_dir: ${{ env.TEST_RESULTS_DIR }} - datadog_api_key: ${{ secrets.DD_API_KEY }} - is_postsubmit: ${{ github.event_name == 'schedule' || github.event_name == 'push' }} - continue-on-error: true