1. Introduction
Use CircleCi Service, please create account and register on CircleCi:
Use CircleCi Service, please create account and register on CircleCi:
When your Android/Gradle project its ready, need register application on CircleCi.
In this tutorial we use Github Repository, CircleCi need a yml file to connect with gradle whole put on .circleci/:
./circleci/config.yml
Version: 2
jobs:
build:
working_directory: ~/code
docker:
- image: circleci/android:api-25-alpha
environment:
JVM_OPTS: -Xmx3200m
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
command: sudo chmod +x ./gradlew
- run:
name: Download Dependencies
command: ./gradlew androidDependencies
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
name: Run Tests
command: ./gradlew lint test
- store_artifacts:
path: app/build/reports
destination: reports
- store_test_results:
path: app/build/test-results
In the configuration of the Github, must be insured that the permissions of writing are enabled for committing immediate in the original branch
For dynamic, create a test unit that throw error assert on Java Class into test directory:
Write a error comment into commit, just only for visualize on Repository and CircleCi
Create and Push a new branch with this commit
When pushed on remote repository, we can view on CircleCi dashboard, on this display show every testing, the status change on real time running
When finished, display one of two status failed or success. In this case show an issue
Suppose we found the problem, test unit cases had been corroborated, make commit and push it, into CircleCi dashboard
show automatically
Great CircleCi run all test cases and not find any issue, but found a previous test case failed already corrected it.
Summarizing the dashboard of circleCi, shows the following:
Once test the potential of the tool we are going to see the really useful thing that we can do with Circleci
, let's suppose that in our team development, then we want to assure the main branch of our repository always have a stable version, where everything developed has been proved correctly.
On Github go to configure and edit branch permissions, stay blank space in Write access
input, and uncheck or revoke all permissions for revoking directly new changes, and enable pull request task for everybody.
Create a new testing case call serviceModule
, in my case use mockito library
Make the respective commit
But tried to send our changes to the remote origin
, the repository will reject, because don't have permissions
Now, What we do?
Simple, create a new branch from our worked branch
If use Android Studio, on Push Commits
window, write the name for new branch called BranchServiceTest
When pushed the branch, normally work because we only disabled the changes on master branch or directly push
On the CircleCi dashboard, a new record with NOT RUN label and the last commit, CircleCi detected new changes on repository but doesn't had permissions.
On Github we look the three change had a new test_branch
branch, built from AndroidStudio
Suppose a person in charge of the changes, witch create the new branch need merge on remote origin, the person create a pull request
On details put a message for the respective merge request and indicate close branch when conflicts are been solved.
On our project Pull Request display a new request:
On CircleCi dashboard, added a new record, when run all test and passed. The record status will change, state: SUCCESS
On the screen display we visualize a counter of executed tests, in our case not detected that the issues of other test cases have been modified, only it will execute our test serviceModule
of the class ModuleTest
When the administrador had confirm the new implementation to merge. Assuring a rate of reliability of the code at all time
Since we can estimate the tool Circleci, it allows us a great usefulness, for the management and control of the versioning of the cases of tests (proofs) automated, allowing to diversify the tasks between the collaborators of the project where they need test
On CircleCi dashboard show the result:
We can see the record to detail of the testing, step by step display all the commands that we had written on yml file:
On CircleCi yml file, check Chmod permissions
. Because it is very usual that the beginners in this tool have problems due to depending on the this machine(CircleCi Server) would need permissions
./circleci/config.yml
...
jobs: ...
build: ...
steps: ...
- run: ...
command: sudo chmod +x ./gradlew
...
CircleCi tools supported the gradle flavors, in this project use SonarQube
flavor, for connect it to a base of facts of testing need it on the part of the organization:
Copyright 2018 Romell D.Z.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and limitations under the License.