From fe1d9aa589e248507555c4243361dccdb459a8c8 Mon Sep 17 00:00:00 2001 From: ariskotsomitopoulos Date: Wed, 8 Sep 2021 14:03:51 +0300 Subject: [PATCH] - Optimize build time for local builds - Enhance CI/CD workflows (7GB Ram, 2CPU) by adding custom gradle arguments to properly run - Add unit test UI comment representation plugin --- .github/workflows/build.yml | 12 ++++++++++-- .github/workflows/integration.yml | 28 +++++++++++++++++++++++++--- .github/workflows/sanity_test.yml | 8 +++++++- .github/workflows/tests.yml | 14 +++++++++++++- gradle.properties | 22 +++++++++++----------- 5 files changed, 66 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 85148a2632..2b2dbf09a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,12 @@ on: push: branches: [ main, develop ] +# Enrich gradle.properties for CI/CD +env: + CI_GRADLE_ARG_PROPERTIES: > + -Porg.gradle.jvmargs=-Xmx2g + -Porg.gradle.parallel=false + jobs: debug: name: Build debug APKs (${{ matrix.target }}) @@ -25,7 +31,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Assemble ${{ matrix.target }} debug apk - run: ./gradlew assemble${{ matrix.target }}Debug --stacktrace + run: ./gradlew assemble${{ matrix.target }}Debug $CI_GRADLE_ARG_PROPERTIES --stacktrace - name: Upload ${{ matrix.target }} debug APKs uses: actions/upload-artifact@v2 with: @@ -39,6 +45,8 @@ jobs: if: github.ref == 'refs/heads/main' steps: - uses: actions/checkout@v2 +# - name: Generate CI gradle.properties +# run: echo "$CI_GRADLE_PROPERTIES" > gradle.properties - uses: actions/cache@v2 with: path: | @@ -48,7 +56,7 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Assemble GPlay unsigned apk - run: ./gradlew clean assembleGplayRelease --stacktrace + run: ./gradlew clean assembleGplayRelease $CI_GRADLE_ARG_PROPERTIES --stacktrace - name: Upload Gplay unsigned APKs uses: actions/upload-artifact@v2 with: diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 984ae0748e..5d2cc2cd33 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -5,6 +5,12 @@ on: push: branches: [ main, develop ] +# Enrich gradle.properties for CI/CD +env: + CI_GRADLE_ARG_PROPERTIES: > + -Porg.gradle.jvmargs=-Xmx2g + -Porg.gradle.parallel=false + jobs: # Temporary add build of Android tests, which cannot be run on the CI right now, but they need to at least compile # So it will be mandatory for this action to be successful on every PRs @@ -22,17 +28,26 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Compile Android tests - run: ./gradlew clean assembleAndroidTest --stacktrace -PallWarningsAsErrors=false + run: ./gradlew clean assembleAndroidTest $CI_GRADLE_ARG_PROPERTIES --stacktrace -PallWarningsAsErrors=false integration-tests: name: Integration Tests (Synapse) +# env: +# JAVA_HOME: $JAVA_HOME_11_X64 runs-on: ubuntu-latest strategy: fail-fast: false matrix: - api-level: [21, 28, 30] + api-level: [21,23, 28, 30] steps: - uses: actions/checkout@v2 +# - name: Generate CI gradle.properties +# run: echo "$CI_GRADLE_PROPERTIES" > gradle.properties + - uses: gradle/wrapper-validation-action@v1 + - uses: actions/setup-java@v2 + with: + distribution: 'adopt' + java-version: 11 - name: Set up Python 3.8 uses: actions/setup-python@v2 with: @@ -64,5 +79,12 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} + #arch: x86_64 + #disable-animations: true # script: ./gradlew -PallWarningsAsErrors=false vector:connectedAndroidTest matrix-sdk-android:connectedAndroidTest - script: ./gradlew -PallWarningsAsErrors=false connectedCheck + 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 + emulator-build: 7425822 + script: ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedCheck --stacktrace diff --git a/.github/workflows/sanity_test.yml b/.github/workflows/sanity_test.yml index 632dee8a58..3ab0017ce2 100644 --- a/.github/workflows/sanity_test.yml +++ b/.github/workflows/sanity_test.yml @@ -5,6 +5,12 @@ on: push: branches: [ main, develop ] +# Enrich gradle.properties for CI/CD +env: + CI_GRADLE_ARG_PROPERTIES: > + -Porg.gradle.jvmargs=-Xmx2g + -Porg.gradle.parallel=false + jobs: integration-tests: name: Sanity Tests (Synapse) @@ -46,5 +52,5 @@ jobs: uses: reactivecircus/android-emulator-runner@v2 with: api-level: ${{ matrix.api-level }} - script: ./gradlew -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest + script: ./gradlew $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false connectedGplayDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=im.vector.app.ui.UiAllScreensSanityTest diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6e51368ce5..11c03a504b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -5,6 +5,12 @@ on: push: branches: [main, develop] +# Enrich gradle.properties for CI/CD +env: + CI_GRADLE_ARG_PROPERTIES: > + -Porg.gradle.jvmargs=-Xmx2g + -Porg.gradle.parallel=false + jobs: unit-tests: name: Run Unit Tests @@ -20,4 +26,10 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - name: Run unit tests - run: ./gradlew clean test --stacktrace -PallWarningsAsErrors=false + run: ./gradlew clean test $CI_GRADLE_ARG_PROPERTIES -PallWarningsAsErrors=false --stacktrace + - name: Publish Unit Test Results + uses: EnricoMi/publish-unit-test-result-action@v1 + if: always() + with: + files: ./**/build/test-results/**/*.xml + # files: test-results/**/*.xml diff --git a/gradle.properties b/gradle.properties index 200866be25..98d561815b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,20 +6,20 @@ # http://www.gradle.org/docs/current/userguide/build_environment.html # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -android.enableJetifier=true -android.useAndroidX=true -org.gradle.jvmargs=-Xmx2048m -# When configured, Gradle will run in incubating parallel mode. -# This option should only be used with decoupled projects. More details, visit -# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true -# Enable file system watch (https://docs.gradle.org/6.7/release-notes.html) +# Build Time Optimizations +org.gradle.jvmargs=-Xmx3g -Xms512M -XX:MaxPermSize=2048m -XX:MaxMetaspaceSize=1g -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 -XX:+UseParallelGC +org.gradle.configureondemand=true +org.gradle.parallel=true org.gradle.vfs.watch=true +# Android Settings +android.enableJetifier=true +android.useAndroidX=true + +#Project Settings +# Change debugPrivateData to true for debugging vector.debugPrivateData=false +# httpLogLevel values: NONE, BASIC, HEADERS, BODY vector.httpLogLevel=BASIC -# Note: to debug, you can put and uncomment the following lines in the file ~/.gradle/gradle.properties to override the value above -#vector.debugPrivateData=true -#vector.httpLogLevel=BODY