Release on the head and you are scared of thoroughly testing and submitting a code that does not crash anywhere here is a solution for that. Now if you are thinking of writing test cases good choice but here we are gonna use automation test generating tools popularly known as continuation Integration Tools.
Continuous Integration or CI is the process of automating the build and testing of code every time a team member commits changes to version control. CI encourages developers to share their code and unit tests by merging their changes into a shared version control repository after every small task completion. Committing code triggers an automated build system to grab the latest code from the shared repository and to build, test, and validate the full master branch.
Benefits of CI/CD
i. Code versioning & control
ii. Reduce efforts and time
iii. Reduce overheads
iv. Reduce the risk of wrong commit and missing files.
v. Build & Deployment automation
Now there are different CI tools available in the market, Some are listed below:
1.Bitrise
2.Github Action
3.Docker
4.CircleCI
Now there may be more but these are the ones trending currently
And I would like to use Bitrise and bitbucket for our example as it just is a min task. Yes !! it's true just in a min the setup is done and whenever you run your project the code is tested and ready for deployment.
Now let's understand the same via an example.
Bitbucket collaborates with CI/CD tools via webhooks to get instant feedback about any integration as well as triggering a build to deliver right away to stakeholders.
Let’s look at a simple example using Bitrise. To set up a mobile project, follow the steps described here. Now, below I’m going to describe some insights we have to consider.
A CI/CD pipeline executes a set of reusable and configurable steps or jobs. In Bitrise, this is referred to as a workflow. Whichever branch flow your team uses — namely Git flow, promiscuous integration, etc — there should be at least a stable branch and many other secondary branches. So we should have at least one workflow that, when kicked off, compiles the codebase and executes unit tests, adding unit tests step. It’s represented by this icon:
For more specific build system execution you should consider a Gradle step that allows you to execute with custom arguments, for example ./gradlew testDebugUnitTest
. This step is represented by this icon:
Also, we should have early delivery workflows that build apk files of the desired flavors and distributes them so that the QA and product team can install them in different testing devices.
When creating a pull request to the stable branch Bitbucket should trigger the verification workflow that will execute a fast test suite.
On the other hand, when pushing changes to your stable branch (directly or merging a secondary branch), a Bitbucket webhook should trigger a thorough longer test suite, which may include functional tests. You can also use git tags to trigger some specific workflow with Bitbucket webhooks.
This way when one or more workflow steps fail, Bitbucket will notice authors and reviewers about the failing CI pipeline execution, warning them right away to let the team fix it before the issues are integrated into a stable branch.
You can also configure your Bitbucket repository to automatically prevent a merge with unresolved merge checks.
Static code scanning tools
Some tools help to maintain and even improve code’s quality in our repository doing static code analysis, often called linters. We should seriously consider adding a lint task to our CI pipeline, so that whenever someone creates a pull request the linter’s reports may warn that the code to be integrated might have code smells, performance issues, bad practices, etc. Likewise, this tool helps to reduce technical debt as well as to ease code reviewers' work.
There are many static analyzers for mobile projects that can be easily integrated into your Configuration Management workflow: Android lint, SonarQube, Spotless, Klint, Code Inspector, among others. Some of the issues that can be detected before merging a branch are duplicated code, wrong threading management, memory leaks, high cyclomatic complexity, and many others.
Conclusion
Mobile developers should seriously consider integrating a thorough Configuration Management workflow into their projects through practices like code reviews and CI/CD pipelines. In my experience, Bitbucket allows to easily set up all the necessary tools and webhooks to automate as much of this process as possible.
Keep Coding !!