Skip to content

Commit

Permalink
Fix on-host test if condition (#4581)
Browse files Browse the repository at this point in the history
Also move artifact upload to separate upload action.

b/371590965
  • Loading branch information
oxve authored Dec 17, 2024
1 parent 9bafbb1 commit 9c9a8a9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 24 deletions.
17 changes: 0 additions & 17 deletions .github/actions/build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ inputs:
targets:
description: "List of ninja targets for Cobalt build."
required: true
test_artifacts_key:
description: "Artifact key used to store test artifacts."
required: true
runs:
using: "composite"
steps:
Expand Down Expand Up @@ -61,17 +58,3 @@ runs:
src/out/${{ matrix.platform }}_qa/apks/*.apk
src/out/${{ matrix.platform }}_qa/*_apk/*.apk
src/out/${{ matrix.platform }}_qa/gen/build_info.json
- name: Create Test Files Archive
if: startsWith(matrix.platform, 'linux') && matrix.config == 'devel'
run: |
set -x
cd src
tar cvf - out/${{ matrix.platform }}_${{ matrix.config }}/*tests out/${{ matrix.platform }}_${{ matrix.config }}/nplb out/${{ matrix.platform }}_${{ matrix.config }}/*.so out/${{ matrix.platform }}_${{ matrix.config }}/*.so.* out/${{ matrix.platform }}_${{ matrix.config }}/starboard/*.so.* out/${{ matrix.platform }}_${{ matrix.config }}/content/test | xz -T0 -1 -z - > test_artifacts.tar.xz
shell: bash
- name: Upload Test artifacts
if: startsWith(matrix.platform, 'linux') && matrix.config == 'devel'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test_artifacts_key }}
path: src/test_artifacts.tar.xz
retention-days: 3
35 changes: 31 additions & 4 deletions .github/actions/upload_test_artifacts/action.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
name: Test Artifact Upload
description: Uploads test archives to GCS for on-device tests.
description: Uploads test archives for on-device and on-host tests.
inputs:
on_host:
description: "Indicates if on-host test artifacts should be uploaded."
required: true
on_device:
description: "Indicates if on-device test artifacts should be uploaded."
required: true
test_artifacts_key:
description: "Artifact key used to store on-host test artifacts."
required: true
runs:
using: "composite"
steps:
- name: Set up Cloud SDK
if: inputs.on_device == 'true'
uses: isarkis/setup-gcloud@40dce7857b354839efac498d3632050f568090b6 # v1.1.1
- name: Upload Artifacts to GCS
- name: Upload Android Test Artifacts to GCS
if: inputs.on_device == 'true'
env:
WORKFLOW: ${{ github.workflow }}
run: |
set -eux
project_name=$(gcloud config get-value project)
gsutil cp "${GITHUB_WORKSPACE}"/src/out/${{ matrix.platform }}_${{ matrix.config }}/**/*.apk \
gs://"${project_name}"-test-artifacts/"${WORKFLOW}"/"${GITHUB_RUN_NUMBER}"/${{matrix.platform}}/
gsutil cp "${GITHUB_WORKSPACE}/src/out/${{ matrix.platform }}_${{ matrix.config }}/**/*.apk" \
"gs://${project_name}-test-artifacts/${WORKFLOW}/${GITHUB_RUN_NUMBER}/${{matrix.platform}}/"
shell: bash

- name: Create On-Host Test Artifacts Archive
if: inputs.on_host == 'true'
run: |
set -x
cd src
tar cvf - out/${{ matrix.platform }}_${{ matrix.config }}/*tests out/${{ matrix.platform }}_${{ matrix.config }}/nplb out/${{ matrix.platform }}_${{ matrix.config }}/*.so out/${{ matrix.platform }}_${{ matrix.config }}/*.so.* out/${{ matrix.platform }}_${{ matrix.config }}/starboard/*.so.* out/${{ matrix.platform }}_${{ matrix.config }}/content/test | xz -T0 -1 -z - > test_artifacts.tar.xz
shell: bash
- name: Upload On-Host Test Artifacts Archive
if: inputs.on_host == 'true'
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.test_artifacts_key }}
path: src/test_artifacts.tar.xz
retention-days: 3
9 changes: 6 additions & 3 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ jobs:
if: ${{ ! (startsWith(matrix.platform, 'android') && matrix.config == 'debug') }}
with:
targets: ${{ needs.initialize.outputs.targets }}
test_artifacts_key: ${{ env.TEST_ARTIFACTS_KEY }}
- name: Upload On Device Test Artifacts
if: matrix.config == 'devel' && needs.initialize.outputs.test_on_device == 'true'
- name: Upload Test Artifacts
if: matrix.config == 'devel'
uses: ./src/.github/actions/upload_test_artifacts
with:
test_artifacts_key: ${{ env.TEST_ARTIFACTS_KEY }}
on_host: ${{ needs.initialize.outputs.test_on_host }}
on_device: ${{ needs.initialize.outputs.test_on_device }}

test:
needs: [initialize, docker-build-image, build]
Expand Down

0 comments on commit 9c9a8a9

Please sign in to comment.