Adding Continuous Integration (CI) to your project using Travis CI
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 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.
To start using Travis CI, make sure you have:
- A GitHub or Bitbucket or GitLab or Assembla account.
- Owner permissions for a project hosted on GitHub or Bitbucket or GitLab or Assembla.
For this demonstration, I’m going to use GitHub.
To get started with Travis CI using GitHub
- Go to Travis-ci.com and Sign up with GitHub.
- Accept the Authorization of Travis CI. You’ll be redirected to GitHub.
- 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,
- Add a
.travis.ymlfile 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.
- npm run build
- npm run lint
- According to this example, Once the PR is made it will run
npm run buildand
npm run lint.
2. Add the
.travis.yml file to git, commit and push to trigger a Travis CI build
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! ✌️
. Travis CI. Documentation [31 October 2020]. Available from: https://docs.travis-ci.com/