From 49bb2c3fdddb1f981931fde4a862d34879f1e165 Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Tue, 17 Oct 2023 10:46:05 +0200 Subject: [PATCH] CI fixes and improvements (#1765) --- .github/workflows/android-device-test.yml | 16 +++-- .github/workflows/ios-device-test.yml | 80 ++++------------------- .github/workflows/pr-bloaty.yml | 2 + 3 files changed, 25 insertions(+), 73 deletions(-) diff --git a/.github/workflows/android-device-test.yml b/.github/workflows/android-device-test.yml index 9107b0dfe89..f5db0a0c383 100644 --- a/.github/workflows/android-device-test.yml +++ b/.github/workflows/android-device-test.yml @@ -17,11 +17,6 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: ./.github/actions/download-workflow-run-artifact - with: - artifact-name: ${{ matrix.test.artifactName }} - expect-files: "${{ matrix.test.testFile }}, ${{ matrix.test.appFile }}" - - name: Generate token id: generate_token uses: tibdex/github-app-token@v2 @@ -38,7 +33,18 @@ jobs: name: ${{ matrix.test.name }} sha: ${{ github.event.workflow_run.head_sha }} + - uses: ./.github/actions/download-workflow-run-artifact + with: + artifact-name: ${{ matrix.test.artifactName }} + + - name: Check if test files exist (otherwise the parent workflow was skipped) + id: check_files + uses: andstor/file-existence-action@v2.0.0 + with: + files: "${{ matrix.test.testFile }}, ${{ matrix.test.appFile }}" + - uses: ./.github/actions/aws-device-farm-run + if: steps.check_files.outputs.files_exists == 'true' with: name: ${{ matrix.test.name }} appType: ANDROID_APP diff --git a/.github/workflows/ios-device-test.yml b/.github/workflows/ios-device-test.yml index 42cc26cc501..ecb90bd5d85 100644 --- a/.github/workflows/ios-device-test.yml +++ b/.github/workflows/ios-device-test.yml @@ -46,76 +46,20 @@ jobs: with: files: "${{ matrix.test.xcTestFile }}, ${{ matrix.test.ipaFile }}" - - name: Configure AWS Credentials + - uses: ./.github/actions/aws-device-farm-run if: steps.check_files.outputs.files_exists == 'true' - uses: aws-actions/configure-aws-credentials@v4 with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - aws-region: us-west-2 - role-to-assume: ${{ vars.AWS_ROLE_TO_ASSUME }} - role-duration-seconds: 3600 - role-session-name: MySessionName - - - name: Create upload app - if: steps.check_files.outputs.files_exists == 'true' - run: | - response=$(aws devicefarm create-upload --type IOS_APP --name ${{ matrix.test.ipaFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) - echo "$response" - arn="$(jq -r '.upload.arn' <<< "$response")" - url="$(jq -r '.upload.url' <<< "$response")" - echo "app_arn=$arn" >> "$GITHUB_ENV" - echo "app_url=$url" >> "$GITHUB_ENV" - - - name: Create upload test package - if: steps.check_files.outputs.files_exists == 'true' - run: | - response=$(aws devicefarm create-upload --type XCTEST_TEST_PACKAGE --name ${{ matrix.test.xcTestFile }} --project-arn ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }}) - echo "$response" - arn="$(jq -r '.upload.arn' <<< "$response")" - url="$(jq -r '.upload.url' <<< "$response")" - echo "test_package_arn=$arn" >> "$GITHUB_ENV" - echo "test_package_url=$url" >> "$GITHUB_ENV" - - - name: Upload ${{ matrix.test.name }} - if: steps.check_files.outputs.files_exists == 'true' - run: | - curl -T ${{ matrix.test.ipaFile }} "${{ env.app_url }}" - curl -T ${{ matrix.test.xcTestFile }} "${{ env.test_package_url }}" - - max_checks=10 - sleep_time=5 - - check_status() { - aws devicefarm get-upload --arn "$1" | jq -r '.upload.status' - } - - while ((max_checks--)); do - status_app="$(check_status "${{ env.app_arn }}")" - status_test_package="$(check_status "${{ env.test_package_arn }}")" - - echo status_app="$status_app" - echo status_test_package="$status_test_package" - - if [[ "$status_app" == "SUCCEEDED" && "$status_test_package" == "SUCCEEDED" ]]; then - exit 0 - fi - - sleep $sleep_time - done - - - name: Schedule test run - if: steps.check_files.outputs.files_exists == 'true' - uses: realm/aws-devicefarm/test-application@master - with: - name: MapLibre Native ${{ matrix.test.name }} - project_arn: ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }} - device_pool_arn: ${{ vars.AWS_DEVICE_FARM_IPHONE_DEVICE_POOL_ARN }} - app_arn: ${{ env.app_arn }} - app_type: IOS_APP - test_type: XCTEST - test_package_arn: ${{ env.test_package_arn }} - timeout: 28800 + name: ${{ matrix.test.name }} + appType: IOS_APP + appFile: ${{ matrix.test.ipaFile }} + testFile: ${{ matrix.test.xcTestFile }} + testPackageType: XCTEST_TEST_PACKAGE + testType: XCTEST + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_ROLE_TO_ASSUME: ${{ vars.AWS_ROLE_TO_ASSUME }} + AWS_DEVICE_FARM_PROJECT_ARN: ${{ vars.AWS_DEVICE_FARM_PROJECT_ARN }} + AWS_DEVICE_FARM_DEVICE_POOL_ARN: ${{ vars.AWS_DEVICE_FARM_IPHONE_DEVICE_POOL_ARN }} - uses: LouisBrunner/checks-action@v1.6.2 if: always() diff --git a/.github/workflows/pr-bloaty.yml b/.github/workflows/pr-bloaty.yml index f4700da4688..0655d1bce88 100644 --- a/.github/workflows/pr-bloaty.yml +++ b/.github/workflows/pr-bloaty.yml @@ -19,6 +19,8 @@ jobs: pr-bloaty: runs-on: ubuntu-22.04 steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/download-workflow-run-artifact with: artifact-name: mbgl-render