2021-03-25 14:26:26 +03:00
name : Test
on :
pull_request : {}
push :
2021-05-06 19:25:34 +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 :
CI_GRADLE_ARG_PROPERTIES : >
-Porg.gradle.jvmargs=-Xmx2g
-Porg.gradle.parallel=false
2022-02-24 12:30:28 +03:00
2021-03-25 14:26:26 +03:00
jobs :
2022-03-10 18:58:00 +03:00
# Build Android Tests [Matrix SDK]
build-android-test-matrix-sdk :
name : Matrix SDK - Build Android Tests
runs-on : ubuntu-latest
# No concurrency required, runs every time on a schedule.
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v2
with :
distribution : 'adopt'
java-version : 11
- uses : actions/cache@v2
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys : |
${{ runner.os }}-gradle-
- name : Build Android Tests for matrix-sdk-android
run : ./gradlew clean matrix-sdk-android:assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES --stacktrace
# Build Android Tests [Matrix APP]
build-android-test-app :
name : App - Build Android Tests
runs-on : ubuntu-latest
# No concurrency required, runs every time on a schedule.
steps :
- uses : actions/checkout@v3
- uses : actions/setup-java@v2
with :
distribution : 'adopt'
java-version : 11
- uses : actions/cache@v2
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys : |
${{ runner.os }}-gradle-
- name : Build Android Tests for vector
run : ./gradlew clean vector:assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES --stacktrace
2021-03-25 14:26:26 +03:00
unit-tests :
2021-05-19 18:48:12 +03:00
name : Run Unit Tests
2021-03-25 14:26:26 +03:00
runs-on : ubuntu-latest
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
- uses : actions/cache@v2
with :
path : |
~/.gradle/caches
~/.gradle/wrapper
key : ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys : |
${{ runner.os }}-gradle-
- name : Run unit tests
2022-03-08 16:26:04 +03:00
run : ./gradlew clean test $CI_GRADLE_ARG_PROPERTIES --stacktrace
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
2021-09-08 14:03:51 +03:00
- name : Publish Unit Test Results
uses : EnricoMi/publish-unit-test-result-action@v1
2021-09-24 11:14:57 +03:00
if : always() &&
github.event.sender.login != 'dependabot[bot]' &&
( github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository )
2021-09-08 14:03:51 +03:00
with :
files : ./**/build/test-results/**/*.xml
2022-03-10 19:41:00 +03:00
# Notify the channel about runs against develop or main that have failures, as PRs should have caught these first.
notify :
runs-on : ubuntu-latest
needs :
- unit-tests
- build-android-test-matrix-sdk
- build-android-test-app
if : ${{ (github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/main' ) && failure() }}
steps :
- uses : michaelkaye/matrix-hookshot-action@v0.3.0
with :
github_token : ${{ secrets.GITHUB_TOKEN }}
matrix_access_token : ${{ secrets.ELEMENT_ANDROID_NOTIFICATION_ACCESS_TOKEN }}
matrix_room_id : ${{ secrets.ELEMENT_ANDROID_INTERNAL_ROOM_ID }}
text_template : "Build is broken for ${{ github.ref }} 🎊: {{#each job_statuses }}{{#with this }}{{#if completed }} {{name}} {{conclusion}} at {{completed_at}}, {{/if}}{{/with}}{{/each}}"
html_template : "Build is broken for ${{ github.ref }} 🎊: {{#each job_statuses }}{{#with this }}{{#if completed }}<br />{{icon conclusion }}{{name}} <font color='{{color conclusion }}'>{{conclusion}} at {{completed_at}} <a href=\"{{html_url}}\">[details]</a></font>{{/if}}{{/with}}{{/each}}"