Weekly Webtips
Published in

Weekly Webtips

Adding Continuous Integration (CI) to your project using Travis CI

Travis CI with Github

When you and your team working on a project making mistakes is something obvious. Adding CI will solve this problem because it will test and build your project before deploying. In this article, I’m going to talk about one of the best CI services I got to know when working with Sustainable Educational Foundation-SEF. In SEF we use Travis for our projects. Make sure to visit our page to have a look at our projects. Let me start from the start.

What Is Continuous Integration (CI)?

Continuous Integration is the practice of merging in small code changes frequently — rather than merging in a large change at the end of a development cycle. The goal is to build healthier software by developing and testing in smaller increments. This is where Travis CI comes in.

As a continuous integration platform, Travis CI supports your development process by automatically building and testing code changes, providing immediate feedback on the success of the change. Travis CI can also automate other parts of your development process by managing deployments and notifications.

For more core concepts follow this documentation.

Why Travis CI?

Travis CI enables your team to test and ship your apps with confidence. It’s built for everyone and for projects and teams of all sizes, supporting over 20 different languages out of the box, including Javascript and Node.js, Ruby, PHP, Python, Mac/iOS, as well as Docker, while giving you full control over the build environment to customize it to your own needs.

Travis CI is trusted by hundreds of thousands of open source projects, teams, and developers.

Works for all your projects

Whether it’s Node.js, Ruby, iOS, or Java, Travis CI supports all your projects and languages. No more “works on my machine” thanks to isolated and customizable build environments.

Supports your workflow

Your team uses GitHub Flow, feature branches, or commits directly to master? Travis CI supports your way of shipping, integrating tightly with GitHub to give you the best possible shipping experience.

Live and breathe Continuous Delivery

Build Stages give you full control to structure your build for continuous delivery.

Test and deploy anywhere

Updating staging or production as soon as your tests pass has never been easier! Heroku, GitHub Releases, AWS CodeDeploy, and more are at your fingertips.

Scales with your team

Whether 10 or 1000 developers are using it, Travis CI scales with your team. Enabling a new project and team is as simple as flicking a switch.

Prerequisites

To start using Travis CI, make sure you have:

For this demonstration, I’m going to use GitHub.

To get started with Travis CI using GitHub

  1. Go to Travis-ci.com and Sign up with GitHub.
  2. Accept the Authorization of Travis CI. You’ll be redirected to GitHub.
  3. Click on your profile picture in the top right of your Travis Dashboard, click Settings, and then the green Activate button, and select the repositories you want to use with Travis CI.

In your project,

  1. Add a .travis.yml file to your repository to tell Travis CI what to do.
  • The following example specifies a React Js project that should be built with node_js.
language: node_js
node_js:
- "stable"
cache:
directories:
- node_modules
script:
- npm run build
- npm run lint
  • According to this example, Once the PR is made it will run npm run build and npm run lint .

2. Add the .travis.yml file to git, commit and push to trigger a Travis CI build

3.Check the build status page to see if your build passes or fails according to the return status of the build command by visiting Travis CI and selecting your repository.

As you can see in the above screenshot, It ran the given tests and passes the build if there’s no issue with the build.

This is a quick introduction to Travis-CI. Go through the official documentation before starting and there are many more things that Travis offers us. As always thanks for reading see you guys in the next one. Stay safe! ✌️

References

[1]. Travis CI. Documentation [31 October 2020]. Available from: https://docs.travis-ci.com/

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store