diff --git a/.circleci/config.yml b/.circleci/config.yml new file mode 100644 index 00000000000..1c5828e6595 --- /dev/null +++ b/.circleci/config.yml @@ -0,0 +1,80 @@ +# Use the latest 2.1 version of CircleCI pipeline process engine. +# See: https://circleci.com/docs/configuration-reference +version: 2.1 + +# Orbs are reusable packages of CircleCI configuration that you may share across projects, enabling you to create encapsulated, parameterized commands, jobs, and executors that can be used across multiple projects. +# See: https://circleci.com/docs/orb-intro/ +orbs: + # https://circleci.com/developer/orbs/orb/circleci/android + android: circleci/android@2.3.0 + +# Define a job to be invoked later in a workflow. +# See: https://circleci.com/docs/configuration-reference/#jobs +jobs: + run-tests-with-bitrise-build-cache: + # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/configuration-reference/#executor-job + executor: + name: android/android-machine + tag: 2023.11.1 + environment: + ENABLE_BITRISE_BUILD_CACHE: "true" + + # Add steps to the job + # See: https://circleci.com/docs/configuration-reference/#steps + steps: + - android/change-java-version: + java-version: 17 + - checkout + - run: + name: Checkout submodules as well + command: | + git "submodule" "update" "--init" "--recursive" "--jobs=10" + - run: + name: Add Build Cache dependency hashes + command: | + ./gradlew --write-verification-metadata sha256 + - run: + name: Lint PlayProdDebug + no_output_timeout: 60m + command: ./gradlew :Signal-Android:lintPlayProdDebug + # - run: + # name: Assemble playProdDebug + # command: ./gradlew :Signal-Android:assemblePlayProdDebug + + run-tests-without-build-cache: + # Specify the execution environment. You can specify an image from Docker Hub or use one of our convenience images from CircleCI's Developer Hub. + # See: https://circleci.com/docs/configuration-reference/#executor-job + executor: + name: android/android-machine + tag: 2023.11.1 + + # Add steps to the job + # See: https://circleci.com/docs/configuration-reference/#steps + steps: + - android/change-java-version: + java-version: 17 + - checkout + - run: + name: Checkout submodules as well + command: | + git "submodule" "update" "--init" "--recursive" "--jobs=10" + - run: + name: Add Build Cache dependency hashes + command: | + ./gradlew --write-verification-metadata sha256 + - run: + name: Lint PlayProdDebug + no_output_timeout: 60m + command: ./gradlew :Signal-Android:lintPlayProdDebug + # - run: + # name: Assemble playProdDebug + # command: ./gradlew :Signal-Android:assemblePlayProdDebug + +# Orchestrate jobs using workflows +# See: https://circleci.com/docs/configuration-reference/#workflows +workflows: + run-tests: + jobs: + - run-tests-with-bitrise-build-cache + - run-tests-without-build-cache diff --git a/bitrise-build-cache.gradle b/bitrise-build-cache.gradle new file mode 100644 index 00000000000..8044633bd0a --- /dev/null +++ b/bitrise-build-cache.gradle @@ -0,0 +1,34 @@ +buildscript { + repositories { + mavenCentral() + maven { url 'https://jitpack.io' } + } + + dependencies { + classpath 'io.bitrise.gradle:remote-cache:1.+' + } +} + +import io.bitrise.gradle.cache.BitriseBuildCache +import io.bitrise.gradle.cache.BitriseBuildCacheServiceFactory + +println('[BITRISE BUILD CACHE] Gradle Configuration loaded') + +String bitriseBuildCacheWorkspaceID = System.getenv('BITRISE_BUILD_CACHE_WORKSPACE_ID') +boolean isCI = System.getenv().containsKey("CI") +println('[BITRISE BUILD CACHE] isCI: ' + isCI) +buildCache { + local { + enabled = !isCI + } + registerBuildCacheService(BitriseBuildCache.class, BitriseBuildCacheServiceFactory.class) + remote(BitriseBuildCache.class) { + endpoint = System.getenv('BITRISE_BUILD_CACHE_ENDPOINT') ?: 'grpcs://pluggable.services.bitrise.io' + println('[BITRISE BUILD CACHE] endpoint: ' + endpoint) + authToken = bitriseBuildCacheWorkspaceID + ':' + System.getenv('BITRISE_BUILD_CACHE_AUTH_TOKEN') + enabled = true + push = isCI + debug = false + blobValidationLevel = 'warning' + } +} diff --git a/gradle.properties b/gradle.properties index d7cb0fccbdc..29f2039a17f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -org.gradle.jvmargs=-Xmx6g -Xms256m -XX:MaxMetaspaceSize=1g +org.gradle.jvmargs=-Xmx4g -Xms256m -XX:MaxMetaspaceSize=1g android.useAndroidX=true android.enableJetifier=true kapt.incremental.apt=false @@ -6,3 +6,6 @@ android.experimental.androidTest.numManagedDeviceShards=4 android.defaults.buildfeatures.buildconfig=true android.nonTransitiveRClass=false android.nonFinalResIds=false + +org.gradle.caching=true +#org.gradle.caching.debug=true diff --git a/settings.gradle b/settings.gradle index 705c94a6779..7c0e15e4ea2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -95,3 +95,7 @@ project(':glide-webp-app').projectDir = file('glide-webp/app') rootProject.name='Signal' apply from: 'dependencies.gradle' + +if (file("bitrise-build-cache.gradle").exists() && System.getenv("ENABLE_BITRISE_BUILD_CACHE") == "true") { + apply(from: "bitrise-build-cache.gradle") +}