Refactor PR workflows to not fail (#2145)
This commit is contained in:
64
.github/workflows/android-device-test.yml
vendored
64
.github/workflows/android-device-test.yml
vendored
@@ -7,7 +7,21 @@ on:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
create-check:
|
||||
pre_job:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
should_skip: ${{ steps.check_skip.outputs.should_skip }}
|
||||
steps:
|
||||
# if android-build in android-ci was skipped, the android-device-test job can be skipped entirely
|
||||
- id: check_skip
|
||||
run: |
|
||||
conclusion=$(curl ${{ github.event.workflow_run.jobs_url }} | jq -r '.jobs[] | select(.name == "android-build").conclusion')
|
||||
should_skip=$([ "$conclusion" = "skipped" ] && echo "true" || echo "false")
|
||||
echo "should_skip=$should_skip" >> "$GITHUB_OUTPUT"
|
||||
|
||||
android-device-test:
|
||||
needs: pre_job
|
||||
if: needs.pre_job.outputs.should_skip == 'false'
|
||||
strategy:
|
||||
max-parallel: 2
|
||||
matrix:
|
||||
@@ -34,29 +48,48 @@ jobs:
|
||||
}
|
||||
]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.workflow_run.event == 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Sanity check, test files should exist
|
||||
uses: andstor/file-existence-action@v2.0.0
|
||||
with:
|
||||
files: "${{ matrix.test.testFile }}, ${{ matrix.test.appFile }}"
|
||||
fail: true
|
||||
|
||||
# get comment from PR
|
||||
|
||||
- uses: ./.github/actions/get-pr-number
|
||||
id: get-pr-number
|
||||
|
||||
- name: Generate token
|
||||
if: matrix.test.name == 'Android Benchmark' && steps.get-pr-number.outputs.pr-number
|
||||
id: generate_token
|
||||
uses: tibdex/github-app-token@v2
|
||||
with:
|
||||
app_id: ${{ secrets.MAPLIBRE_NATIVE_BOT_APP_ID }}
|
||||
private_key: ${{ secrets.MAPLIBRE_NATIVE_BOT_PRIVATE_KEY }}
|
||||
|
||||
- uses: ./.github/actions/get-pr-number
|
||||
id: get-pr-number
|
||||
|
||||
- name: Check if comment on PR contains '!benchmark android'
|
||||
if: matrix.test.name == 'Android Benchmark' && steps.get-pr-number.outputs.pr-number
|
||||
uses: peter-evans/find-comment@v3
|
||||
id: fc
|
||||
id: benchmark_comment
|
||||
with:
|
||||
issue-number: ${{ steps.get-pr-number.outputs.pr-number }}
|
||||
body-regex: '^!benchmark.*android.*$'
|
||||
|
||||
- name: Should we run this device test?
|
||||
# always run when something was merged into main
|
||||
# run benchmark when comment with '!benchmark android' exists in PR
|
||||
if: |
|
||||
(github.event.workflow_run.head_branch == 'main' && github.event.workflow_run.event == 'push') ||
|
||||
matrix.test.name == 'Android Benchmark' && steps.benchmark_comment.outputs.comment-id ||
|
||||
matrix.test.name != 'Android Benchmark'
|
||||
run:
|
||||
echo "run_device_test=true" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: LouisBrunner/checks-action@v2.0.0
|
||||
if: matrix.test.name != 'Android Benchmark' || steps.fc.outputs.comment-id
|
||||
if: env.run_device_test == 'true'
|
||||
id: create_check
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
@@ -66,19 +99,12 @@ jobs:
|
||||
sha: ${{ github.event.workflow_run.head_sha }}
|
||||
|
||||
- uses: ./.github/actions/download-workflow-run-artifact
|
||||
if: matrix.test.name != 'Android Benchmark' || steps.fc.outputs.comment-id
|
||||
if: env.run_device_test == 'true'
|
||||
with:
|
||||
artifact-name: ${{ matrix.test.artifactName }}
|
||||
|
||||
- name: Check if test files exist (otherwise the parent workflow was skipped)
|
||||
if: matrix.test.name != 'Android Benchmark' || steps.fc.outputs.comment-id
|
||||
id: check_files
|
||||
uses: andstor/file-existence-action@v2.0.0
|
||||
with:
|
||||
files: "${{ matrix.test.testFile }}, ${{ matrix.test.appFile }}"
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
if: matrix.test.name == 'Android Benchmark'
|
||||
if: env.run_device_test == 'true' && matrix.test.name == 'Android Benchmark'
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
@@ -89,7 +115,7 @@ jobs:
|
||||
role-session-name: MySessionName
|
||||
|
||||
- name: Upload external data for benchmark
|
||||
if: matrix.test.name == 'Android Benchmark'
|
||||
if: env.run_device_test == 'true' && matrix.test.name == 'Android Benchmark'
|
||||
run: |
|
||||
export RESULTS_API=${{ secrets.MLN_RESULTS_API }}
|
||||
export AWS_DEVICE_FARM_PROJECT_ARN=${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}
|
||||
@@ -97,7 +123,7 @@ jobs:
|
||||
echo external_data_arn="$upload_arn" >> "$GITHUB_ENV"
|
||||
|
||||
- uses: ./.github/actions/aws-device-farm-run
|
||||
if: steps.check_files.outputs.files_exists == 'true' && (matrix.test.name != 'Android Benchmark' || steps.fc.outputs.comment-id)
|
||||
if: env.run_device_test == 'true'
|
||||
with:
|
||||
name: ${{ matrix.test.name }}
|
||||
appType: ANDROID_APP
|
||||
@@ -115,7 +141,7 @@ jobs:
|
||||
testSpecArn: ${{ matrix.test.testSpecArn }}
|
||||
|
||||
- uses: LouisBrunner/checks-action@v2.0.0
|
||||
if: always() && (matrix.test.name != 'Android Benchmark' || steps.fc.outputs.comment-id)
|
||||
if: always() && env.run_device_test == 'true'
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
check_id: ${{ steps.create_check.outputs.check_id }}
|
||||
|
||||
Reference in New Issue
Block a user