From be2d6951508f158f40537de5e3b4a9cd1c38f445 Mon Sep 17 00:00:00 2001 From: Torsten Grote <t@grobox.de> Date: Wed, 25 Jul 2018 16:29:52 -0300 Subject: [PATCH] Setup fastlane This is great for automatically uploading (localized) screenshots and app metadata to Google Play. You can even upload the signed APK releases as well. For now, this is only useful for running the screenshot Espresso tests and grabbing the screenshots from the device. --- .gitignore | 9 +++- briar-android/fastlane/Appfile | 2 + briar-android/fastlane/Fastfile | 28 ++++++++++++ briar-android/fastlane/rename_screenshots.py | 43 +++++++++++++++++++ .../briar/android/settings/DarkThemeTest.java | 4 +- 5 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 briar-android/fastlane/Appfile create mode 100644 briar-android/fastlane/Fastfile create mode 100755 briar-android/fastlane/rename_screenshots.py diff --git a/.gitignore b/.gitignore index b40390a313..8f2bfafc30 100644 --- a/.gitignore +++ b/.gitignore @@ -23,5 +23,12 @@ local.properties !.idea/codeStyles .gradle build/ +captures *.iml -projectFilesBackup/ \ No newline at end of file +projectFilesBackup/ + +# Fastlane Non-Google Play Screenshots +briar-android/fastlane/metadata/android/screenshots.html +briar-android/fastlane/metadata/android/*/images/phoneScreenshots/manual_*.png +briar-android/fastlane/report.xml +briar-android/fastlane/README.md \ No newline at end of file diff --git a/briar-android/fastlane/Appfile b/briar-android/fastlane/Appfile new file mode 100644 index 0000000000..05204c92cf --- /dev/null +++ b/briar-android/fastlane/Appfile @@ -0,0 +1,2 @@ +json_key_file("") # Path to the json secret file - Follow https://docs.fastlane.tools/actions/supply/#setup to get one +package_name("org.briarproject.briar.android") diff --git a/briar-android/fastlane/Fastfile b/briar-android/fastlane/Fastfile new file mode 100644 index 0000000000..3646c37a65 --- /dev/null +++ b/briar-android/fastlane/Fastfile @@ -0,0 +1,28 @@ +# This file contains the fastlane.tools configuration +# You can find the documentation at https://docs.fastlane.tools +# +# For a list of all available actions, check out +# +# https://docs.fastlane.tools/actions +# +# For a list of all available plugins, check out +# +# https://docs.fastlane.tools/plugins/available-plugins +# + +# Uncomment the line if you want fastlane to automatically update itself +# update_fastlane + +default_platform(:android) + +platform :android do + desc "Takes screenshots for manual and Google Play" + lane :screenshots do + gradle(project_dir: "..", task: "assembleScreenshot assembleAndroidTest") + capture_android_screenshots + system './rename_screenshots.py' + end +end + + +# vi:syntax=ruby diff --git a/briar-android/fastlane/rename_screenshots.py b/briar-android/fastlane/rename_screenshots.py new file mode 100755 index 0000000000..f1f0485fa7 --- /dev/null +++ b/briar-android/fastlane/rename_screenshots.py @@ -0,0 +1,43 @@ +#!/usr/bin/env python3 + +# Author: Torsten Grote +# License: GPLv3 or later + +import os +import re +import glob + +METADATA_PATH = 'metadata/android' +GLOB = '/*/images/phoneScreenshots/*.png' + +REGEX = re.compile(r'(^\w+)_\d{13}\.png$') +REGEX_IN_FILE = re.compile(r'(\w+)_\d{13}\.png', re.MULTILINE) +PATH = os.path.dirname(os.path.realpath(__file__)) + + +def main(): + for path in glob.glob("%s%s" % (os.path.join(PATH, METADATA_PATH), GLOB)): + filename = os.path.basename(path) + match = REGEX.match(filename) + if match: + directory = os.path.dirname(path) + new_filename = "%s.png" % match.group(1) + new_path = os.path.join(directory, new_filename) + os.rename(path, new_path) + print("Renaming\n %s\nto\n %s\n" % (path, new_path)) + else: + print("Warning: Path did not match %s" % path) + + # rename fields also in screenshot overview file + overview = os.path.join(PATH, METADATA_PATH, 'screenshots.html') + with open(overview, 'r') as f: + file_data = f.read() + + file_data = REGEX_IN_FILE.sub(r'\1.png', file_data) + + with open(overview, 'w') as f: + f.write(file_data) + + +if __name__ == "__main__": + main() diff --git a/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/DarkThemeTest.java b/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/DarkThemeTest.java index 274c6e5c0b..3989d2f97c 100644 --- a/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/DarkThemeTest.java +++ b/briar-android/src/androidTest/java/org/briarproject/briar/android/settings/DarkThemeTest.java @@ -56,7 +56,7 @@ public class DarkThemeTest extends ScreenshotTest { .check(matches(isDisplayed())) .perform(click()); - screenshot("dark_theme_settings"); + screenshot("manual_dark_theme_settings"); onView(withText(R.string.pref_theme_title)) .check(matches(isDisplayed())) @@ -83,7 +83,7 @@ public class DarkThemeTest extends ScreenshotTest { .check(matches(isClosed(Gravity.LEFT))) .perform(DrawerActions.open()); - screenshot("dark_theme_nav_drawer"); + screenshot("manual_dark_theme_nav_drawer"); } } -- GitLab