2021-03-25 14:26:26 +03:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
2022-09-07 12:45:00 +03:00
|
|
|
pull_request: { }
|
2021-03-25 14:26:26 +03:00
|
|
|
push:
|
2022-09-07 12:45:00 +03:00
|
|
|
branches: [ main, develop ]
|
2021-03-25 14:26:26 +03:00
|
|
|
|
2021-09-08 14:03:51 +03:00
|
|
|
# Enrich gradle.properties for CI/CD
|
|
|
|
env:
|
2022-08-04 12:00:47 +03:00
|
|
|
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
|
2022-08-03 17:53:27 +03:00
|
|
|
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon
|
2022-02-24 12:30:28 +03:00
|
|
|
|
2021-03-25 14:26:26 +03:00
|
|
|
jobs:
|
2022-05-25 14:38:37 +03:00
|
|
|
tests:
|
|
|
|
name: Runs all tests
|
2022-09-19 15:31:35 +03:00
|
|
|
runs-on: buildjet-4vcpu-ubuntu-2204
|
2022-09-19 19:12:19 +03:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
api-level: [28]
|
2022-02-24 02:13:30 +03:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-23 21:11:46 +03:00
|
|
|
concurrency:
|
2022-02-24 19:31:17 +03:00
|
|
|
group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('unit-tests-{0}', github.ref) }}
|
2022-02-23 21:11:46 +03:00
|
|
|
cancel-in-progress: true
|
2021-03-25 14:26:26 +03:00
|
|
|
steps:
|
2022-03-08 02:05:24 +03:00
|
|
|
- uses: actions/checkout@v3
|
2021-03-25 14:26:26 +03:00
|
|
|
with:
|
2022-05-25 14:38:37 +03:00
|
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-java@v3
|
|
|
|
with:
|
|
|
|
distribution: 'adopt'
|
|
|
|
java-version: '11'
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
2022-06-14 02:05:19 +03:00
|
|
|
- uses: actions/setup-python@v4
|
2022-05-25 14:38:37 +03:00
|
|
|
with:
|
|
|
|
python-version: 3.8
|
|
|
|
- uses: michaelkaye/setup-matrix-synapse@v1.0.3
|
|
|
|
with:
|
|
|
|
uploadLogs: true
|
|
|
|
httpPort: 8080
|
|
|
|
disableRateLimiting: true
|
|
|
|
public_baseurl: "http://10.0.2.2:8080/"
|
2022-09-19 19:12:19 +03:00
|
|
|
|
|
|
|
- name: AVD cache
|
|
|
|
uses: actions/cache@v3
|
|
|
|
id: avd-cache
|
|
|
|
with:
|
|
|
|
path: |
|
|
|
|
~/.android/avd/*
|
|
|
|
~/.android/adb*
|
|
|
|
key: avd-${{ matrix.api-level }}
|
|
|
|
|
|
|
|
- name: create AVD and generate snapshot for caching
|
|
|
|
if: steps.avd-cache.outputs.cache-hit != 'true'
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
|
|
|
with:
|
|
|
|
api-level: ${{ matrix.api-level }}
|
|
|
|
arch: x86
|
|
|
|
profile: Nexus 5X
|
|
|
|
force-avd-creation: true # Is set to false in the doc https://github.com/ReactiveCircus/android-emulator-runner
|
|
|
|
emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
|
|
disable-animations: true
|
|
|
|
script: echo "Generated AVD snapshot for caching."
|
|
|
|
|
2022-05-25 14:38:37 +03:00
|
|
|
- name: Run all the codecoverage tests at once
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
2022-09-19 17:26:38 +03:00
|
|
|
# continue-on-error: true
|
2022-05-25 14:38:37 +03:00
|
|
|
with:
|
2022-09-19 19:12:19 +03:00
|
|
|
api-level: ${{ matrix.api-level }}
|
2022-05-25 14:38:37 +03:00
|
|
|
arch: x86
|
|
|
|
profile: Nexus 5X
|
|
|
|
force-avd-creation: false
|
|
|
|
emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
|
|
disable-animations: true
|
2022-09-19 19:12:19 +03:00
|
|
|
# emulator-build: 7425822
|
2022-09-07 12:45:00 +03:00
|
|
|
script: |
|
2022-08-11 11:50:10 +03:00
|
|
|
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
2022-08-04 17:03:00 +03:00
|
|
|
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES
|
2022-09-13 15:40:26 +03:00
|
|
|
# NB: continue-on-error marks steps.tests.conclusion = 'success' but leaves steps.tests.outcome = 'failure'
|
2022-09-13 15:42:39 +03:00
|
|
|
### - name: Run all the codecoverage tests at once (retry if emulator failed)
|
|
|
|
### uses: reactivecircus/android-emulator-runner@v2
|
|
|
|
### if: always() && steps.tests.outcome == 'failure' # don't run if previous step succeeded.
|
|
|
|
### with:
|
|
|
|
### api-level: 28
|
|
|
|
### arch: x86
|
|
|
|
### profile: Nexus 5X
|
|
|
|
### force-avd-creation: false
|
|
|
|
### emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none
|
|
|
|
### disable-animations: true
|
|
|
|
### emulator-build: 7425822
|
|
|
|
### script: |
|
|
|
|
### ./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
### ./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
### ./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
### ./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES
|
2022-09-07 12:45:00 +03:00
|
|
|
|
2022-09-19 19:36:01 +03:00
|
|
|
- name: Upload Integration Test Report Log
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
if: always()
|
|
|
|
with:
|
|
|
|
name: integration-test-error-results
|
|
|
|
path: |
|
|
|
|
*/build/outputs/androidTest-results/connected/
|
|
|
|
*/build/reports/androidTests/connected/
|
|
|
|
|
2022-09-07 12:45:00 +03:00
|
|
|
# we may have failed a previous step and retried, that's OK
|
|
|
|
- name: Publish results to Sonar
|
2022-09-07 13:15:12 +03:00
|
|
|
env:
|
|
|
|
GITHUB_TOKEN: ${{ secrets.SONARQUBE_GITHUB_API_TOKEN }} # Needed to get PR information, if any
|
|
|
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
|
|
|
ORG_GRADLE_PROJECT_SONAR_LOGIN: ${{ secrets.SONAR_TOKEN }}
|
2022-09-07 13:14:03 +03:00
|
|
|
if: ${{ always() && env.GITHUB_TOKEN != '' && env.SONAR_TOKEN != '' && env.ORG_GRADLE_PROJECT_SONAR_LOGIN != '' }}
|
2022-09-07 12:45:00 +03:00
|
|
|
run: ./gradlew sonarqube $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 14:38:37 +03:00
|
|
|
|
2022-03-01 14:42:54 +03:00
|
|
|
- name: Format unit test results
|
|
|
|
if: always()
|
|
|
|
run: python3 ./tools/ci/render_test_output.py unit ./**/build/test-results/**/*.xml
|
2022-05-25 16:10:50 +03:00
|
|
|
|
|
|
|
# can't be run on macos due to containers.
|
2022-05-25 14:38:37 +03:00
|
|
|
# - name: Publish Unit Test Results
|
|
|
|
# uses: EnricoMi/publish-unit-test-result-action@v1
|
|
|
|
# if: always() &&
|
|
|
|
# github.event.sender.login != 'dependabot[bot]' &&
|
|
|
|
# ( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository )
|
|
|
|
# with:
|
|
|
|
# files: ./**/build/test-results/**/*.xml
|
2022-03-10 19:41:00 +03:00
|
|
|
|
2022-05-25 16:10:50 +03:00
|
|
|
# Unneeded as part of the test suite above, kept around in case we want to re-enable them.
|
|
|
|
#
|
|
|
|
# # Build Android Tests
|
|
|
|
# build-android-tests:
|
|
|
|
# name: Build Android Tests
|
|
|
|
# runs-on: ubuntu-latest
|
|
|
|
# concurrency:
|
|
|
|
# group: ${{ github.ref == 'refs/heads/main' && format('unit-tests-main-{0}', github.sha) || github.ref == 'refs/heads/develop' && format('unit-tests-develop-{0}', github.sha) || format('build-android-tests-{0}', github.ref) }}
|
|
|
|
# cancel-in-progress: true
|
|
|
|
# steps:
|
|
|
|
# - uses: actions/checkout@v3
|
|
|
|
# - uses: actions/setup-java@v3
|
|
|
|
# with:
|
|
|
|
# distribution: 'adopt'
|
|
|
|
# java-version: 11
|
|
|
|
# - uses: actions/cache@v3
|
|
|
|
# with:
|
|
|
|
# path: |
|
|
|
|
# ~/.gradle/caches
|
|
|
|
# ~/.gradle/wrapper
|
|
|
|
# key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
|
|
|
# restore-keys: |
|
|
|
|
# ${{ runner.os }}-gradle-
|
|
|
|
# - name: Build Android Tests
|
2022-08-04 17:03:00 +03:00
|
|
|
# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 16:10:50 +03:00
|
|
|
|