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

Continuous Integration: Catch Bugs and Improve Team Communication

Continuous Integration: Catch Bugs and Improve Team Communication

GitHub project for demo: https://github.com/jordanjoz1/andevcon-demo

A good build process makes everyone’s lives easier. Running tests and static code analysis gives developers confidence and peace of mind. Product managers and QA benefit from automatically shared builds that clearly indicate changes. In this session, we will expand on the concept of a CI process and talk about some ways to automate everyday tasks, including pull request feedback, testing, and distribution.

We will discuss several opportunities for automated improvement. First, sharing style formatting to improve readability and reduce merge conflicts. Second, showing results of automated testing and static code analysis in pull requests to improve code quality and reduce bugs. Last, how to automatically distribute builds and update tickets to improve intra-team communication. Whether you choose some of these tools or all of them, they will make your life easier. Our focus will be on a comprehensive solution using Jenkins, SonarQube, Fabric, JIRA and Github, but we will also compare alternative services.

Want to get started with these processes now? You will have details for installation instructions, plugins, and configurations. By the end of this talk, you will understand how to setup and use all these services so that they do the heavy lifting in your development process.

Jordan Jozwiak

December 01, 2016
Tweet

More Decks by Jordan Jozwiak

Other Decks in Programming

Transcript

  1. Continuous Integration:
    Catch Bugs and Improve Team Communication
    Jordan Jozwiak, eero

    View Slide

  2. First, let’s agree on some values

    View Slide

  3. It’s better to
    automate processes
    than do them manually

    View Slide

  4. It’s better to
    have consistent code style
    than mix multiple styles

    View Slide

  5. It’s better to
    catch bugs during development
    than during the QA process

    View Slide

  6. It’s better to
    automate routine communication
    than rely on individuals

    View Slide

  7. Is this really Continuous Integration?
    What can I do?
    When can I do these things?
    How can I do these things?
    Guiding Questions

    View Slide

  8. This isn’t really Continuous Integration

    View Slide

  9. This isn’t really Continuous Integration
    continuous integration (CI)
    is the practice of merging all developer working copies to a shared
    mainline several times a day.

    View Slide

  10. This isn’t really Continuous Integration
    continuous integration (CI)
    is the practice of merging all developer working copies to a shared
    mainline several times a day.
    build automation
    is the process of automating the creation of a software build and the
    associated processes including: compiling computer source code
    into binary code … and running automated tests.

    View Slide

  11. This isn’t really Continuous Integration
    I’m talking about a larger scope and a longer timeframe

    View Slide

  12. Is this really Continuous Integration?
    What checks can I do?
    When can I do these checks?
    How can I do these checks?

    View Slide

  13. Is this really Continuous Integration?
    What checks can I do? (Scope)
    When can I do these checks?
    How can I do these checks?

    View Slide

  14. Is this really Continuous Integration?
    What checks can I do? (Scope)
    When can I do these checks? (Timeframe)
    How can I do these checks?

    View Slide

  15. Checks you can do (Scope)

    View Slide

  16. Checks you can do (Scope)
    • Tests

    View Slide

  17. Checks you can do (Scope)
    • Tests
    • Unit tests

    View Slide

  18. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests

    View Slide

  19. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage

    View Slide

  20. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks

    View Slide

  21. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement

    View Slide

  22. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting

    View Slide

  23. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count

    View Slide

  24. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size

    View Slide

  25. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis

    View Slide

  26. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication

    View Slide

  27. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity

    View Slide

  28. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity
    • Profiling

    View Slide

  29. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity
    • Profiling
    • Memory profiling

    View Slide

  30. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity
    • Profiling
    • Memory profiling
    • Start-up time profiling

    View Slide

  31. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity
    • Profiling
    • Memory profiling
    • Start-up time profiling
    • Frame rate profiling

    View Slide

  32. Checks you can do (Scope)
    • Tests
    • Unit tests
    • Instrumentation tests
    • Test coverage
    • Style checks
    • Code arrangement
    • Code formatting
    • Method count
    • APK size
    • Static code analysis
    • Code duplication
    • Code complexity
    • Profiling
    • Memory profiling
    • Start-up time profiling
    • Frame rate profiling
    • And more…

    View Slide

  33. When can I do these checks?

    View Slide

  34. Normal timeline

    View Slide

  35. Normal timeline

    View Slide

  36. Save Code
    Normal timeline

    View Slide

  37. Save Code
    Normal timeline
    Commit
    Locally

    View Slide

  38. Save Code
    Normal timeline
    Commit
    Locally
    Open
    Pull Request

    View Slide

  39. Save Code
    Normal timeline
    Commit
    Locally
    Open
    Pull Request Merge code

    View Slide

  40. Save Code
    Normal timeline
    Commit
    Locally
    Open
    Pull Request Merge code QA

    View Slide

  41. Save Code
    Normal timeline
    Commit
    Locally
    Open
    Pull Request Merge code QA Release

    View Slide

  42. Work that you do
    Work done automatically
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release

    View Slide

  43. Work that you do
    Work done automatically
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    Local
    Development
    Code
    Review
    After
    Merge

    View Slide

  44. Assessing cost and value of running a check
    Quality Bar
    Time

    View Slide

  45. Normal timeline
    Automatically hook into events
    Editor
    hooks
    git
    hooks
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    GitHub PR
    hooks
    GitHub
    hooks

    View Slide

  46. Normal timeline
    Available time and expected quality
    little time
    low quality
    little time
    med quality
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    med time
    high quality
    more time
    highest quality

    View Slide

  47. Normal timeline
    For example… catch bugs early
    Reformat
    & rearrange
    code
    FindBugs
    PMD
    Lint
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    Tests &
    Static Code
    Analysis
    Automation
    Tests

    View Slide

  48. Normal timeline
    and improve communication!
    Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    Update
    ticket
    statuses
    Generate
    release
    notes

    View Slide

  49. This isn’t really Continuous Integration

    View Slide

  50. Build, Test, Analysis,
    and Communication Process
    spanning entire development cycle

    View Slide

  51. Totally Awesome Development Process™

    View Slide

  52. How can I do these checks?

    View Slide

  53. Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity

    View Slide

  54. Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket

    View Slide

  55. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket

    View Slide

  56. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket

    View Slide

  57. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket
    Instrumentation
    Testing
    • Espresso
    • Spoon

    View Slide

  58. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket
    Instrumentation
    Testing
    • Espresso
    • Spoon
    Crash
    Reporting
    • Crashlytics
    • Firebase

    View Slide

  59. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket
    Instrumentation
    Testing
    • Espresso
    • Spoon
    Crash
    Reporting
    • Crashlytics
    • Firebase
    Distribution
    • Fabric

    View Slide

  60. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket
    Instrumentation
    Testing
    • Espresso
    • Spoon
    Crash
    Reporting
    • Crashlytics
    • Firebase
    Distribution
    • Fabric
    Multi-
    functional
    • BuddyBuild

    View Slide

  61. Static Code
    Analysis
    • CheckStyle
    • Findbugs
    • PMD
    • SonarQube
    Unit Testing
    • JUnit
    • Robolectric
    Build
    • Jenkins
    • Travis
    • Circle CI
    • TeamCity
    VCS
    • GitHub
    • BitBucket
    Instrumentation
    Testing
    • Espresso
    • Spoon
    Crash
    Reporting
    • Crashlytics
    • Firebase
    Distribution
    • Fabric
    Multi-
    functional
    • BuddyBuild
    and
    so
    many
    more

    View Slide

  62. A Totally Awesome Development Process™ is

    View Slide

  63. A Totally Awesome Development Process™ is
    Reliable
    24/7

    View Slide

  64. A Totally Awesome Development Process™ is
    Reliable Comprehensive
    24/7

    View Slide

  65. A Totally Awesome Development Process™ is
    Reliable Comprehensive Informative
    24/7

    View Slide

  66. How we do things at eero
    a mostly free option
    using popular services

    View Slide

  67. Services used at eero

    View Slide

  68. Services used at eero
    GitHub
    Industry standard
    Free public repos

    View Slide

  69. Services used at eero
    GitHub
    Industry standard
    Free public repos
    SonarQube
    Duplication, coverage,
    complexity, history,
    assignment, etc.

    View Slide

  70. Services used at eero
    GitHub
    Industry standard
    Free public repos
    Jenkins
    Free, customizable,
    large community
    SonarQube
    Duplication, coverage,
    complexity, history,
    assignment, etc.

    View Slide

  71. Services used at eero
    GitHub
    Industry standard
    Free public repos
    Jenkins
    Free, customizable,
    large community
    SonarQube
    Duplication, coverage,
    complexity, history,
    assignment, etc.
    Fabric
    Convenient, includes
    release notes

    View Slide

  72. Services used at eero
    GitHub
    Industry standard
    Free public repos
    Jenkins
    Free, customizable,
    large community
    JIRA
    Specialized for bug and task tracking
    Has API for updating ticket status
    SonarQube
    Duplication, coverage,
    complexity, history,
    assignment, etc.
    Fabric
    Convenient, includes
    release notes

    View Slide

  73. Let’s dive into an example!
    inspired by the eero timeline

    View Slide

  74. Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    Local
    Development
    Code
    Review
    After
    Merge

    View Slide

  75. Save Code
    Commit
    Locally
    Open
    Pull Request Merge code QA Release
    Local
    Development
    Code
    Review
    After
    Merge

    View Slide

  76. Save Code
    Commit
    Locally
    Local
    Development
    Services

    View Slide

  77. Save Code
    Commit
    Locally
    Local
    Development
    Services
    Android Studio

    View Slide

  78. Save Code
    Commit
    Locally
    Local
    Development
    Services
    Android Studio
    git

    View Slide

  79. Save Code
    Commit
    Locally
    Local
    Development
    Services
    Android Studio
    git
    SonarQube

    View Slide

  80. Android Studio
    • Helpful Plugins
    • SonarLint
    • FindBugs, PMD, Checkstyle
    • Share settings for formatting and arrangement
    • Shortcut for optimizing imports, formatting, and arranging

    View Slide

  81. git
    • git hooks

    View Slide

  82. SonarQube
    • Static code analysis at its best. An ultimate combination of PMD,
    FindBugs, Checkstyle, Android Lint, and more!
    • Tech debt, complexity analysis, code duplication, test coverage
    • History to track project quality
    • Caveat: the Android Lint plugin is woefully out of date. It’s still on
    22.0 when the latest is >25

    View Slide

  83. SonarQube
    • Helpful plugins
    • GitHub Plugin
    • Android Lint Plugin
    • XML Plugin

    View Slide

  84. View Slide

  85. Save Code
    Commit
    Locally
    Local
    Development
    Demo

    View Slide

  86. Save Code
    Commit
    Locally
    Local
    Development

    View Slide

  87. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review

    View Slide

  88. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review
    Services

    View Slide

  89. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review
    GitHub
    Services

    View Slide

  90. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review
    GitHub
    Jenkins
    Services

    View Slide

  91. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review
    GitHub
    Jenkins
    SonarQube
    Services

    View Slide

  92. GitHub
    • Show the results of external tasks on a commit or pull request

    View Slide

  93. GitHub

    View Slide

  94. Jenkins
    • Helpful plugins
    • GitHub Plugin
    • GitHub Pull Request Builder
    • JUnit Plugin
    • Gradle Plugin
    • JIRA Plugin

    View Slide

  95. Jenkins
    • Useful jobs
    • Pull Request Builder
    • Job that builds all changes to development branch
    • Nightly builder

    View Slide

  96. Jenkins
    • APK size
    • Method count

    View Slide

  97. View Slide

  98. SonarQube
    • Run an incremental analysis on just the changes
    • Publish results to GitHub

    View Slide

  99. Save Code
    Commit
    Locally
    Open
    Pull Request
    Local
    Development
    Code
    Review
    Demo

    View Slide

  100. The case for an all-in-one solution

    View Slide

  101. • No setup to build pull requests
    • No setup to run tests
    • Includes crash reporting
    • Integrate SDK so users can send screenshots of issues
    • Easily distribute builds to team
    • Publish directly to the app store

    View Slide

  102. View Slide

  103. Save Code
    Commit
    Locally
    Local
    Development
    Open
    Pull Request
    Code
    Review

    View Slide

  104. Save Code
    Commit
    Locally
    Local
    Development
    Open
    Pull Request
    Code
    Review
    Merge code QA Release
    After
    Merge

    View Slide

  105. Merge code QA Release
    After
    Merge

    View Slide

  106. Merge code QA Release
    After
    Merge
    Services

    View Slide

  107. Merge code QA Release
    After
    Merge
    Services

    View Slide

  108. Merge code QA Release
    After
    Merge
    Fabric
    Services

    View Slide

  109. • Integrate with Jenkins to automatically update tickets statuses

    View Slide

  110. View Slide

  111. Fabric
    • Distribute build to team
    • Include release notes based on the changes since the last Jenkins
    build

    View Slide

  112. Fabric

    View Slide

  113. Fabric

    View Slide

  114. Merge code QA Release
    After
    Merge
    Demo

    View Slide

  115. The reality

    View Slide

  116. The reality
    all this requires work and maintenance

    View Slide

  117. The reality
    all this requires work and maintenance
    and that can be frustrating

    View Slide

  118. The reality

    View Slide

  119. The struggle

    View Slide

  120. The struggle
    • Build server breaks

    View Slide

  121. The struggle
    • Build server breaks
    • Wait time for tests and checks to complete

    View Slide

  122. The struggle
    • Build server breaks
    • Wait time for tests and checks to complete
    • Pre-commit checks are annoying

    View Slide

  123. The struggle
    • Build server breaks
    • Wait time for tests and checks to complete
    • Pre-commit checks are annoying
    • False-positives in checks

    View Slide

  124. The struggle
    • Build server breaks
    • Wait time for tests and checks to complete
    • Pre-commit checks are annoying
    • False-positives in checks
    • Rules don’t always apply (e.g. parentheses for improved readability)

    View Slide

  125. it’s easy to get started
    but configuring everything to your needs is harder

    View Slide

  126. enforcing rules improves quality
    but it requires maturity and discipline

    View Slide

  127. the journey is hard
    but it’s worth it when you get there

    View Slide

  128. I asked some other companies what they do

    View Slide

  129. Do what’s best for your team

    View Slide

  130. Do what’s best for your team
    by catching bugs early and improving communication

    View Slide

  131. Questions?
    [email protected]

    View Slide