Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CircleCIを使ったAndroidの開発フローの効率化とtips

ymnder
May 28, 2019

 CircleCIを使ったAndroidの開発フローの効率化とtips

CircleCI ユーザーコミュニティミートアップ #4 2019/5/28 @ymnd
https://circleci.connpass.com/event/125622/

ymnder

May 28, 2019
Tweet

More Decks by ymnder

Other Decks in Technology

Transcript

  1. CircleCI Android tips
    CircleCI #4 2019/5/28 @ymnd

    View full-size slide

  2. whoami
    twitter:@ymnd, GitHub:@ymnder
    Application Engineer
    Android
    Android
    :
    https://riconken.bitbucket.io/hifumi/

    View full-size slide

  3. Circle CI .
    CI Private repository
    Danger
    CI CI

    View full-size slide

  4. CircleCI .
    2018 CircleCI .
    v . 15
    push waiting
    v . ~ ↗↗↗

    View full-size slide

  5. [CI]
    local -> GitHub -> CircleCI
    [CD]
    local -> Fabric Beta

    View full-size slide

  6. CircleCI CD
    gradle Beta
    CD
    QA
    apk
    1.0 master apk

    View full-size slide

  7. CircleCI
    A: UnitTest
    gradle-git-repo-plugin
    B: Danger

    View full-size slide

  8. CircleCI private repository

    View full-size slide

  9. CircleCI private repository
    private CircleCI
    UnitTest
    submodule
    gradle-git-repo-plugin

    View full-size slide

  10. submodule
    git submodule update init

    View full-size slide

  11. gradle-git-repo-plugin
    private
    private aar
    git
    clone ~/.gitRepos/
    ~/.gitRepos/
    https://qiita.com/kgmyshin/items/ f c c fbd
    https://qiita.com/shimada_takuya/items/ e b ae f ad a

    View full-size slide

  12. gradle-git-repo-plugin
    fork
    grgit
    GitHub
    https://blog.github.com/ - - -weak-cryptographic-
    standards-removed/

    View full-size slide

  13. gradle-git-repo-plugin
    //build.gradle
    dependencies {
    classpath 'com.github.atsushi-ageet:gradle-git-repo-plugin:2.0.4'
    }
    //app/build.gradle
    apply plugin: 'git-repo'
    repositories {
    // Username repository name branch directory
    github("Nikkei", "KaizenRequest_Android", "master", "repository")
    }
    dependencies {
    implementation ('com.nikkei:kaizenrequest:1.4.1') {
    }

    View full-size slide

  14. gradle-git-repo-plugin Circle CI
    version: 2
    jobs:
    build:
    working_directory: ~/code
    docker:
    - image: circleci/android:api-28
    environment:
    _JAVA_OPTIONS: -Xms512m -Xmx1024m
    steps:
    - checkout
    - add_ssh_keys:
    fingerprints:
    - “ssh_key”
    - run: cp ssh_config ~/.ssh/config
    - run: git clone [email protected]:ymnder/Hoge.git ~/.gitRepos/ymnder/hoge_library
    - run:
    name: Run Unit Test
    command: ./gradlew testReleaseUnitTest -Poffline

    View full-size slide

  15. gradle-git-repo-plugin Circle CI
    version: 2
    jobs:
    build:
    working_directory: ~/code
    docker:
    - image: circleci/android:api-28
    environment:
    _JAVA_OPTIONS: -Xms512m -Xmx1024m
    steps:
    - checkout
    - add_ssh_keys:
    fingerprints:
    - “ssh_key”
    - run: cp ssh_config ~/.ssh/config
    - run: git clone [email protected]:ymnder/Hoge.git ~/.gitRepos/ymnder/hoge_library
    - run:
    name: Run Unit Test
    command: ./gradlew testReleaseUnitTest -Poffline

    View full-size slide

  16. gradle-git-repo-plugin Circle CI
    CI Deploy Keys
    current branch ssh key != library ssh key
    add_ssh_keys
    GitHub(deploy keys) -> CircleCI(SSH Permissions)

    View full-size slide

  17. gradle-git-repo-plugin Circle CI
    version: 2
    jobs:
    build:
    working_directory: ~/code
    docker:
    - image: circleci/android:api-28
    environment:
    _JAVA_OPTIONS: -Xms512m -Xmx1024m
    steps:
    - checkout
    - add_ssh_keys:
    fingerprints:
    - “ssh_key”
    - run: cp ssh_config ~/.ssh/config
    - run: git clone [email protected]:ymnder/Hoge.git ~/.gitRepos/ymnder/hoge_library
    - run:
    name: Run Unit Test
    command: ./gradlew testReleaseUnitTest -Poffline

    View full-size slide

  18. gradle-git-repo-plugin Circle CI
    //ssh_config
    Host Hoge-Android
    HostName github.com
    User git
    IdentityFile /home/circleci/.ssh/id_hoge
    Host Fuga-Android
    HostName github.com
    User git
    IdentityFile /home/circleci/.ssh/id_hoge
    - run: git clone git@Hoge-Android:ymnder/Hoge.git ~/.gitRepos/hoge_library
    - run: git clone git@Fuga-Android:ymnder/Fuga.git ~/.gitRepos/fuga_library

    View full-size slide

  19. gradle-git-repo-plugin Circle CI
    repository clone
    ssh_con g
    clone

    View full-size slide

  20. gradle-git-repo-plugin Circle CI
    version: 2
    jobs:
    build:
    working_directory: ~/code
    docker:
    - image: circleci/android:api-28
    environment:
    _JAVA_OPTIONS: -Xms512m -Xmx1024m
    steps:
    - checkout
    - add_ssh_keys:
    fingerprints:
    - “ssh_key”
    - run: cp ssh_config ~/.ssh/config
    - run: git clone [email protected]:ymnder/Hoge.git ~/.gitRepos/ymnder/hoge_library
    - run:
    name: Run Unit Test
    command: ./gradlew testReleaseUnitTest -Poffline

    View full-size slide

  21. gradle-git-repo-plugin Circle CI
    Test gradle -Po ine
    git-repo-plugin
    GitHub
    private repository

    View full-size slide

  22. Danger
    (Ruby)
    CI Pull Requests

    View full-size slide

  23. Danger
    plugin
    issue
    issue
    Milestone
    WIP
    Lint

    View full-size slide

  24. Danger
    APK
    https://github.com/jmatsu/danger-apkstats

    View full-size slide

  25. Danger
    Gem le
    gem install bundle
    bundle init
    Gem le
    # Gemfile
    gem 'danger'
    gem 'danger-android_lint'
    gem 'danger-apkstats'

    View full-size slide

  26. Danger
    Gem le lock
    bundle install
    Danger le
    ### lint
    android_lint.gradle_task = "lintDebug -Poffline"
    android_lint.report_file = "path/app/build/reports/lint-results-Debug.xml"
    android_lint.filtering = true
    android_lint.lint(inline_mode: true)
    ### stats
    apkstats.command_type=:apk_analyzer
    apkstats.apk_filepath='~/app-debug.apk'
    apkstats.compare_with('~/old-app-debug.apk', do_report: true)

    View full-size slide

  27. Danger
    android_lint. ltering
    lint
    https://github.com/loadsmart/danger-android_lint/blob/
    c bf b aa c b a a bd af /lib/
    android_lint/plugin.rb#L

    View full-size slide

  28. Danger
    .circleci/con g.yml
    images Ruby
    - save_cache:
    paths:
    - ~/.gradle
    key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
    - restore_cache:
    key: gems-{{ checksum "Gemfile.lock" }}
    - run: bundle install --path vendor/bundle
    - save_cache:
    paths:
    - vendor/bundle
    key: gems-{{ checksum "Gemfile.lock" }}
    # make app
    - run:
    name: Run danger
    command: bundle exec danger

    View full-size slide

  29. Danger
    GitHub Personal access tokens
    https://github.com/settings/tokens
    Private repository [repo]
    bot
    CircleCI Environment Variables
    DANGER_GITHUB_API_TOKEN

    View full-size slide

  30. CI
    Danger
    library permission
    CD 策
    internal app sharing

    View full-size slide

  31. : images licenses accepted
    策 1
    circleci/android:api- X-alpha image
    SDK docker
    gradle
    > Android Platform SDK license not accepted
    https://discuss.circleci.com/t/android-platform- -sdk-
    license-not-accepted/

    View full-size slide

  32. : images licenses accepted
    .circle/con g.yml
    run: yes | sdkmanager --licenses || exit
    run: yes | sdkmanager --update || exit
    https://discuss.circleci.com/t/android-platform- -sdk-
    license-not-accepted/ /

    View full-size slide

  33. : images licenses accepted
    release
    circleci/android:api- X
    alpha images

    View full-size slide

  34. https://speakerdeck.com/jmatsu/cd-based-on-
    droidkaigi- -app-e ae-fe - -b -e e fbaf d
    https://qiita.com/noboru_i/items/f b b d
    https://qiita.com/noboru_i/items/ ad c d b c eb b
    https://qiita.com/hkusu/items/e bd efa f
    http://tech.connehito.com/entry/danger
    https://techblog.lclco.com/entry/ / / /

    View full-size slide