.gitlab-ci.yml 5.21 KB
Newer Older
1
image: registry.gitlab.com/fdroid/ci-images-client:latest
Daniel Martí's avatar
Daniel Martí committed
2

3 4 5 6 7
cache:
  paths:
    - .gradle/wrapper
    - .gradle/caches

8 9 10 11
stages:
  - test
  - deploy

12 13
before_script:
  - export GRADLE_USER_HOME=$PWD/.gradle
14
  - export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
15
  - alias sdkmanager="sdkmanager --no_https"
16
  - echo y | sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}" > /dev/null
17

18
.test-template: &test-template
19
  stage: test
20 21 22 23
  artifacts:
    name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
    paths:
      - logcat.txt
24 25
      - app/core*
      - app/*.log
26 27 28 29 30 31 32 33
      - app/build/reports
      - app/build/outputs/*ml
      - app/build/outputs/apk
    expire_in: 1 week
    when: on_failure
  after_script:
    - echo "Download debug artifacts from https://gitlab.com/${CI_PROJECT_PATH}/-/jobs"

34 35
# Run the most important first. Then we can decide whether to ignore
# the style tests if the rest of the more meaningful tests pass.
36
test_lint_pmd_checkstyle:
37
  <<: *test-template
38
  script:
39
    - export EXITVALUE=0
40
    - ./gradlew assemble
41
    # always report on lint errors to the build log
42
    - sed -i -e 's,textReport .*,textReport true,' app/build.gradle
43
    - ./gradlew testFullDebugUnitTest
44
    - ./gradlew lint
45 46 47 48 49
    - ./gradlew pmd || (export EXITVALUE=1; echo ERROR !!)
    - ./gradlew checkstyle || (export EXITVALUE=1; echo ERROR !!)
    - ./tools/check-format-strings.py || (export EXITVALUE=1; echo ERROR !!)
    - ./tools/check-fastlane-whitespace.py || (export EXITVALUE=1; echo ERROR !!)
    - ./tools/remove-unused-and-blank-translations.py || (export EXITVALUE=1; echo ERROR !!)
50
    - echo "These are unused or blank translations that should be removed:"
51
    - git --no-pager diff --ignore-all-space --name-only --exit-code app/src/*/res/values*/strings.xml || (export EXITVALUE=1; echo ERROR !!)
52
    - exit $EXITVALUE
53

54 55 56
errorprone:
  stage: test
  script:
57 58 59 60
    - apt-get update
    - apt-get install -t stretch-backports openjdk-11-jdk-headless
    - update-java-alternatives --set java-1.11.0-openjdk-amd64
    - export JAVA_HOME=/usr/lib/jvm/java-1.11.0-openjdk-amd64
61
    - cat config/errorprone.gradle >> app/build.gradle
62 63
    - ./gradlew --write-verification-metadata pgp,sha256
    - git diff || true
64
    - ./gradlew -Dorg.gradle.dependency.verification=lenient assembleDebug
65

66 67
# once these prove stable, the task should be switched to
# connectedCheck to test all the build flavors
68
.connected-template: &connected-template
69
  script:
70
    - ./gradlew assembleFullDebug
71 72 73 74 75
    - export AVD_SDK=`echo $CI_JOB_NAME | awk '{print $2}'`
    - export AVD_TAG=`echo $CI_JOB_NAME | awk '{print $3}'`
    - export AVD_ARCH=`echo $CI_JOB_NAME | awk '{print $4}'`
    - export AVD_PACKAGE="system-images;android-${AVD_SDK};${AVD_TAG};${AVD_ARCH}"
    - echo $AVD_PACKAGE
76

77
    - alias sdkmanager
78
    - ls -l ~/.android
79 80 81

    - adb start-server
    - start-emulator
82
    - wait-for-emulator
83
    - adb devices
84
    - adb shell input keyevent 82 &
85 86 87
    - if [ $AVD_SDK -lt 25 ] || ! emulator -accel-check; then
          export FLAG=-Pandroid.testInstrumentationRunnerArguments.notAnnotation=android.support.test.filters.LargeTest;
      fi
88 89 90 91
    - ./gradlew connectedFullDebugAndroidTest $FLAG
      || ./gradlew connectedFullDebugAndroidTest $FLAG
      || ./gradlew connectedFullDebugAndroidTest $FLAG
      || (adb -e logcat -d > logcat.txt; exit 1)
92

93
connected 22 default armeabi-v7a:
94
  retry: 1
95 96 97
  <<: *test-template
  <<: *connected-template

98 99 100 101
.kvm-template: &kvm-template
  tags:
    - fdroid
    - kvm
102
  allow_failure: true
103
  only:
104
    - branches@eighthave/fdroidclient
105 106 107
  <<: *test-template
  <<: *connected-template

108
connected 23 default x86:
109 110 111 112 113 114 115
  <<: *kvm-template

connected 25 default x86:
  <<: *kvm-template

connected 26 google_apis x86:
  <<: *kvm-template
116 117 118
  only:
    - branches@fdroid/fdroidclient
    - branches@eighthave/fdroidclient
119 120 121 122 123 124 125

connected 27 google_apis_playstore x86:
  <<: *kvm-template

connected 28 default x86_64:
  <<: *kvm-template

126
connected 29 default x86_64:
127 128
  <<: *kvm-template

129

130
deploy_nightly:
131 132 133 134
  stage: deploy
  only:
    - master
  script:
135
    - test -z "$DEBUG_KEYSTORE" && exit 0
136 137 138 139
    - sed -i
        's,<string name="app_name">.*</string>,<string name="app_name">F-Nightly</string>,'
        app/src/main/res/values*/strings.xml
    # add this nightly repo as a enabled repo
140 141 142 143
    - sed -i -e '/<\/string-array>/d' -e '/<\/resources>/d' app/src/main/res/values/default_repos.xml
    - echo "<item>${CI_PROJECT_PATH}-nightly</item>" >> app/src/main/res/values/default_repos.xml
    - echo "<item>${CI_PROJECT_URL}-nightly/raw/master/fdroid/repo</item>" >> app/src/main/res/values/default_repos.xml
    - cat config/nightly-repo/repo.xml >> app/src/main/res/values/default_repos.xml
144 145 146
    - export DB=`sed -n 's,.*DB_VERSION *= *\([0-9][0-9]*\).*,\1,p' app/src/main/java/org/fdroid/fdroid/data/DBHelper.java`
    - export versionCode=`printf '%d%05d' $DB $(date '+%s'| cut -b4-8)`
    - sed -i "s,^\(\s*versionCode\)  *[0-9].*,\1 $versionCode," app/build.gradle
147
    # build the APKs!
148 149
    - ./gradlew assembleDebug
    - fdroid nightly -v
150

151 152 153 154
after_script:
    # this file changes every time but should not be cached
    - rm -f $GRADLE_USER_HOME/caches/modules-2/modules-2.lock
    - rm -fr $GRADLE_USER_HOME/caches/*/plugin-resolution/