2021-03-25 19:26:26 +08:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
2022-09-07 17:45:00 +08:00
|
|
|
pull_request: { }
|
2021-03-25 19:26:26 +08:00
|
|
|
push:
|
2022-09-07 17:45:00 +08:00
|
|
|
branches: [ main, develop ]
|
2021-03-25 19:26:26 +08:00
|
|
|
|
2021-09-08 19:03:51 +08:00
|
|
|
# Enrich gradle.properties for CI/CD
|
|
|
|
env:
|
2022-08-04 17:00:47 +08:00
|
|
|
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
|
2022-08-03 22:53:27 +08:00
|
|
|
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 2 --no-daemon
|
2022-02-24 17:30:28 +08:00
|
|
|
|
2021-03-25 19:26:26 +08:00
|
|
|
jobs:
|
2022-05-25 19:38:37 +08:00
|
|
|
tests:
|
|
|
|
name: Runs all tests
|
|
|
|
runs-on: macos-latest # for the emulator
|
2022-02-24 07:13:30 +08:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-24 02:11:46 +08:00
|
|
|
concurrency:
|
2022-02-25 00:31:17 +08: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-24 02:11:46 +08:00
|
|
|
cancel-in-progress: true
|
2021-03-25 19:26:26 +08:00
|
|
|
steps:
|
2022-03-08 07:05:24 +08:00
|
|
|
- uses: actions/checkout@v3
|
2021-03-25 19:26:26 +08:00
|
|
|
with:
|
2022-05-25 19:38:37 +08:00
|
|
|
fetch-depth: 0
|
|
|
|
- uses: actions/setup-java@v3
|
|
|
|
with:
|
|
|
|
distribution: 'adopt'
|
|
|
|
java-version: '11'
|
|
|
|
- uses: gradle/gradle-build-action@v2
|
2022-06-14 07:05:19 +08:00
|
|
|
- uses: actions/setup-python@v4
|
2022-05-25 19:38:37 +08: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/"
|
|
|
|
- name: Run all the codecoverage tests at once
|
2022-06-07 00:43:30 +08:00
|
|
|
id: tests
|
2022-05-25 19:38:37 +08:00
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
2022-06-10 06:58:50 +08:00
|
|
|
continue-on-error: true
|
2022-05-25 19:38:37 +08:00
|
|
|
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
|
2022-09-07 17:45:00 +08:00
|
|
|
script: |
|
2022-08-11 16:50:10 +08:00
|
|
|
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
2022-08-04 22:03:00 +08:00
|
|
|
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES
|
2022-09-07 17:45:00 +08:00
|
|
|
# NB: continue-on-error marks steps.tests.conclusion = 'success' but leaves stes.tests.outcome = 'failure'
|
2022-06-07 00:43:30 +08:00
|
|
|
- name: Run all the codecoverage tests at once (retry if emulator failed)
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
2022-06-07 00:55:03 +08:00
|
|
|
if: always() && steps.tests.outcome == 'failure' # don't run if previous step succeeded.
|
2022-06-07 00:43:30 +08:00
|
|
|
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
|
2022-06-14 22:56:16 +08:00
|
|
|
script: |
|
2022-08-11 16:50:10 +08:00
|
|
|
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
2022-08-03 17:23:49 +08:00
|
|
|
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES
|
2022-09-07 17:45:00 +08:00
|
|
|
|
|
|
|
# we may have failed a previous step and retried, that's OK
|
|
|
|
- name: Publish results to Sonar
|
2022-09-07 18:15:12 +08: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 18:14:03 +08:00
|
|
|
if: ${{ always() && env.GITHUB_TOKEN != '' && env.SONAR_TOKEN != '' && env.ORG_GRADLE_PROJECT_SONAR_LOGIN != '' }}
|
2022-09-07 17:45:00 +08:00
|
|
|
run: ./gradlew sonarqube $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 19:38:37 +08:00
|
|
|
|
2022-03-01 19:42:54 +08:00
|
|
|
- name: Format unit test results
|
|
|
|
if: always()
|
|
|
|
run: python3 ./tools/ci/render_test_output.py unit ./**/build/test-results/**/*.xml
|
2022-05-25 21:10:50 +08:00
|
|
|
|
|
|
|
# can't be run on macos due to containers.
|
2022-05-25 19:38:37 +08: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-11 00:41:00 +08:00
|
|
|
|
2022-05-25 21:10:50 +08: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 22:03:00 +08:00
|
|
|
# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 21:10:50 +08:00
|
|
|
|