Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build Cache Example on CircleCI #1

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
80 changes: 80 additions & 0 deletions .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
34 changes: 34 additions & 0 deletions 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'
}
}
5 changes: 4 additions & 1 deletion gradle.properties
@@ -1,8 +1,11 @@
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
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
4 changes: 4 additions & 0 deletions settings.gradle
Expand Up @@ -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")
}