.gitlab-ci.yml 2.94 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 15
  - export ANDROID_COMPILE_SDK=`sed -n 's,.*compileSdkVersion\s*\([0-9][0-9]*\).*,\1,p' app/build.gradle`
  - echo y | android --silent update sdk --no-ui --filter 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"

Daniel Martí's avatar
Daniel Martí committed
30
test:
31
  stage: test
32
  <<: *test-template
33
  script:
34
    - export EXITVALUE=0
35
    - ./tools/check-format-strings.py
36
    - ./tools/remove-unused-and-blank-translations.py
37 38
    - echo "These are unused or blank translations that should be removed:"
    - git --no-pager diff --exit-code || export EXITVALUE=1
39
    - ./gradlew assemble
40
    # always report on lint errors to the build log
41
    - sed -i -e 's,textReport .*,textReport true,' app/build.gradle
42 43 44
    - ./gradlew lint
    - ./gradlew pmd
    - ./gradlew checkstyle
45
    - ./gradlew test || export EXITVALUE=1
46
    - exit $EXITVALUE
47

48
connected10:
49
  stage: test
50
  <<: *test-template
51 52 53
  variables:
    AVD_SDK: "10"
  script:
54
    - ./gradlew assembleDebug
55 56 57
    - emulator64-arm -avd fcl-test-$AVD_SDK -no-skin -no-audio -no-window &
    - ./tools/wait-for-emulator
    - adb shell input keyevent 82 &
58
    - ./gradlew connectedCheck || adb -e logcat -d '*:E' > logcat.txt
59

60
connected24:
61
  stage: test
62
  variables:
63
    AVD_SDK: "24"
64
  <<: *test-template
65
  script:
66
    - ./gradlew assembleDebug
67
    - android list avd
68
    - emulator64-arm -avd fcl-test-$AVD_SDK -no-audio -no-window &
69
    - ./tools/wait-for-emulator
70
    - adb shell input keyevent 82 &
71
    - adb devices
72
    - ./gradlew connectedCheck || adb -e logcat -d '*:E' > logcat.txt
73

74 75 76 77 78
deploy_nightly:
  stage: deploy
  only:
    - master
  script:
79 80 81 82
    - 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
83 84 85 86
    - 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
87
    # build the APKs!
88 89
    - ./gradlew assembleDebug
    - fdroid nightly -v
90

91 92 93 94
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/