chiark / gitweb /
Merge branch 'fix_no-refresh' into 'master'
authorHans-Christoph Steiner <hans@guardianproject.info>
Thu, 28 Dec 2017 22:08:29 +0000 (22:08 +0000)
committerHans-Christoph Steiner <hans@guardianproject.info>
Thu, 28 Dec 2017 22:08:29 +0000 (22:08 +0000)
build: fix --no-refresh

See merge request fdroid/fdroidserver!428

fdroidserver/common.py
jenkins-setup-build-environment
jenkins-test
makebuildserver
tests/common.TestCase
tests/source-files/at.bitfire.davdroid/build.gradle [new file with mode: 0644]
tests/source-files/com.nextcloud.client/build.gradle [new file with mode: 0644]
tests/source-files/fdroid/fdroidclient/build.gradle

index aa81cb914ea3c51300c3fd4f6dec5361a007b2b1..bd831f1e642ec4a3465d3fc5d4f3780682e84b91 100644 (file)
@@ -1336,27 +1336,63 @@ def parse_androidmanifests(paths, app):
         vercode = None
         package = None
 
+        flavour = None
+        if app.builds and 'gradle' in app.builds[-1] and app.builds[-1].gradle:
+            flavour = app.builds[-1].gradle[-1]
+
         if has_extension(path, 'gradle'):
             with open(path, 'r') as f:
+                inside_flavour_group = 0
+                inside_required_flavour = 0
                 for line in f:
                     if gradle_comment.match(line):
                         continue
-                    # Grab first occurence of each to avoid running into
-                    # alternative flavours and builds.
-                    if not package:
-                        matches = psearch_g(line)
-                        if matches:
-                            s = matches.group(2)
-                            if app_matches_packagename(app, s):
-                                package = s
-                    if not version:
-                        matches = vnsearch_g(line)
-                        if matches:
-                            version = matches.group(2)
-                    if not vercode:
-                        matches = vcsearch_g(line)
-                        if matches:
-                            vercode = matches.group(1)
+
+                    if inside_flavour_group > 0:
+                        if inside_required_flavour > 0:
+                            matches = psearch_g(line)
+                            if matches:
+                                s = matches.group(2)
+                                if app_matches_packagename(app, s):
+                                    package = s
+
+                            matches = vnsearch_g(line)
+                            if matches:
+                                version = matches.group(2)
+
+                            matches = vcsearch_g(line)
+                            if matches:
+                                vercode = matches.group(1)
+
+                            if '{' in line:
+                                inside_required_flavour += 1
+                            if '}' in line:
+                                inside_required_flavour -= 1
+                        else:
+                            if flavour and (flavour in line):
+                                inside_required_flavour = 1
+
+                        if '{' in line:
+                            inside_flavour_group += 1
+                        if '}' in line:
+                            inside_flavour_group -= 1
+                    else:
+                        if "productFlavors" in line:
+                            inside_flavour_group = 1
+                        if not package:
+                            matches = psearch_g(line)
+                            if matches:
+                                s = matches.group(2)
+                                if app_matches_packagename(app, s):
+                                    package = s
+                        if not version:
+                            matches = vnsearch_g(line)
+                            if matches:
+                                version = matches.group(2)
+                        if not vercode:
+                            matches = vcsearch_g(line)
+                            if matches:
+                                vercode = matches.group(1)
         else:
             try:
                 xml = parse_xml(path)
index 983b9b23e80a378bd3e76e08903165ef8d7837a5..dc9a77515c4c6a17fcb01df1bbb12ed78aab4d37 100755 (executable)
@@ -55,6 +55,11 @@ virsh -c qemu:///system undefine buildserver_default \
       --nvram --managed-save --remove-all-storage --snapshots-metadata || true
 virsh -c qemu:///system undefine builder_default \
       --nvram --managed-save --remove-all-storage --snapshots-metadata || true
+virsh -c qemu:///system vol-delete --pool default \
+      /var/lib/libvirt/images/buildserver_vagrant_box_image_0.img || true
+virsh -c qemu:///system vol-delete --pool default \
+      /var/lib/libvirt/images/jessie64_vagrant_box_image_0.img || true
+rm -rf "$WORKSPACE"/../*/.testfiles
 
 cd $WORKSPACE
 echo "debian_mirror = 'https://deb.debian.org/debian/'" > $WORKSPACE/makebuildserver.config.py
index 39fdaa8f4c267080d1c2abb32dcda2e1fafe18e8..b065084ad7ff7d0ce44e1c4da5ec995cea820b72 100755 (executable)
@@ -23,9 +23,9 @@ set -x
 # set up Android SDK to use the Debian packages in stretch
 export ANDROID_HOME=/usr/lib/android-sdk
 
-rm -rf $WORKSPACE/.testfiles
+rm -rf "$WORKSPACE/.testfiles"
 cd tests
-./run-tests $WORKSPACE
+./run-tests $WORKSPACE/fdroiddata/repo
 
 # this is set up and managed by jenkins-build-all
 cd $WORKSPACE/fdroiddata
index 7e9ce9bda6d77c7670c33fb33b60c2ace210c7f5..cb46035e834591b2b7053d302afc6dc1ad9c8210 100755 (executable)
@@ -178,8 +178,6 @@ cachefiles = [
      '9b742d34590fe73fb7229e34835ecffb1846ca389d9f924f0b2a37de525dc6b8'),
     ('https://dl.google.com/android/repository/platform-26_r02.zip',
      '2aafa7d19c5e9c4b643ee6ade3d85ef89dc2f79e8383efdb9baf7fddad74b52a'),
-    ('https://dl.google.com/android/repository/platform-27_r01.zip',
-     'cbba6f8fcf025e1b533326746763aa1d6e2cf4001b1b441602bb44d253bc49ac'),
     ('https://dl.google.com/android/repository/build-tools_r17-linux.zip',
      '4c8444972343a19045236f6924bd7f12046287c70dace96ab88b2159c8ec0e74'),
     ('https://dl.google.com/android/repository/build-tools_r18.0.1-linux.zip',
index 06b17a04420dc9058a628a966761da83f2c2259d..3b4cc5e932fce73ed616676c3fc8758a89008b73 100755 (executable)
@@ -612,6 +612,88 @@ class CommonTest(unittest.TestCase):
         sig = fdroidserver.common.metadata_find_developer_signature('org.smssecure.smssecure')
         self.assertEqual('b30bb971af0d134866e158ec748fcd553df97c150f58b0a963190bbafbeb0868', sig)
 
+    def test_parse_androidmanifests(self):
+        source_files_dir = os.path.join(os.path.dirname(__file__), 'source-files')
+        app = fdroidserver.metadata.App()
+        app.id = 'org.fdroid.fdroid'
+        paths = [
+            os.path.join(source_files_dir, 'fdroid', 'fdroidclient', 'AndroidManifest.xml'),
+            os.path.join(source_files_dir, 'fdroid', 'fdroidclient', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('0.94-test', '940', 'org.fdroid.fdroid'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
+    def test_parse_androidmanifests_with_flavor(self):
+        source_files_dir = os.path.join(os.path.dirname(__file__), 'source-files')
+
+        app = fdroidserver.metadata.App()
+        build = fdroidserver.metadata.Build()
+        build.gradle = ['devVersion']
+        app.builds = [build]
+        app.id = 'org.fdroid.fdroid.dev'
+        paths = [
+            os.path.join(source_files_dir, 'fdroid', 'fdroidclient', 'AndroidManifest.xml'),
+            os.path.join(source_files_dir, 'fdroid', 'fdroidclient', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('0.95-dev', '949', 'org.fdroid.fdroid.dev'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
+        app = fdroidserver.metadata.App()
+        build = fdroidserver.metadata.Build()
+        build.gradle = ['free']
+        app.builds = [build]
+        app.id = 'eu.siacs.conversations'
+        paths = [
+            os.path.join(source_files_dir, 'eu.siacs.conversations', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('1.23.1', '245', 'eu.siacs.conversations'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
+        app = fdroidserver.metadata.App()
+        build = fdroidserver.metadata.Build()
+        build.gradle = ['generic']
+        app.builds = [build]
+        app.id = 'com.nextcloud.client'
+        paths = [
+            os.path.join(source_files_dir, 'com.nextcloud.client', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('2.0.0', '20000099', 'com.nextcloud.client'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
+        app = fdroidserver.metadata.App()
+        build = fdroidserver.metadata.Build()
+        build.gradle = ['versionDev']
+        app.builds = [build]
+        app.id = 'com.nextcloud.android.beta'
+        paths = [
+            os.path.join(source_files_dir, 'com.nextcloud.client', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('20171223', '20171223', 'com.nextcloud.android.beta'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
+        app = fdroidserver.metadata.App()
+        build = fdroidserver.metadata.Build()
+        build.gradle = ['standard']
+        app.builds = [build]
+        app.id = 'at.bitfire.davdroid'
+        paths = [
+            os.path.join(source_files_dir, 'at.bitfire.davdroid', 'build.gradle'),
+        ]
+        for path in paths:
+            self.assertTrue(os.path.isfile(path))
+        self.assertEqual(('1.9.8.1-ose', '197', 'at.bitfire.davdroid'),
+                         fdroidserver.common.parse_androidmanifests(paths, app))
+
 
 if __name__ == "__main__":
     parser = optparse.OptionParser()
diff --git a/tests/source-files/at.bitfire.davdroid/build.gradle b/tests/source-files/at.bitfire.davdroid/build.gradle
new file mode 100644 (file)
index 0000000..5bac8b0
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) Ricki Hirner (bitfire web engineering).
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Public License v3.0
+ * which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/gpl.html
+ */
+
+apply plugin: 'com.android.application'
+apply plugin: 'kotlin-android'
+apply plugin: 'kotlin-android-extensions'
+apply plugin: 'org.jetbrains.dokka-android'
+
+android {
+    compileSdkVersion 27
+    buildToolsVersion '27.0.1'
+
+    defaultConfig {
+        applicationId "at.bitfire.davdroid"
+
+        versionCode 197
+        buildConfigField "long", "buildTime", System.currentTimeMillis() + "L"
+        buildConfigField "boolean", "customCerts", "true"
+
+        minSdkVersion 19        // Android 4.4
+        targetSdkVersion 27     // Android 8.1
+
+        // when using this, make sure that notification icons are real bitmaps
+        vectorDrawables.useSupportLibrary = true
+    }
+
+    flavorDimensions "type"
+
+    productFlavors {
+        standard {
+            versionName "1.9.8.1-ose"
+
+            buildConfigField "boolean", "customCerts", "true"
+            buildConfigField "boolean", "customCertsUI", "true"
+        }
+    }
+
+    buildTypes {
+        debug {
+            minifyEnabled false
+        }
+        release {
+            minifyEnabled true
+            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
+        }
+    }
+
+    lintOptions {
+        disable 'GoogleAppIndexingWarning'      // we don't need Google indexing, thanks
+        disable 'ImpliedQuantity', 'MissingQuantity'           // quantities from Transifex may vary
+        disable 'MissingTranslation', 'ExtraTranslation'       // translations from Transifex are not always up to date
+        disable "OnClick"     // doesn't recognize Kotlin onClick methods
+        disable 'Recycle'           // doesn't understand Lombok's @Cleanup
+        disable 'RtlEnabled'
+        disable 'RtlHardcoded'
+        disable 'Typos'
+    }
+    packagingOptions {
+        exclude 'META-INF/DEPENDENCIES'
+        exclude 'META-INF/LICENSE'
+    }
+
+    defaultConfig {
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+    }
+}
+
+dependencies {
+    compile project(':cert4android')
+    compile project(':dav4android')
+    compile project(':ical4android')
+    compile project(':vcard4android')
+
+    compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
+
+    compile 'com.android.support:appcompat-v7:27.0.2'
+    compile 'com.android.support:cardview-v7:27.0.2'
+    compile 'com.android.support:design:27.0.2'
+    compile 'com.android.support:preference-v14:27.0.2'
+
+    compile 'com.github.yukuku:ambilwarna:2.0.1'
+
+    compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
+    compile 'commons-io:commons-io:2.6'
+    compile 'dnsjava:dnsjava:2.1.8'
+    compile 'org.apache.commons:commons-lang3:3.6'
+    compile 'org.apache.commons:commons-collections4:4.1'
+
+    // for tests
+    //noinspection GradleDynamicVersion
+    androidTestCompile('com.android.support.test:runner:+') {
+        exclude group: 'com.android.support', module: 'support-annotations'
+    }
+    //noinspection GradleDynamicVersion
+    androidTestCompile('com.android.support.test:rules:+') {
+        exclude group: 'com.android.support', module: 'support-annotations'
+    }
+    androidTestCompile 'junit:junit:4.12'
+    androidTestCompile 'com.squareup.okhttp3:mockwebserver:3.9.1'
+
+    testCompile 'junit:junit:4.12'
+    testCompile 'com.squareup.okhttp3:mockwebserver:3.9.1'
+}
diff --git a/tests/source-files/com.nextcloud.client/build.gradle b/tests/source-files/com.nextcloud.client/build.gradle
new file mode 100644 (file)
index 0000000..528f612
--- /dev/null
@@ -0,0 +1,253 @@
+// Gradle build file
+//
+// This project was started in Eclipse and later moved to Android Studio. In the transition, both IDEs were supported.
+// Due to this, the files layout is not the usual in new projects created with Android Studio / gradle. This file
+// merges declarations usually split in two separates build.gradle file, one for global settings of the project in
+// its root folder, another one for the app module in subfolder of root.
+
+buildscript {
+    repositories {
+        jcenter()
+        maven {
+            url 'https://oss.sonatype.org/content/repositories/snapshots/'
+        }
+        google()
+    }
+    dependencies {
+        classpath 'com.android.tools.build:gradle:3.0.1'
+        classpath 'com.google.gms:google-services:3.0.0'
+    }
+}
+
+apply plugin: 'com.android.application'
+apply plugin: 'checkstyle'
+apply plugin: 'pmd'
+apply plugin: 'findbugs'
+
+configurations.all {
+    // check for updates every build
+    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
+}
+
+ext {
+    supportLibraryVersion = '26.1.0'
+    googleLibraryVersion = '11.2.2'
+
+    travisBuild = System.getenv("TRAVIS") == "true"
+
+    // allows for -Dpre-dex=false to be set
+    preDexEnabled = "true".equals(System.getProperty("pre-dex", "true"))
+}
+
+repositories {
+    jcenter()
+    maven { url "https://jitpack.io" }
+    maven { url 'https://oss.sonatype.org/content/repositories/snapshots/' }
+    google()
+
+    flatDir {
+        dirs 'libs'
+    }
+}
+
+android {
+    lintOptions {
+        abortOnError false
+        htmlReport true
+        htmlOutput file("$project.buildDir/reports/lint/lint.html")
+        disable 'MissingTranslation'
+    }
+
+    dexOptions {
+        javaMaxHeapSize "4g"
+    }
+
+    compileSdkVersion 26
+    buildToolsVersion '26.0.2'
+
+    defaultConfig {
+        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
+
+        // arguments to be passed to functional tests
+        testInstrumentationRunnerArgument "TEST_USER", "\"$System.env.OCTEST_APP_USERNAME\""
+        testInstrumentationRunnerArgument "TEST_PASSWORD", "\"$System.env.OCTEST_APP_PASSWORD\""
+        testInstrumentationRunnerArgument "TEST_SERVER_URL", "\"$System.env.OCTEST_SERVER_BASE_URL\""
+
+        multiDexEnabled true
+
+        versionCode = 20000099
+        versionName = "2.0.0"
+
+        // adapt structure from Eclipse to Gradle/Android Studio expectations;
+        // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
+
+        flavorDimensions "default"
+
+        productFlavors {
+            // used for f-droid
+            generic {
+                applicationId 'com.nextcloud.client'
+                dimension "default"
+            }
+
+            gplay {
+                applicationId 'com.nextcloud.client'
+                dimension "default"
+            }
+
+            modified {
+                // structure is:
+                // domain tld
+                // domain name
+                // .client
+                applicationId 'com.custom.client'
+                dimension "default"
+            }
+
+            versionDev {
+                applicationId "com.nextcloud.android.beta"
+                dimension "default"
+                versionCode 20171223
+                versionName "20171223"
+            }
+        }
+
+        configurations {
+            modifiedCompile
+        }
+    }
+
+
+    // adapt structure from Eclipse to Gradle/Android Studio expectations;
+    // see http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Configuring-the-Structure
+
+    dexOptions {
+        // Skip pre-dexing when running on Travis CI or when disabled via -Dpre-dex=false.
+        preDexLibraries = preDexEnabled && !travisBuild
+    }
+
+    packagingOptions {
+        exclude 'META-INF/LICENSE.txt'
+        exclude 'META-INF/LICENSE'
+    }
+
+    task checkstyle(type: Checkstyle) {
+        configFile = file("${rootProject.projectDir}/checkstyle.xml")
+        configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath
+        source 'src'
+        include '**/*.java'
+        exclude '**/gen/**'
+        classpath = files()
+    }
+
+    task pmd(type: Pmd) {
+        ruleSetFiles = files("${project.rootDir}/pmd-ruleset.xml")
+        ignoreFailures = false
+        ruleSets = []
+
+        source 'src'
+        include '**/*.java'
+        exclude '**/gen/**'
+
+        reports {
+            xml.enabled = false
+            html.enabled = true
+            xml {
+                destination = file("$project.buildDir/reports/pmd/pmd.xml")
+            }
+            html {
+                destination = file("$project.buildDir/reports/pmd/pmd.html")
+            }
+        }
+    }
+
+    task findbugs(type: FindBugs) {
+        ignoreFailures = false
+        effort = "max"
+        reportLevel = "high"
+        classes = files("$project.buildDir/intermediates/classes")
+        excludeFilter = new File("${project.rootDir}/findbugs-filter.xml")
+        source 'src'
+        include '**/*.java'
+        exclude '**/gen/**'
+
+        reports {
+            xml.enabled = false
+            html.enabled = true
+            html {
+                destination  = file("$project.buildDir/reports/findbugs/findbugs.html")
+            }
+        }
+        classpath = files()
+    }
+    check.dependsOn 'checkstyle', 'findbugs', 'pmd', 'lint'
+
+    compileOptions {
+        sourceCompatibility JavaVersion.VERSION_1_8
+        targetCompatibility JavaVersion.VERSION_1_8
+    }
+}
+
+dependencies {
+    /// dependencies for app building
+    implementation 'com.android.support:multidex:1.0.2'
+    implementation 'com.github.nextcloud:android-library:1.0.33'
+    versionDevImplementation 'com.github.nextcloud:android-library:master-SNAPSHOT' // use always latest master
+    implementation "com.android.support:support-v4:${supportLibraryVersion}"
+    implementation "com.android.support:design:${supportLibraryVersion}"
+    implementation 'com.jakewharton:disklrucache:2.0.2'
+    implementation "com.android.support:appcompat-v7:${supportLibraryVersion}"
+    implementation "com.android.support:cardview-v7:${supportLibraryVersion}"
+    implementation "com.android.support:exifinterface:${supportLibraryVersion}"
+    implementation 'com.github.tobiasKaminsky:android-floating-action-button:1.10.2'
+    implementation 'com.github.albfernandez:juniversalchardet:v2.0.0'
+    implementation 'com.google.code.findbugs:annotations:2.0.1'
+    implementation 'commons-io:commons-io:2.5'
+    implementation 'com.github.evernote:android-job:v1.2.0'
+    implementation 'com.jakewharton:butterknife:8.5.1'
+    annotationProcessor 'com.jakewharton:butterknife-compiler:8.5.1'
+    implementation 'org.greenrobot:eventbus:3.0.0'
+    implementation 'com.googlecode.ez-vcard:ez-vcard:0.10.2'
+    implementation 'org.lukhnos:nnio:0.2'
+    // uncomment for gplay, modified
+    // implementation "com.google.firebase:firebase-messaging:${googleLibraryVersion}"
+    // implementation "com.google.android.gms:play-services-base:${googleLibraryVersion}"
+    // implementation "com.google.android.gms:play-services-gcm:${googleLibraryVersion}"
+    // implementation "com.google.firebase:firebase-core:${googleLibraryVersion}"
+    implementation 'org.parceler:parceler-api:1.1.6'
+    annotationProcessor 'org.parceler:parceler:1.1.6'
+    implementation 'com.github.bumptech.glide:glide:3.7.0'
+    implementation 'com.caverock:androidsvg:1.2.1'
+    implementation "com.android.support:support-annotations:${supportLibraryVersion}"
+
+    /// dependencies for local unit tests
+    testImplementation 'junit:junit:4.12'
+    testImplementation 'org.mockito:mockito-core:1.10.19'
+    /// dependencies for instrumented tests
+    // JUnit4 Rules
+    androidTestImplementation 'com.android.support.test:rules:1.0.1'
+    // Android JUnit Runner
+    androidTestImplementation 'com.android.support.test:runner:1.0.1'
+
+    // Espresso core
+    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
+    // UIAutomator - for cross-app UI tests, and to grant screen is turned on in Espresso tests
+    //androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2'
+    // fix conflict in dependencies; see http://g.co/androidstudio/app-test-app-conflict for details
+    //androidTestImplementation "com.android.support:support-annotations:${supportLibraryVersion}"
+    implementation 'org.jetbrains:annotations:15.0'
+}
+
+configurations.all {
+    resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
+}
+
+tasks.withType(Test) {
+    /// increased logging for tests
+    testLogging {
+        events "passed", "skipped", "failed"
+    }
+}
+
+// uncomment for gplay, modified (must be at the bottom)
+//apply plugin: 'com.google.gms.google-services'
index 1d994dc8556b25422499b25084da9816161220c7..8971f235367db18eb431684b1c4eedb2debab85c 100644 (file)
@@ -129,6 +129,21 @@ android {
     compileSdkVersion 21
     buildToolsVersion '22.0.1'
 
+    defaultConfig {
+
+        flavorDimensions "default"
+
+        productFlavors {
+            devVersion {
+                applicationId "org.fdroid.fdroid.dev"
+                dimension "default"
+                versionCode 949
+                versionName "0.95-dev"
+            }
+        }
+
+    }
+
     sourceSets {
         main {
             manifest.srcFile 'AndroidManifest.xml'