2021-03-25 12:26:26 +01:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
2022-09-07 11:45:00 +02:00
|
|
|
pull_request: { }
|
2021-03-25 12:26:26 +01:00
|
|
|
push:
|
2022-09-07 11:45:00 +02:00
|
|
|
branches: [ main, develop ]
|
2023-02-10 15:17:13 +01:00
|
|
|
paths-ignore:
|
|
|
|
- '.github/**'
|
2021-03-25 12:26:26 +01:00
|
|
|
|
2021-09-08 13:03:51 +02:00
|
|
|
# Enrich gradle.properties for CI/CD
|
|
|
|
env:
|
2022-08-04 11:00:47 +02:00
|
|
|
GRADLE_OPTS: -Dorg.gradle.jvmargs="-Xmx3072m -Dfile.encoding=UTF-8 -XX:+HeapDumpOnOutOfMemoryError" -Dkotlin.daemon.jvm.options="-Xmx2560m" -Dkotlin.incremental=false
|
2022-09-23 15:25:32 +02:00
|
|
|
CI_GRADLE_ARG_PROPERTIES: --stacktrace -PpreDexEnable=false --max-workers 4 --no-daemon
|
2022-02-24 10:30:28 +01:00
|
|
|
|
2021-03-25 12:26:26 +01:00
|
|
|
jobs:
|
2022-05-25 13:38:37 +02:00
|
|
|
tests:
|
|
|
|
name: Runs all tests
|
2022-09-19 14:31:35 +02:00
|
|
|
runs-on: buildjet-4vcpu-ubuntu-2204
|
2022-11-24 09:46:11 +01:00
|
|
|
timeout-minutes: 90 # We might need to increase it if the time for tests grows
|
2022-09-19 18:12:19 +02:00
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-07-16 10:01:22 +02:00
|
|
|
api-level: [29]
|
2022-02-24 00:13:30 +01:00
|
|
|
# Allow all jobs on main and develop. Just one per PR.
|
2022-02-23 19:11:46 +01:00
|
|
|
concurrency:
|
2022-02-24 17:31:17 +01: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 19:11:46 +01:00
|
|
|
cancel-in-progress: true
|
2021-03-25 12:26:26 +01:00
|
|
|
steps:
|
2024-07-15 18:12:08 +02:00
|
|
|
- uses: actions/checkout@v4
|
2021-03-25 12:26:26 +01:00
|
|
|
with:
|
2022-09-14 16:29:21 +02:00
|
|
|
lfs: true
|
2022-05-25 13:38:37 +02:00
|
|
|
fetch-depth: 0
|
2024-07-15 18:12:08 +02:00
|
|
|
- name: Use JDK 17
|
|
|
|
uses: actions/setup-java@v4
|
2022-05-25 13:38:37 +02:00
|
|
|
with:
|
2024-07-15 18:12:08 +02:00
|
|
|
distribution: 'temurin' # See 'Supported distributions' for available options
|
2024-06-06 13:22:05 +02:00
|
|
|
java-version: '17'
|
2024-07-15 18:12:08 +02:00
|
|
|
- name: Configure gradle
|
|
|
|
uses: gradle/actions/setup-gradle@v3
|
2022-09-27 17:45:50 +02:00
|
|
|
with:
|
|
|
|
cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
|
|
|
|
gradle-home-cache-cleanup: ${{ github.ref == 'refs/heads/develop' }}
|
2022-09-14 16:09:14 +02:00
|
|
|
|
|
|
|
- name: Run screenshot tests
|
2022-09-26 13:29:28 +02:00
|
|
|
run: ./gradlew verifyScreenshots $CI_GRADLE_ARG_PROPERTIES
|
2022-09-14 16:09:14 +02:00
|
|
|
|
|
|
|
- name: Archive Screenshot Results on Error
|
|
|
|
if: failure()
|
2022-09-27 12:03:44 +02:00
|
|
|
uses: actions/upload-artifact@v3
|
2022-09-14 16:09:14 +02:00
|
|
|
with:
|
|
|
|
name: screenshot-results
|
|
|
|
path: |
|
|
|
|
**/out/failures/
|
|
|
|
**/build/reports/tests/*UnitTest/
|
|
|
|
|
2022-06-14 01:05:19 +02:00
|
|
|
- uses: actions/setup-python@v4
|
2022-05-25 13:38:37 +02:00
|
|
|
with:
|
|
|
|
python-version: 3.8
|
2022-10-18 01:04:02 +02:00
|
|
|
- uses: michaelkaye/setup-matrix-synapse@v1.0.4
|
2022-05-25 13:38:37 +02:00
|
|
|
with:
|
|
|
|
uploadLogs: true
|
|
|
|
httpPort: 8080
|
|
|
|
disableRateLimiting: true
|
|
|
|
public_baseurl: "http://10.0.2.2:8080/"
|
2022-09-19 18:12:19 +02:00
|
|
|
|
2022-05-25 13:38:37 +02:00
|
|
|
- name: Run all the codecoverage tests at once
|
|
|
|
uses: reactivecircus/android-emulator-runner@v2
|
2022-09-19 16:26:38 +02:00
|
|
|
# continue-on-error: true
|
2022-05-25 13:38:37 +02:00
|
|
|
with:
|
2022-09-19 18:12:19 +02:00
|
|
|
api-level: ${{ matrix.api-level }}
|
2022-05-25 13:38:37 +02:00
|
|
|
arch: x86
|
|
|
|
profile: Nexus 5X
|
2022-09-23 15:25:32 +02:00
|
|
|
target: playstore
|
2022-05-25 13:38:37 +02:00
|
|
|
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 18:12:19 +02:00
|
|
|
# emulator-build: 7425822
|
2022-09-07 11:45:00 +02:00
|
|
|
script: |
|
2023-10-02 13:58:51 +02:00
|
|
|
./gradlew gatherGplayDebugStringTemplates $CI_GRADLE_ARG_PROPERTIES
|
2022-08-04 16:03:00 +02:00
|
|
|
./gradlew unitTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew instrumentationTestsWithCoverage $CI_GRADLE_ARG_PROPERTIES
|
|
|
|
./gradlew generateCoverageReport $CI_GRADLE_ARG_PROPERTIES
|
2022-09-13 14:40:26 +02:00
|
|
|
# NB: continue-on-error marks steps.tests.conclusion = 'success' but leaves steps.tests.outcome = 'failure'
|
2022-09-13 14:42:39 +02: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 11:45:00 +02:00
|
|
|
|
2022-09-19 18:36:01 +02: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 11:45:00 +02:00
|
|
|
# we may have failed a previous step and retried, that's OK
|
|
|
|
- name: Publish results to Sonar
|
2022-09-07 12:15:12 +02: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 12:14:03 +02:00
|
|
|
if: ${{ always() && env.GITHUB_TOKEN != '' && env.SONAR_TOKEN != '' && env.ORG_GRADLE_PROJECT_SONAR_LOGIN != '' }}
|
2023-03-03 16:40:23 +01:00
|
|
|
run: ./gradlew sonar $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 13:38:37 +02:00
|
|
|
|
2022-03-01 12:42:54 +01:00
|
|
|
- name: Format unit test results
|
|
|
|
if: always()
|
|
|
|
run: python3 ./tools/ci/render_test_output.py unit ./**/build/test-results/**/*.xml
|
2022-05-25 15:10:50 +02:00
|
|
|
|
|
|
|
# can't be run on macos due to containers.
|
2022-05-25 13:38:37 +02: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 17:41:00 +01:00
|
|
|
|
2022-05-25 15:10:50 +02:00
|
|
|
# Unneeded as part of the test suite above, kept around in case we want to re-enable them.
|
|
|
|
#
|
|
|
|
# # Build Android Tests
|
2022-11-24 09:46:11 +01:00
|
|
|
# build-android-tests:
|
|
|
|
# name: Build Android Tests
|
|
|
|
# runs-on: ubuntu-latest
|
2022-05-25 15:10:50 +02:00
|
|
|
# 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
|
2022-11-24 09:46:11 +01:00
|
|
|
# steps:
|
2024-07-15 18:12:08 +02:00
|
|
|
# - uses: actions/checkout@v4
|
|
|
|
# - name: Use JDK 17
|
|
|
|
# uses: actions/setup-java@v4
|
2022-11-24 09:46:11 +01:00
|
|
|
# with:
|
2024-07-15 18:12:08 +02:00
|
|
|
# distribution: 'temurin' # See 'Supported distributions' for available options
|
|
|
|
# java-version: '17'
|
2023-01-19 12:20:16 +01:00
|
|
|
# - name: Configure gradle
|
2024-07-15 18:12:08 +02:00
|
|
|
# uses: gradle/actions/setup-gradle@v3
|
2022-11-24 09:46:11 +01:00
|
|
|
# with:
|
2023-01-19 12:20:16 +01:00
|
|
|
# cache-read-only: ${{ github.ref != 'refs/heads/develop' }}
|
2022-11-24 09:46:11 +01:00
|
|
|
# - name: Build Android Tests
|
2022-08-04 16:03:00 +02:00
|
|
|
# run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES
|
2022-05-25 15:10:50 +02:00
|
|
|
|