From 7ca6f4fff01c3c5ce57f68a5fde95c4e3050ee60 Mon Sep 17 00:00:00 2001 From: Chuck Greb Date: Fri, 10 Feb 2017 13:11:22 -0500 Subject: [PATCH] Improve build performance (#298) * Test debug build only and reduce output * Gradle 3.3 and android-maven plugin 1.5 * Adds --configure-on-demand option to circle.yml * Adds -PdisablePreDex option to circle.yml * Build and test modules in parallel * Deploy sample apps to AWS on release build only * Publish docs on release build only * Install core lib to local .m2 repo before resolving dependencies * Copy test results into archive folder * Disable Javadoc tasks * Build sample app but do not deploy to s3. Archive APKs on Circle CI. * Update gradle options to limit memory use and dump heap on OOM error * Relative path for artifacts folder * Circle CI syntax for "artifacts" * Test deployment on non-master branch * Revert full build including sample apps to master only --- build.gradle | 17 +++++++++++++ circle.yml | 25 +++++++++++++------ core/build.gradle | 15 +---------- gradle/wrapper/gradle-wrapper.properties | 2 +- mapzen-android-sdk/build.gradle | 15 +---------- mapzen-places-api/build.gradle | 15 +---------- .../mapzen-android-sdk-sample/build.gradle | 5 ---- scripts/deploy-android-sdk-sample-app.sh | 1 - scripts/deploy-places-api-sample-app.sh | 1 - scripts/deploy-samples.sh | 11 ++++++++ scripts/publish-docs.sh | 9 +++++++ 11 files changed, 59 insertions(+), 57 deletions(-) create mode 100755 scripts/deploy-samples.sh create mode 100755 scripts/publish-docs.sh diff --git a/build.gradle b/build.gradle index c60977fe..293fc531 100644 --- a/build.gradle +++ b/build.gradle @@ -21,6 +21,23 @@ allprojects { } } +subprojects { + task verify(dependsOn: ['compileDebugSources', + 'testDebugUnitTest', + 'checkstyle', + 'lint']) + + tasks.withType(Test) { + testLogging { + exceptionFormat "full" + events "skipped", "passed", "failed" + showStandardStreams true + } + } + + tasks.withType(Javadoc).all { enabled = false } +} + task clean(type: Delete) { delete rootProject.buildDir } diff --git a/circle.yml b/circle.yml index 902b431d..c8355c59 100644 --- a/circle.yml +++ b/circle.yml @@ -1,8 +1,16 @@ +general: + artifacts: + - "samples/mapzen-android-sdk-sample/build/outputs/apk" + - "samples/mapzen-places-api-sample/build/outputs/apk" + machine: java: version: oraclejdk8 python: version: 2.7.10 + environment: + GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError"' + TEST_FLAGS: "--configure-on-demand -PdisablePreDex" checkout: post: @@ -14,20 +22,23 @@ dependencies: - echo y | android update sdk --all --no-ui --force --filter "build-tools-25.0.2" - echo y | android update sdk --all --no-ui --force --filter "android-25" - echo y | android update sdk --all --no-ui --force --filter "extra-android-m2repository" - - sudo apt-get update; sudo apt-get install s3cmd - - printf "[default]\naccess_key = $S3_ACCESS_KEY\n secret_key = $S3_SECRET_KEY" > ~/.s3cfg + - ./gradlew :core:install test: override: - - ./gradlew clean :core:install :core:verify :mapzen-android-sdk:verify :mapzen-places-api:verify + - case $CIRCLE_NODE_INDEX in 0) ./gradlew :core:verify $TEST_FLAGS ;; 1) ./gradlew :mapzen-android-sdk:verify $TEST_FLAGS ;; 2) ./gradlew :mapzen-places-api:verify $TEST_FLAGS ;; esac: + parallel: true + post: + - mkdir -p $CIRCLE_TEST_REPORTS/junit/ + - find . -type f -regex ".*/build/test-results/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \; deployment: master: branch: master commands: + - ./gradlew :samples_mapzen-android-sdk-sample:assembleDebug -PmapzenApiKey=$MAPZEN_API_KEY + - ./gradlew :samples_mapzen-place-api-sample:assembleDebug -PmapzenApiKey=$MAPZEN_API_KEY - ./gradlew uploadArchives -PsonatypeUsername=$SONATYPE_NEXUS_SNAPSHOTS_USERNAME -PsonatypePassword=$SONATYPE_NEXUS_SNAPSHOTS_PASSWORD - - scripts/deploy-android-sdk-sample-app.sh - - scripts/deploy-places-api-sample-app.sh - ./gradlew aarSize countReleaseDexMethods permissions mapzen-android-sdk:dependencies --configuration compile - - pip install 'Circle-Tickler == 1.0.1' - - tickle-circle mapzen documentation master $CIRCLE_TOKEN + - scripts/deploy-samples.sh + - scripts/publish-docs.sh diff --git a/core/build.gradle b/core/build.gradle index dc9bab8c..9ca368aa 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'net.researchgate:gradle-release:2.4.0' } } @@ -60,14 +60,6 @@ android { } } -tasks.withType(Test) { - testLogging { - exceptionFormat "full" - events "started", "skipped", "passed", "failed" - showStandardStreams true - } -} - task checkstyle(type: Checkstyle) { configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") source 'src' @@ -77,11 +69,6 @@ task checkstyle(type: Checkstyle) { classpath = files() } -task verify(dependsOn: ['compileDebugSources', - 'test', - 'checkstyle', - 'lint']) - apply from: rootProject.file('gradle/gradle-mvn-push.gradle') task submodules { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 86d6158a..f301b41c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/mapzen-android-sdk/build.gradle b/mapzen-android-sdk/build.gradle index 9df23167..c51c3ba0 100644 --- a/mapzen-android-sdk/build.gradle +++ b/mapzen-android-sdk/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'net.researchgate:gradle-release:2.4.0' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1' } @@ -58,14 +58,6 @@ android { } } -tasks.withType(Test) { - testLogging { - exceptionFormat "full" - events "started", "skipped", "passed", "failed" - showStandardStreams true - } -} - task checkstyle(type: Checkstyle) { configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") source 'src' @@ -75,11 +67,6 @@ task checkstyle(type: Checkstyle) { classpath = files() } -task verify(dependsOn: ['compileDebugSources', - 'test', - 'checkstyle', - 'lint']) - dependencies { compile 'com.mapzen:mapzen-core:1.3.0-SNAPSHOT' compile ('com.mapzen:on-the-road:1.2.0-SNAPSHOT') { diff --git a/mapzen-places-api/build.gradle b/mapzen-places-api/build.gradle index 7b025a64..9ea662e9 100644 --- a/mapzen-places-api/build.gradle +++ b/mapzen-places-api/build.gradle @@ -7,7 +7,7 @@ buildscript { } } dependencies { - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' classpath 'net.researchgate:gradle-release:2.4.0' classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.6.1' } @@ -55,14 +55,6 @@ android { } } -tasks.withType(Test) { - testLogging { - exceptionFormat "full" - events "started", "skipped", "passed", "failed" - showStandardStreams true - } -} - task checkstyle(type: Checkstyle) { configFile file("${project.rootDir}/config/checkstyle/checkstyle.xml") source 'src' @@ -72,11 +64,6 @@ task checkstyle(type: Checkstyle) { classpath = files() } -task verify(dependsOn: ['compileDebugSources', - 'test', - 'checkstyle', - 'lint']) - dependencies { compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.mapzen:mapzen-core:1.3.0-SNAPSHOT' diff --git a/samples/mapzen-android-sdk-sample/build.gradle b/samples/mapzen-android-sdk-sample/build.gradle index df0c0be8..55bbda40 100644 --- a/samples/mapzen-android-sdk-sample/build.gradle +++ b/samples/mapzen-android-sdk-sample/build.gradle @@ -36,11 +36,6 @@ task checkstyle(type: Checkstyle) { classpath = files() } -task verify(dependsOn: ['compileDebugSources', - 'test', - 'checkstyle', - 'lint']) - dependencies { compile(project(':mapzen-android-sdk')) { transitive = true; diff --git a/scripts/deploy-android-sdk-sample-app.sh b/scripts/deploy-android-sdk-sample-app.sh index 453caddc..cbe729c6 100755 --- a/scripts/deploy-android-sdk-sample-app.sh +++ b/scripts/deploy-android-sdk-sample-app.sh @@ -2,6 +2,5 @@ # # Builds mapzen android sdk sample app and uploads APK to s3://android.mapzen.com/mapzen-android-sdk-sample-snapshots/. -./gradlew assembleDebug -PmapzenApiKey=$MAPZEN_API_KEY s3cmd put samples/mapzen-android-sdk-sample/build/outputs/apk/samples_mapzen-android-sdk-sample-debug.apk s3://android.mapzen.com/mapzen-android-sdk-sample-latest.apk s3cmd put samples/mapzen-android-sdk-sample/build/outputs/apk/samples_mapzen-android-sdk-sample-debug.apk s3://android.mapzen.com/mapzen-android-sdk-sample-snapshots/mapzen-android-sdk-sample-$CIRCLE_BUILD_NUM.apk diff --git a/scripts/deploy-places-api-sample-app.sh b/scripts/deploy-places-api-sample-app.sh index efe32674..584d9c37 100755 --- a/scripts/deploy-places-api-sample-app.sh +++ b/scripts/deploy-places-api-sample-app.sh @@ -2,6 +2,5 @@ # # Builds mapzen places api sample app and uploads APK to s3://android.mapzen.com/mapzen-places-api-sample-snapshots/. -./gradlew assembleDebug -PmapzenApiKey=$MAPZEN_API_KEY s3cmd put samples/mapzen-places-api-sample/build/outputs/apk/samples_mapzen-places-api-sample-debug.apk s3://android.mapzen.com/mapzen-places-api-sample-latest.apk s3cmd put samples/mapzen-places-api-sample/build/outputs/apk/samples_mapzen-places-api-sample-debug.apk s3://android.mapzen.com/places-api-sample-snapshots/mapzen-places-api-sample-$CIRCLE_BUILD_NUM.apk diff --git a/scripts/deploy-samples.sh b/scripts/deploy-samples.sh new file mode 100755 index 00000000..b2badffe --- /dev/null +++ b/scripts/deploy-samples.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# +# Builds and uploads sample apps to S3 on release build only. + +if [[ ${PERFORM_RELEASE} ]] + then + sudo apt-get update; sudo apt-get install s3cmd + printf "[default]\naccess_key = $S3_ACCESS_KEY\n secret_key = $S3_SECRET_KEY" > ~/.s3cfg + scripts/deploy-android-sdk-sample-app.sh + scripts/deploy-places-api-sample-app.sh +fi diff --git a/scripts/publish-docs.sh b/scripts/publish-docs.sh new file mode 100755 index 00000000..2c3d3362 --- /dev/null +++ b/scripts/publish-docs.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# +# Triggers mapzen docs build to publish to https://mapzen.com/documentation/. + +if [[ ${PERFORM_RELEASE} ]] + then + pip install 'Circle-Tickler == 1.0.1' + tickle-circle mapzen documentation master $CIRCLE_TOKEN +fi