Advertisement
Guest User

Gitlab CI script

a guest
Mar 1st, 2020
760
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
YAML 2.33 KB | None | 0 0
  1. image: jangrewe/gitlab-ci-android
  2.  
  3. stages:
  4.  - build
  5.   - test
  6.  
  7. before_script:
  8. - export GRADLE_USER_HOME=$(pwd)/.gradle
  9. - chmod +x ./gradlew
  10.  
  11. build_debug:
  12.   stage: build
  13.   script:
  14.    - ./gradlew assembleDebug
  15.   artifacts:
  16.     paths:
  17.      - app/build/outputs/
  18.  
  19. .test_lab_template: &test_lab_template_def
  20.   stage: test
  21.   before_script:
  22.    # Preparing wget
  23.     - apt-get update
  24.     #- apt-get upgrade -y
  25.     - apt install python2.7 python-pip -y
  26.     #- apt-get install wget
  27.  
  28.     # Install Google Cloud SDK
  29.     - curl https://dl.google.com/dl/cloudsdk/channels/rapid/google-cloud-sdk.tar.gz --output /tmp/google-cloud-sdk.tar.gz
  30.     - mkdir -p /opt
  31.     - tar zxf /tmp/google-cloud-sdk.tar.gz --directory /opt
  32.     - /opt/google-cloud-sdk/install.sh --quiet
  33.     - source /opt/google-cloud-sdk/path.bash.inc
  34.  
  35.     # Setup and configure the project
  36.     - gcloud components update
  37.     - echo $GCLOUD_PROJECT_ID
  38.     - gcloud config set project $GCLOUD_PROJECT_ID
  39.  
  40.     # Activate cloud credentials
  41.     - echo $SERVICE_ACCOUNT > /tmp/service-account.json
  42.     - gcloud auth activate-service-account --key-file /tmp/service-account.json
  43.  
  44.     # List available options for logging purpose only (so that we can review available options)
  45.     - gcloud firebase test android models list
  46.     - gcloud firebase test android versions list
  47.  
  48.  
  49.   after_script:
  50.    - source /opt/google-cloud-sdk/path.bash.inc
  51.  
  52.     # Iterate up to 10 possible test lab configurations and create CLI tool options
  53.     - for i in `seq 1 10`; do export CONFIG="TEST_LAB_DEVICE_CONFIGURATION_$i"; if [ -n "${!CONFIG}" ]; then export TEST_LAB_DEVICE_CONFIGURATIONS="$TEST_LAB_DEVICE_CONFIGURATIONS --device model=${!CONFIG} "; fi; done
  54.  
  55.     # Output for debug logging purpose only
  56.     - echo $TEST_LAB_DEVICE_CONFIGURATIONS
  57.  
  58.     # Run tests if there were any configured
  59.     - if [ -n "$TEST_LAB_DEVICE_CONFIGURATIONS" ]; then gcloud firebase test android run --type robo --app app.apk $TEST_LAB_DEVICE_CONFIGURATIONS --timeout 90s; fi
  60.  
  61.     # Warn if there were no configurations
  62.     - if [ -z "$TEST_LAB_DEVICE_CONFIGURATIONS" ]; then echo "NO FIREBASE TESTLAB CONFIGURATIONS!!!"; fi
  63.  
  64. test_lab_debug:
  65.     <<: *test_lab_template_def
  66.     script:
  67.        - cp app/build/outputs/apk/autopizza/debug/app-autopizza-debug.apk ./app.apk
  68.     dependencies:
  69.        - build_debug
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement