The series of this tutorial has definitely evolved right from getting started with flask pythonframework to Building RESTful APIs using flask , writing tests to our app and now we are integrating Continuous integration.
- Advantages of CI
- Integrating Travis CI in myblog app
Continuous Integration (CI) is a development practice that requires developers to integrate code into a shared repository several times a day. Each check-in is then verified by an automated build, allowing teams to detect problems early. By integrating regularly, you can detect errors quickly, and locate them more easily.
Generally it’s the cheapest way of determining whether the code added to the repository is compatible with it or not. Not adding CI is on the other hand very expensive since it makes it very hard to find and fix problems.
Advantages of continuous intergration
- Help build solid foundation for the development team.
- You don’t have to stop and wait if your code is going to work.
- Improved visibility, problem identification and solving.
- Limited debugging time.
- Minimize integration issues and and deliver more rapidly
- Enhancing the reputation of the company by providing Quality Assurance
Integrating Travis CI in myblog app
The following is a step by step approach to integrating Travis CI into our app
Step #1: Go to Travis and click sign in/up with gitHub. Follow the instruction and Authenticate and allow travis permissions to your github account
Step #2: Activate Travis CI to access your specific repository by togling in the switch button area.
Open your project specific dashboard or enter the following url:
Step #3: Create a file in your project root directory called
.travis.yml This file will instruct travis how to set up your app and run its tests. In that file add the following lines of code.
language: python python: - "3.6" install: - pip install -r requirements.txt - pip install coveralls script: - nosetests -v test_myblog.py after_success: - coveralls
- First we are telling Travis the language we are using
- Then the version of the language we are using
- What to
installbefore running the tests
- Then the exact scrips that run our tests
- And what to do after successful run of the tests. In most cases, we would usually want to get the test coverage to we also integrate coveralls
Step #4: Git add and push your code to github.
If done successfully, Travis through the github webook will pick up the activity on the repository and start to build it automatically, You will then be prompted with this.
When successful, the yellow coloring will turn green else red upon failure
Step #5: Badge your Repository.
In this step, all you need to do is to extract a markdown badge from Travis, put it into your
readme.md file inside your repo and thats it. To do this click on the build image located right next to your tittle, select markdown, copy the text and past it into your
Create the Readme.md file and push to github. This will help keep track of whats happening anytime you add some code. You will not be required to keep on checking Travis to see if your builds are passing or not.
Thats it and you are all done!!
Please leave a comment, subscribe and follow us on all our social media handles and like our youtube channel