Skip to content

Commit

Permalink
Merge branch 'support-running-tests-multiple-times-in-gh-droid-703'
Browse files Browse the repository at this point in the history
  • Loading branch information
albin-mullvad committed Mar 1, 2024
2 parents 22953bb + e8134f3 commit b239906
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 8 deletions.
22 changes: 17 additions & 5 deletions .github/workflows/android-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ on:
description: Run firebase tests
type: boolean
required: false
mockapi_test_repeat:
description: Mockapi test repeat
default: '1'
required: true
type: string
# Build if main is updated to ensure up-to-date caches are available
push:
branches: [main]
Expand Down Expand Up @@ -397,11 +402,14 @@ jobs:
include:
- test-type: app
path: android/app/build/outputs/apk
# Disabled due to flakiness.
#- test-type: mockapi
# path: android/test/mockapi/build/outputs/apk
test-repeat: 1
# Disabled (test-repeat='0') due to flakiness unless overridden by input.
- test-type: mockapi
path: android/test/mockapi/build/outputs/apk
test-repeat: ${{ github.event.inputs.mockapi_test_repeat || 0 }}
steps:
- name: Prepare report dir
if: ${{ matrix.test-repeat != 0 }}
id: prepare-report-dir
env:
INNER_REPORT_DIR: /tmp/${{ matrix.test-type }}-${{ github.run_id }}-${{ github.run_attempt }}
Expand All @@ -410,33 +418,37 @@ jobs:
echo "report_dir=$INNER_REPORT_DIR" >> $GITHUB_OUTPUT
- name: Checkout repository
if: ${{ matrix.test-repeat != 0 }}
uses: actions/checkout@v4

# Using v3 due to v4 being very slow for this artifact.
- uses: actions/download-artifact@v3
if: ${{ matrix.test-repeat != 0 }}
with:
name: apks
path: android/app/build/outputs/apk

# Using v3 due to v4 being very slow for this artifact.
- uses: actions/download-artifact@v3
if: ${{ matrix.test-repeat != 0 }}
with:
name: ${{ matrix.test-type }}-instrumentation-apks
path: ${{ matrix.path }}

- name: Run instrumented test script
if: ${{ matrix.test-repeat != 0 }}
shell: bash -ieo pipefail {0}
env:
AUTO_FETCH_TEST_HELPER_APKS: true
TEST_TYPE: ${{ matrix.test-type }}
BILLING_FLAVOR: oss
INFRA_FLAVOR: prod
REPORT_DIR: ${{ steps.prepare-report-dir.outputs.report_dir }}
run: ./android/scripts/run-instrumented-tests.sh
run: ./android/scripts/run-instrumented-tests-repeat.sh ${{ matrix.test-repeat }}

- name: Upload instrumentation report (${{ matrix.test-type }})
uses: actions/upload-artifact@v4
if: always()
if: ${{ matrix.test-repeat != 0 }}
with:
name: ${{ matrix.test-type }}-instrumentation-report
path: ${{ steps.prepare-report-dir.outputs.report_dir }}
Expand Down
13 changes: 10 additions & 3 deletions android/scripts/run-instrumented-tests-repeat.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
#!/usr/bin/env bash

# Help script to invoke run-instrumented-tests.sh multiple times.
#
# Usage:
# run-instrumented-tests-repeat.sh <repeat-count> [<args>]
#
# Example:
# run-instrumented-tests-repeat.sh 2 --test-type mockapi --infra-flavor prod --billing-flavor oss

set -eu

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

TEST_TYPE=$1
REPEAT_COUNT=$2
REPEAT_COUNT=$1

for ((i=1; i <= REPEAT_COUNT; i++))
do
echo "### Run $i ###"
./run-instrumented-tests.sh "$TEST_TYPE"
./run-instrumented-tests.sh "${@:2}"
done

0 comments on commit b239906

Please sign in to comment.