Everyone Struggles: Unveiling Continuous Integration (CI)

Photo by JJ Ying on Unsplash

Everyone Struggles: Unveiling Continuous Integration (CI)

Introduction

This week's theme, "Everyone Struggles," resonates deeply with my Outreachy internship experience. Diving into the world of open source, I've encountered numerous new concepts, and one that initially stumped me was Continuous Integration (CI).

Encountering CI in ODK-X

Early in my internship, "CI" became a frequent player in the ODK-X community chat and mentor discussions, particularly when it came to code quality and automated testing. Since my project involves building Android tests for ODK-X's Android tools, understanding CI became essential.

At first, the concept flew right over my head. Though I have heard of CI/CD before, the context of Android development left me confused. Thankfully, CI in Android development follows the same core principles as in general software development.

Overcoming My Hesitation

Initially, I hesitated to ask about CI in Circle CI. It felt like a fundamental concept everyone else grasped. The fear of revealing my lack of knowledge held me back. But then, I remembered the core purpose of this internship: to learn and grow. So, I took the plunge and started researching.

Demystifying CI

CI is a software development practice where developers frequently push their code changes to a central repository. These changes are then automatically checked against pre-configured criteria. Any changes that fail to meet these criteria won't be merged into the main codebase.

Imagine a central repository with a set Application Programming Interface (API) level (e.g., 31) and Java version (e.g., Java 8). If multiple developers push updates with different API levels (like 28 or 29) or incompatible Java versions, those changes will fail integration. Essentially, both API level and Java version (along with other dependencies) need to match for successful integration.

A basic CI system helps prevent new changes that might break the build after merging. Here's a typical CI flow:

  • Code Change Detection: The CI system detects a code change, usually triggered by a pull request creation.

  • Server Provisioning: A server is provisioned and initialized to run the workflow.

  • Code and Tool Fetching: The code is fetched, along with any necessary tools like the Android SDK and other dependencies.

  • Project Building: The project is built using a specified command (e.g., ./gradlew build).

  • Local Tests Execution: Local tests are run using another command (e.g., ./gradlew test).

  • Emulator Startup and Instrumented Test Execution: Emulators are launched, and instrumented tests are run.

  • Artifact Uploading: Test results and APKs are uploaded for further analysis.

The Benefits of CI

CI is not just a fancy term; it offers a multitude of advantages for software development:

  • Software Quality: By identifying and fixing problems early on, CI ensures a higher standard of software quality. This translates to fewer bugs and a smoother user experience.

  • Fewer Build Breakdowns: Automating the build process with CI helps prevent broken builds. By catching issues early, CI reduces the risk of wasted time and frustration.

  • Confidence in Releases: CI provides a safety net for software releases. By running automated tests before deployment, CI ensures releases are stable and production-ready.

  • Streamlined Collaboration: CI acts as a central hub for developers to share code and test results. This fosters collaboration and makes it easier to track project progress.

  • Boosted Productivity: CI automates tedious and error-prone tasks, freeing up developers' time to focus on more creative endeavors.

Learning Through Exploration

My journey to understanding CI involved a combination of research and community interaction. I discovered that ODK-X leverages CI tools like Circle CI to automate testing and deployment processes. Diving into the Circle CI documentation and reviewing existing configurations further solidified my grasp of the concept. By understanding these configurations, I witnessed how automated tests are run with every code push, ensuring that new changes don't disrupt existing functionality.

Conclusion

To anyone embarking on their open-source journey, remember: it's okay not to know everything. Everyone starts somewhere, and the open-source community is there to support you. Don't hesitate to ask questions, no matter how basic they seem. Your curiosity and eagerness to learn are what truly matter.
Understanding CI marks a significant milestone in my Outreachy journey with ODK-X. As I continue to learn and grow, I hope to empower others to do the same. Thanks for joining me, and see you next time!

Resources

https://developer.android.com/training/testing/continuous-integration

https://circleci.com/docs/