2020-05-23 11:04:10 +00:00
|
|
|
on: [pull_request]
|
2019-12-15 21:49:18 +00:00
|
|
|
|
|
|
|
name: Check pull request
|
2019-10-02 05:14:16 +00:00
|
|
|
jobs:
|
2019-12-15 21:49:18 +00:00
|
|
|
test-pr:
|
2020-04-16 18:54:13 +00:00
|
|
|
runs-on: macos-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2020-06-23 13:21:47 +00:00
|
|
|
api-level: [23, 29]
|
2020-08-20 21:08:58 +00:00
|
|
|
variant: [freeDebug, nonFreeDebug]
|
2019-10-02 05:14:16 +00:00
|
|
|
steps:
|
2019-12-31 15:27:38 +00:00
|
|
|
|
2020-05-23 11:04:10 +00:00
|
|
|
- name: Check if relevant files have changed
|
|
|
|
uses: actions/github-script@0.9.0
|
|
|
|
id: service-changed
|
|
|
|
with:
|
|
|
|
result-encoding: string
|
|
|
|
script: |
|
|
|
|
const result = await github.pulls.listFiles({
|
|
|
|
owner: context.payload.repository.owner.login,
|
|
|
|
repo: context.payload.repository.name,
|
|
|
|
pull_number: context.payload.number,
|
|
|
|
per_page: 100
|
|
|
|
})
|
2020-06-18 06:31:18 +00:00
|
|
|
const serviceChanged = result.data.filter(f => f.filename.startsWith("app/") || f.filename.endsWith("gradle") || f.filename.startsWith(".github/workflows/pull_request.yml") || f.filename.startsWith("gradle") || f.filename.endsWith("properties")).length > 0
|
2020-05-23 11:04:10 +00:00
|
|
|
console.log(serviceChanged)
|
|
|
|
return serviceChanged
|
|
|
|
|
|
|
|
- name: Checkout repository
|
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-07-14 18:38:34 +00:00
|
|
|
uses: actions/checkout@v2
|
2019-12-31 15:27:38 +00:00
|
|
|
|
2020-02-25 09:52:05 +00:00
|
|
|
- name: Copy CI gradle.properties
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-02-25 09:52:05 +00:00
|
|
|
run: mkdir -p ~/.gradle ; cp .github/ci-gradle.properties ~/.gradle/gradle.properties
|
|
|
|
|
2020-05-01 09:50:57 +00:00
|
|
|
- name: Generate cache key
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-05-01 09:50:57 +00:00
|
|
|
run: ./.github/checksum.sh checksum.txt
|
|
|
|
|
|
|
|
- name: Cache gradle modules
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-07-14 18:38:34 +00:00
|
|
|
uses: actions/cache@v2
|
2020-05-01 09:50:57 +00:00
|
|
|
with:
|
|
|
|
path: ~/.gradle/caches/modules-2
|
|
|
|
key: ${{ runner.os }}-gradlemodules-${{ hashFiles('checksum.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gradlemodules-
|
|
|
|
|
|
|
|
- name: Cache gradle jars
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-07-14 18:38:34 +00:00
|
|
|
uses: actions/cache@v2
|
2020-05-01 09:50:57 +00:00
|
|
|
with:
|
|
|
|
path: ~/.gradle/caches/jars-3
|
|
|
|
key: ${{ runner.os }}-gradlejars-${{ hashFiles('checksum.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gradlejars-
|
|
|
|
|
|
|
|
- name: Cache gradle build
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-07-14 18:38:34 +00:00
|
|
|
uses: actions/cache@v2
|
2019-12-31 15:27:38 +00:00
|
|
|
with:
|
2020-05-01 09:50:57 +00:00
|
|
|
path: ~/.gradle/caches/build-cache-1
|
|
|
|
key: ${{ runner.os }}-gradlebuildcache-${{ hashFiles('checksum.txt') }}
|
|
|
|
restore-keys: |
|
|
|
|
${{ runner.os }}-gradlebuildcache-
|
2019-12-31 15:27:38 +00:00
|
|
|
|
2020-04-16 18:54:13 +00:00
|
|
|
- name: Run unit tests
|
2020-05-23 11:04:10 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' }}
|
2020-05-10 13:51:39 +00:00
|
|
|
run: ./gradlew test${{ matrix.variant }} lint${{ matrix.variant}} -Dpre-dex=false
|
2019-12-31 15:27:38 +00:00
|
|
|
|
2020-07-24 09:03:55 +00:00
|
|
|
- name: Run instrumentation tests on free flavor
|
2020-08-20 21:08:58 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' && matrix.variant == 'freeDebug' }}
|
2020-07-24 09:03:55 +00:00
|
|
|
uses: reactivecircus/android-emulator-runner@v2.11.0
|
|
|
|
with:
|
|
|
|
api-level: ${{ matrix.api-level }}
|
|
|
|
target: default
|
|
|
|
script: |
|
|
|
|
adb shell settings put global animator_duration_scale 0
|
|
|
|
adb shell settings put global transition_animation_scale 0
|
|
|
|
adb shell settings put global window_animation_scale 0
|
|
|
|
./gradlew :app:connectedFreeDebugAndroidTest
|
|
|
|
|
|
|
|
- name: Run instrumentation tests on nonFree flavor
|
2020-08-20 21:08:58 +00:00
|
|
|
if: ${{ steps.service-changed.outputs.result == 'true' && matrix.variant == 'nonFreeDebug' }}
|
2020-06-23 13:21:47 +00:00
|
|
|
uses: reactivecircus/android-emulator-runner@v2.11.0
|
2019-10-02 05:14:16 +00:00
|
|
|
with:
|
2020-04-16 18:54:13 +00:00
|
|
|
api-level: ${{ matrix.api-level }}
|
2020-06-23 13:21:47 +00:00
|
|
|
target: default
|
2020-05-16 19:44:09 +00:00
|
|
|
script: |
|
|
|
|
adb shell settings put global animator_duration_scale 0
|
|
|
|
adb shell settings put global transition_animation_scale 0
|
|
|
|
adb shell settings put global window_animation_scale 0
|
2020-07-24 09:03:55 +00:00
|
|
|
./gradlew :app:connectedNonFreeDebugAndroidTest
|
2020-07-26 11:18:03 +00:00
|
|
|
|
|
|
|
- name: (Fail-only) upload test report
|
|
|
|
if: failure()
|
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: Test report
|
|
|
|
path: app/build/reports
|