Continuous Integration for your open Source project.

You must have heard of travis or jenkins if not you can read about them if you click on their name. Now you want continuous integration or lets leave this word. Lets say you want to run some command whenever you are committing something on github. Say you want to run test case, code quality test or say some security test. All this should be done whenever there is a commit on your project in git. We will be seeing how we can do this using Travis. Lets see continuous Integration for your open Source project.

1. Go to https://travis-ci.org/

 

2. Click on Sign in with Github. On Github you must be having your project.

 

Continuous Integration for your open Source project.
Login Screen

3. When you click it ask for permission allow it.

 

4. Next Go to https://travis-ci.org/profile/chowmean at place of chowmean it will be your username.

 

You will see something like this

Repository List
Continuous Integration for your open Source project.

5. Now click on repository you want to use travis for like below.

 

Continuous Integration for your open Source project.
Activate repo and settings

6. Now click on setting icon to go to settings page.

 

Continuous Integration for your open Source project.
Repo settings

From here you can change the settings of repo like when to run the scripts and all.

7. Now you need a travis file which will tell travis what to do on each commit. Like the one below

 

language: python
python:
  - "2.7"

# command to install dependencies
install:
  - "pip install safety"
  - "pip install fab-polish"
  - "pip install coverage"
# command to run tests
script:
  "fab polish"

8. Here we are telling travis what to do. Like Use python 2.7, Install safety, fab-polish and coverage and then run fab polish command. You have to place this file in root directory of repo with name

.travis.yml

Similarly you can write your own tests to be run here. Just make sure that when it tests pass they give the return_code as 0. Which indicates the tests are passed else any other value is returned.

9. Now whenever you commit you will see something like this in your git repo it if passes and fails

 

Continuous Integration for your open Source project.
Failed and passed commits

 

10. Also if you click on tick or cross you can see what actually is processed like below. Link for the below is here.

 

Continuous Integration for your open Source project.
Travis run logs

So this is how you integrate your tests and made them run when ever any commit is done. If you like the article share it and subscribe.

This is the end of article

Continuous Integration for your open Source project.


Gaurav Yadav

Gaurav is cloud infrastructure engineer and a full stack web developer and blogger. Sportsperson by heart and loves football. Scale is something he loves to work for and always keen to learn new tech. Experienced with CI/CD, distributed cloud infrastructure, build systems and lot of SRE Stuff.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.