From fb90ce583f54a8e9d7ce00cc0c435d6d4339ca8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Paczos?= Date: Mon, 28 Jan 2019 13:10:06 +0100 Subject: [android] android nitpick script, verify submodule pins --- Makefile | 10 ++++ circle.yml | 6 +++ platform/android/MapboxGLAndroidSDK/build.gradle | 4 +- platform/android/gradle/android-nitpick.gradle | 53 ++++++++++++++++++++++ .../gradle/gradle-update-vendor-modules.gradle | 5 ++ 5 files changed, 77 insertions(+), 1 deletion(-) create mode 100644 platform/android/gradle/android-nitpick.gradle create mode 100644 platform/android/gradle/gradle-update-vendor-modules.gradle diff --git a/Makefile b/Makefile index 15802768c6..4dd599bb96 100644 --- a/Makefile +++ b/Makefile @@ -758,6 +758,16 @@ endif android-configuration: platform/android/gradle/configuration.gradle cat platform/android/gradle/configuration.gradle +# Updates Android's vendor submodules +.PHONY: android-update-vendor +android-update-vendor: platform/android/gradle/configuration.gradle + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none updateVendorSubmodules + +# Run android nitpick script +.PHONY: run-android-nitpick +run-android-nitpick: android-update-vendor + cd platform/android && $(MBGL_ANDROID_GRADLE) -Pmapbox.abis=none androidNitpick + # Creates a dependency graph using Graphviz .PHONY: android-graph android-graph: platform/android/gradle/configuration.gradle diff --git a/circle.yml b/circle.yml index 08cf3bf2b5..d2a99b04e8 100644 --- a/circle.yml +++ b/circle.yml @@ -535,6 +535,9 @@ jobs: MBGL_ANDROID_STL: << parameters.stl >> steps: - install-dependencies: { gradle: true } + - run: + name: Android nitpick + command: make run-android-nitpick - run: name: Check code style command: make android-check @@ -596,6 +599,9 @@ jobs: IS_LOCAL_DEVELOPMENT: false steps: - install-dependencies: { gradle: true } + - run: + name: Android nitpick + command: make run-android-nitpick - run: name: Generate Maven credentials command: | diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle index eafb0583c2..12be290175 100644 --- a/platform/android/MapboxGLAndroidSDK/build.gradle +++ b/platform/android/MapboxGLAndroidSDK/build.gradle @@ -165,4 +165,6 @@ configurations { apply from: "${rootDir}/gradle/gradle-javadoc.gradle" apply from: "${rootDir}/gradle/gradle-publish.gradle" apply from: "${rootDir}/gradle/gradle-checkstyle.gradle" -apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle" \ No newline at end of file +apply from: "${rootDir}/gradle/gradle-dependencies-graph.gradle" +apply from: "${rootDir}/gradle/gradle-update-vendor-modules.gradle" +apply from: "${rootDir}/gradle/android-nitpick.gradle" \ No newline at end of file diff --git a/platform/android/gradle/android-nitpick.gradle b/platform/android/gradle/android-nitpick.gradle new file mode 100644 index 0000000000..dfcbcfb869 --- /dev/null +++ b/platform/android/gradle/android-nitpick.gradle @@ -0,0 +1,53 @@ +apply from: "${rootDir}/gradle/dependencies.gradle" + +def MAPBOX_JAVA_DIR = 'mapbox-java' +def MAPBOX_JAVA_TAG_PREFIX = 'v' + +def MAPBOX_TELEMETRY_DIR = 'mapbox-events-android' +def MAPBOX_TELEMETRY_TAG_PREFIX = 'telem-' + +def MAPBOX_GESTURES_DIR = 'mapbox-gestures-android' +def MAPBOX_GESTURES_TAG_PREFIX = 'v' + +task verifyVendorSubmodulePins { + doLast { + println "Verify vendor submodule pins" + verifyVendorSubmodulePin(MAPBOX_JAVA_DIR, MAPBOX_JAVA_TAG_PREFIX, versions.mapboxServices) + verifyVendorSubmodulePin(MAPBOX_TELEMETRY_DIR, MAPBOX_TELEMETRY_TAG_PREFIX, versions.mapboxTelemetry) + verifyVendorSubmodulePin(MAPBOX_GESTURES_DIR, MAPBOX_GESTURES_TAG_PREFIX, versions.mapboxGestures) + } +} + +task androidNitpick { + doLast { + println "Running android nitpick script" + verifyVendorSubmodulePins + } +} + +private def verifyVendorSubmodulePin(def dir, def prefix, def version) { + def output = new ByteArrayOutputStream() + exec { + workingDir "${rootDir}/vendor/${dir}" + commandLine "git", "rev-list", "-n", "1", "tags/${prefix + version}" + standardOutput = output + } + def expectedCommit = output.toString().trim() + output.reset() + + exec { + workingDir "${rootDir}/vendor/${dir}" + commandLine "git", "rev-parse", "HEAD" + standardOutput = output + } + def actualCommit = output.toString().trim() + + if (actualCommit != expectedCommit) { + throw new IllegalStateException("${dir} vendor repository is not checked out on the consumed binary's tag.\n" + + "Expected commit: " + expectedCommit + "(${prefix + version} tag).\n" + + "Actual commit: " + actualCommit + ".\n" + + "If you've updated the version in the dependencies.gradle file, make sure to bump the submodule pin in the platform/android/vendor/ directory to match the release tag.\n" + + "If you've bumped the pin, make sure to verify the version tag prefix in the android-nitpick.gradle file.") + } + output.close() +} \ No newline at end of file diff --git a/platform/android/gradle/gradle-update-vendor-modules.gradle b/platform/android/gradle/gradle-update-vendor-modules.gradle new file mode 100644 index 0000000000..f2305eb7a5 --- /dev/null +++ b/platform/android/gradle/gradle-update-vendor-modules.gradle @@ -0,0 +1,5 @@ +task updateVendorSubmodules { + doLast { + "git submodule update --init --recursive vendor".execute() + } +} \ No newline at end of file -- cgit v1.2.1