.gitlab-ci.yml 3.81 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
  - echo y | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-${ANDROID_COMPILE_SDK}"
16

17 18 19 20 21 22 23 24 25 26 27 28 29
.test-template: &test-template
  artifacts:
    name: "${CI_PROJECT_PATH}_${CI_JOB_STAGE}_${CI_COMMIT_REF_NAME}_${CI_COMMIT_SHA}"
    paths:
      - logcat.txt
      - 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"

30 31
# Run the most important first. Then we can decide whether to ignore
# the style tests if the rest of the more meaningful tests pass.
Daniel Martí's avatar
Daniel Martí committed
32
test:
33
  stage: test
34
  <<: *test-template
35
  script:
36
    - export EXITVALUE=0
37
    - ./gradlew assemble
38
    # always report on lint errors to the build log
39
    - sed -i -e 's,textReport .*,textReport true,' app/build.gradle
40
    - ./gradlew test
41
    - ./gradlew lint
42 43 44 45 46 47
    - ./gradlew pmd || export EXITVALUE=1
    - ./gradlew checkstyle || export EXITVALUE=1
    - ./tools/check-format-strings.py
    - ./tools/remove-unused-and-blank-translations.py
    - echo "These are unused or blank translations that should be removed:"
    - git --no-pager diff --ignore-all-space --name-only --exit-code || export EXITVALUE=1
48
    - exit $EXITVALUE
49

50 51 52 53 54 55 56
errorprone:
  stage: test
  script:
    - cat config/errorprone.gradle >> app/build.gradle
    - ./gradlew assembleDebug
  allow_failure: true

57
connected14:
58
  stage: test
59
  <<: *test-template
60
  variables:
61
    AVD_SDK: "14"
62
  script:
63
    - ./gradlew assembleDebug
64 65 66
    - echo y | $ANDROID_HOME/tools/bin/sdkmanager "platforms;android-$AVD_SDK"
    - echo y | $ANDROID_HOME/tools/bin/sdkmanager "system-images;android-${AVD_SDK};default;armeabi-v7a"
    - echo no | android --verbose create avd --name fcl-test-$AVD_SDK --target android-$AVD_SDK
67 68 69
    - emulator64-arm -avd fcl-test-$AVD_SDK -no-skin -no-audio -no-window &
    - ./tools/wait-for-emulator
    - adb shell input keyevent 82 &
70
    - ./gradlew connectedCheck || adb -e logcat -d '*:E' > logcat.txt
71

72
connected24:
73
  stage: test
74
  variables:
75
    AVD_SDK: "24"
76
  <<: *test-template
77
  script:
78
    - ./gradlew assembleDebug
79
    - android list avd
80
    - emulator64-arm -avd fcl-test-$AVD_SDK -no-audio -no-window &
81
    - ./tools/wait-for-emulator
82
    - adb shell input keyevent 82 &
83
    - adb devices
84
    - ./gradlew connectedCheck || adb -e logcat -d '*:E' > logcat.txt
85

86 87 88 89 90
deploy_nightly:
  stage: deploy
  only:
    - master
  script:
91 92 93 94
    - 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
95 96 97 98
    - 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
99 100 101
    - 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
102
    # build the APKs!
103 104
    - ./gradlew assembleDebug
    - fdroid nightly -v
105

106 107 108 109
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/