This repository aims at getting started with Travis CI for your Github repositories. For demonstration purposes a very simple package is created with some test cases to explain how to integrate Travis CI for continous integration with Github.
Travis CI is a hosted, distributed continuous integration service used to build and test software projects hosted at GitHub. Open source projects may be tested at no charge via https://travis-ci.org. Private projects may be tested at https://travis-ci.com on a fee basis. TravisPro provides custom deployments of a proprietary version on the customer's own hardware. (Source - Wikipedia)
-
The folder pkg contains a arithmetic package which has been created for demonstration puposes. The folder pkg has 2 sub-folders arithmetic and testing with files arithmetic.py and testing.py.
-
The arithmetic.py file is a simple module to do arithmetic operations like addition, subtraction, multiplication and division. The testing.py file is another simple module which runs some testcases on the package.
-
To successfully integrate Travis CI with your Github repository you will need:
Step 1: Github repository for which you want to integrate Travis CI with
Step 2: Sign In with your Github account on https://travis-ci.org
Step 3: Activate the github repository from the Travis CI console for which you want to do the integration
Step 4: Trigger the build by doing a
push
to the repositoryStep 5: Finally check status on Travis CI console to verify if your build passed or failed
- Create a github repository like this one or identify the github repository you would like to integrate with Travis CI.
⚠️ Note that the this repository should be public and not private.
- Fairly straight forward, go to https://travis-ci.org and login with your Github credentials as shown below:
- After you login, navigate to the left of your console as shown below and click on the + sign as shown below:
-
After clicking the + sign you will be able to see all your public repositories
-
Activate your repository for integration with Travis CI by turning on the button next to your repository as shown below:
-
This is the most important step of all the steps. You will need a .travis.yml file to trigger the Travis CI build.
-
A .travis.yml or a YAML is a simple human readible data serialization configuration file which tells Travis CI what to do once you trigger the build. For example like the one shown below:
#declaring the type of language language: python #declaring the versions of the language specified above you to want the test the code against python: - "3.5" #before executing the code installing the dependencies if any install: - pip install -r requirements.txt #running the desired code file for testing your code script: - mypy pkg/arithmetic/arithmetic.py
- Travis CI will start start the build by executing the steps as outlined in the .travis.yml, you can also verify this by checking the logs in the console after logging into your Travis CI account as shown below:
- You can also verify if your build passed ✅ or failed ❌ by looking at the build batch on the top of the console as shown below: