Commit f95ca07e authored by Eric Eastwood's avatar Eric Eastwood
Browse files

Add GitLab CI build/tests

parent f9bd0c83
Pipeline #27297944 passed with stages
in 7 minutes and 35 seconds
image: openjdk:8-jdk
# Just matched `app/build.gradle`
# Just matched `app/build.gradle`
# Version from
- apt-get --quiet update --yes
- apt-get --quiet install --yes wget tar unzip lib32stdc++6 lib32z1
- wget --quiet --output-document=android-sdk.tgz${ANDROID_SDK_TOOLS}-linux.tgz
- tar --extract --gzip --file=android-sdk.tgz
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter android-${ANDROID_COMPILE_SDK}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter platform-tools
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter build-tools-${ANDROID_BUILD_TOOLS}
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-android-m2repository
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-google_play_services
- echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter extra-google-m2repository
- export ANDROID_HOME=$PWD/android-sdk-linux
- export PATH=$PATH:$PWD/android-sdk-linux/platform-tools/
- chmod +x ./gradlew
- build
- test
stage: build
- ./gradlew assembleDebug
- app/build/outputs/
stage: test
- ./gradlew test
# This can't be enabled because `ERROR: x86 emulation currently requires hardware acceleration!`,
# functionalTests:
# stage: test
# script:
# - wget --quiet --output-document=android-wait-for-emulator
# - chmod +x android-wait-for-emulator
# - echo y | android-sdk-linux/tools/android --silent update sdk --no-ui --all --filter sys-img-x86-google_apis-${ANDROID_COMPILE_SDK}
# - echo no | android-sdk-linux/tools/android create avd -n test -t android-${ANDROID_COMPILE_SDK} --abi google_apis/x86
# - android-sdk-linux/tools/emulator64-x86 -avd test -no-window -no-audio &
# - ./android-wait-for-emulator
# - adb shell input keyevent 82
# - ./gradlew cAT
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="NullableNotNullManager">
<option name="myDefaultNullable" value="" />
<option name="myDefaultNotNull" value="" />
<option name="myNullables">
<list size="5">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.Nullable" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nullable" />
<item index="2" class="java.lang.String" itemvalue="javax.annotation.CheckForNull" />
<item index="3" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.Nullable" />
<item index="4" class="java.lang.String" itemvalue="" />
<option name="myNotNulls">
<list size="4">
<item index="0" class="java.lang.String" itemvalue="org.jetbrains.annotations.NotNull" />
<item index="1" class="java.lang.String" itemvalue="javax.annotation.Nonnull" />
<item index="2" class="java.lang.String" itemvalue="edu.umd.cs.findbugs.annotations.NonNull" />
<item index="3" class="java.lang.String" itemvalue="" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
apply plugin: ''
def secretsPropertiesFile = rootProject.file("");
// Try reading secrets from file
def secretsPropertiesFile = rootProject.file("")
def secretProperties = new Properties()
secretProperties.load(new FileInputStream(secretsPropertiesFile))
if (secretsPropertiesFile.exists()) {
secretProperties.load(new FileInputStream(secretsPropertiesFile))
// Otherwise read from environment variables, this happens in CI
else {
secretProperties.setProperty("oauth_client_id", System.getenv('oauth_client_id'))
secretProperties.setProperty("oauth_client_secret", System.getenv('oauth_client_secret'))
secretProperties.setProperty("oauth_redirect_uri", System.getenv('oauth_redirect_uri'))
secretProperties.setProperty("google_project_id", System.getenv('google_project_id') ?: "null")
android {
compileSdkVersion 24
......@@ -15,10 +25,10 @@ android {
versionCode 81
versionName "3.2.0"
buildConfigField("String", "oauth_client_id", secretProperties['oauth_client_id'])
buildConfigField("String", "oauth_client_secret", secretProperties['oauth_client_secret'])
buildConfigField("String", "oauth_redirect_uri", secretProperties['oauth_redirect_uri'])
buildConfigField("String", "google_project_id", secretProperties['google_project_id'] ?: "null")
buildConfigField("String", "oauth_client_id", "\"${secretProperties['oauth_client_id']}\"")
  • @MadLittleMods I just started diving into Gitter here! The character escaping here generates double quoted strings in the generated file app/build/generated/source/buildConfig/debug/im/gitter/gitter/ like the following:

    public static final String google_project_id = ""null"";
    public static final String oauth_redirect_uri = """";

    It think it's safe to change this to the following. What do you think?

    buildConfigField("String", "oauth_client_id", "${secretProperties['oauth_client_id']}")
    Edited by George Tsiolis
  • @gtsiolis From my experience, the double quotes were needed as it literally puts the value in quotes into the build config file output.

    You can see an example here,

  • @MadLittleMods but generating the as the following won't allow the app to build successfully. Maybe there's a another way around this, but I could be wrong.

    public static final String google_project_id = ""null"";
    public static final String oauth_client_id = ""xxx"";
    public static final String oauth_client_secret = ""..."";
    public static final String oauth_redirect_uri = """";
  • @gtsiolis My app/build/generated/source/buildConfig/debug/im/gitter/gitter/ looks the same and I am seeing the syntax errors.

    Have you tested it in CI? Copy oauth_client_id, oauth_client_secret, oauth_redirect_uri into your project settings -> CI / CD -> Variables to get the build going

    Currently the build is green and working AFAICT 🤔

    Edited by Eric Eastwood
  • Sorry for responding late @MadLittleMods, I see exactly the same syntax errors but the build is failing locally. Indeed, pipeline passes when using the variables, but this should also build successfully locally to allow deployment on a device, right?

  • @gtsiolis Your changes build locally but fail in CI, ex.

    But perhaps we could just concat the necessary quotes where we set the properties from the environment variables, I went with this for now 💪

  • @MadLittleMods the pipeline you linked to is running on the master on my fork. The pipeline for these changes running on the branch on my fork is passing and the changes build locally. However, the pipeline on the master now (including 9265e39b) on my fork is passing and changes build locally, too!

  • 9265e39b passes because I amended the commit with the changes I mentioned.

    You're totally right. Thanks again for making this clear @MadLittleMods!

Please register or sign in to reply
buildConfigField("String", "oauth_client_secret", "\"${secretProperties['oauth_client_secret']}\"")
buildConfigField("String", "oauth_redirect_uri", "\"${secretProperties['oauth_redirect_uri']}\"")
buildConfigField("String", "google_project_id", "\"${secretProperties['google_project_id']}\"" ?: "null")
buildTypes {
release {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment