banner



How To Use Travis Ci


Continuous Integration is considered one of the all-time practices in development where code integrations are washed frequently into the code repository rather than waiting to commit a larger version. As a part of continuous integration, the developer should ensure that integrations should not break the already available code, every bit beingness a shared repository would have a meaning impact. To solve this trouble and show how continuous integration and testing works, we'll utilize one of the most popular continuous integration services: Travis CI pipeline.

Travis CI pipeline would assistance the user written report automatic build changes and test the integrations and deployment management. Information technology besides helps your code repository with improved and shippable software quality with reduced risks and better collaboration.

In today's blog, I will walk y'all through the Travis CI overview and the advantages of using Travis CI. Yous will besides come across how to configure Travis CI pipeline with your electric current test automation repository over an online Selenium Grid.

Introduction to Travis CI

Travis CI is a cloud-based CI service that builds and tests your projects hosted on GitHub. Information technology would trigger a build process to validate the build and study any failures for every commit fabricated. It fetches the commands from a .travis.yml file, a YAML-based file format, from your projection's root folder to get started with the build process. Travis YML file would enable the Travis CI to understand which programming languages are being used, branch specifications required for the build to be triggered, installation of dependencies if there are whatsoever required.

Every other code repository has its Continuous Integration tools nowadays. Let'south take Bitbucket existence an Atlassian lawmaking repo, Bamboo is a tool that comes along. If yous prefer GitLab equally your code repo, GitLab CI exists. Tool selection could as well be majorly impacted due to the lawmaking repository being used for version controlling. Currently, we have a myriad of tools available which are both free and open source. To cull the tools that best suits your requirement, you lot can become through some of the top CI/CD tools available today. Besides, you can brand a comparing of the elevation CI/CD tools to make your option.

Dependencies rely on the evolution environment being used and the code repositories used for version control purposes.

In the case of Travis CI, below are some of the prerequisites to get started.

  • A mandatory GitHub account
  • Permission for integrating GitHub code repo with the Travis CI.

Why Travis CI?

  1. It seamlessly integrates with GitHub and is easy to set up. Users demand to Sign Up with GitHub and qualify to sync their GitHub projects which we would accept a detailed walkthrough in the upcoming configuration section of the article.
  2. Extensive Travis CI documentation is available to get started, where you can head over for reference. Information technology has sections related to installing dependencies, configuration options in different programming languages, and encryption and integration topics discussed in detail.
  3. Support almost every other programming language and cloud solution for deployments.
  4. Travis CI would seamlessly integrate with cross browser testing solutions such as LambdaTest for parallel testing.
  5. Travis CI is not platform-dependent as it supports multiple platforms apart from Windows, such as Mac and Linux. Infrastructure dependencies might vary depending upon the environment being used. Withal, y'all can navigate through the detailed documentation available.
  6. Travis CI is gratuitous for open up-sourced projects, i.e., projects that are public over GitHub. For private repositories, in that location is an enterprise version available.
  7. Automatic build triggers when there is a alter in the code repository with the user's desired configuration. The user can select the branch name specified in the Travis yml file in the root folder of your project.

Travis CI Challenges

  1. With integrations limited to GitHub, GitLab, Bitbucket, and Assembla cloud repository, using Travis CI outside of GitHub isn't every bit user friendly as with GitHub.
  2. Private repo comes in an Enterprise Version where you accept to pay afterwards trial version, which involves the first 100 builds for gratuitous.

Edifice your kickoff CI/CD pipeline with Travis CI

Any public repository can be used to create a complimentary pipeline. Permit'due south become started with the Configuration of Travis CI pipeline.

Step i: Log in to your GitHub business relationship with a valid username and password. Select the repo you are planning to integrate with Travis CI pipeline. Make sure your repo is up to engagement.

Step ii: Log on to Travis CI and sign up with your GitHub account used in a higher place.

Travis CI

Step 3: Provide authorization as requested, reference provided in the below epitome.

Step 4: In one case you have completed the sign-up and authorization process, yous would be redirected to the dashboard, where yous would be prompted for a sync account option towards the left-hand corner of your screen. This would ideally sync all your existing GitHub projects with your Travis CI pipeline.

Step five: Under Legacy Service Integrations, you can view all your electric current repositories synced on your Travis CI pipeline.

By default, the CI procedure for all repositories would be turned off. Toggle the button to turn on the integration for a specific project.

Footstep vi: At present, you need to add a .travis.yml file to your current automated test suite's root folder.

What is a .travis.yml file?

Travis YML is a configuration file placed in your projection's root folder to define how to configure the build-related information.

If a .travis.yml is non in your repository or is not valid YAML, Travis CI pipeline will ignore it. You lot tin besides find all language-related templates from the Travis CI linguistic communication template. The file consists of data such as what programming language is being used, what operating system is being used, branch proper name of the repo, which is being targeted.

Once the .travis.yml file is created and pushed to the GitHub repo, upcoming commits to the repo would trigger a build in Travis CI deject, similar to that of the below paradigm. Subsequently successful integration with the assist of a configuration file, Travis CI pipeline has a certain machinery that compiles the GitHub code whilst it would pull in the code for the first time and so on each commit to the repo or the specific branch trigger a compilation process. Provided below are the screens of Travis CI pipeline.

Active Repositories View:

Active Repositories View

JobView afterward build completion:

JobView after build completion

Job Log Sample:

Job Log Sample

View Config with the configuration data:

 Config with the configuration

Step 7: Fork the GitHub repo and sync with Travis CI pipeline through the above process.

If y'all don't want to fork the in a higher place-mentioned repo, brand sure you select a repository, which is non empty in your GitHub account enabled with build tool configuration such as Maven or Ant. This would exist helpful in the compilation process.

Step 8: Enable the synced repository. In one case you enable it, this synced repo should exist visible on my repositories page.

Stride nine: Add .travis.yml file to the repo with the beneath build configuration for compilation.

Ensure that you lot enable your framework and so that tests get triggered through the maven command – "mvn test" every bit specified in the configuration file.

Pace 10: Once the above configuration file is committed and pushed to the master branch in GitHub. You lot would observe a examination getting triggered with build and worker information in the chore log view. This process would essentially trigger your offset compilation by pulling in code from the GitHub account onto the VM created by Travis CI pipeline.

As we have configured our tests to run on the LambdaTest Platform through RemoteWebDriver class, in one case a new commit is made, it triggers execution of the specified examination suite onto the LambdaTest Platform. This will ideally identify if whatsoever user-made commit is breaking the build or the automated test suite.

Integrating Travis CI pipeline for automatic testing with LambdaTest

LambdaTest is a cloud-based cross browser testing solution, which would enable us to perform automatic and live interactive cross browser testing on more than 3000 browsers and operating systems online. This would assist you scale upwards and down without much of a hassle in terms of resource allocation and deallocation. It would also help you support budget estimations on resources used for parallel and cross browser testing.

Testing Local or Privately Hosted Projects

Global enterprises utilise private servers for their Information technology purposes for enabling better web protection and security. LambdaTest would seamlessly integrate with such platforms with the help of a secure beat tunneling feature chosen LambdaTest Tunnel. This would also enable you to exam locally hosted web pages. Let'south discuss how to configure LambdaTest Tunnel.

Step 1: Navigate to Automation Dashboard as shown in the below image after logging in to your LambdaTest platform.

Testing Local

Step 2: Once you click on configure tunnel feature, you would be prompted with an overlay with ii sections being internal server configurations and locally hosted spider web page testing features.

Step 3: Re-create the access token related to the desired feature of an application under exam. Please refer to the below token for reference.

We would exist making use of this token while configuring our desired capabilities in our side by side section of the commodity below to demonstrate Parallel Testing with LambdaTest.

Parallel Testing With LambdaTest Selenium Grid

We will see how to perform parallel testing with an online Selenium Grid using an automated testing pipeline, like Travis CI pipeline. We would exist making utilize of our Cucumber TestNG lawmaking repository for reference. You need to clone the code so import the lawmaking into the desired IDE.

We would be declaring our LambdaTest username and password as global environment variables in the yml file in the below format to exist considered for execution.

Where the global variable for LambdaTest username would be LT_USERNAME, and LambdaTest password would be LT_ACCESS_KEY. The same can be retrieved from the Profile Department.

Your .travis.yml code would exist something like to as below.

You tin can brand use of this variable while trying to trigger a remote web commuter execution, equally shown in the beneath code in the case of our Cucumber+TestNG code.

Once you supplant the TestNG Runner file with the in a higher place code for the integration of LambdaTest based parallel execution with the help of Travis CI automated testing pipeline, this would aid you lot get the examination execution trigger in the LambdaTest platform as shown in the image below.

Travis CI automated testing

Conclusion

Nosotros accept discussed the importance of continuous integration and how it tin be leveraged using Travis CI pipeline and its advantages and disadvantages. Nosotros have seen the demand for parallel and cross browser testing using deject solutions such as LambdaTest with an automated testing pipeline. Also, Travis CI's configuration with one of our frameworks using Cucumber and TestNG for triggering tests on LambdaTest to attain our cantankerous browser testing goals.

To boot start a deployment, you would need a quality check in place to validate the build. You cannot depend on a manual exam process to test each and every build integration into the surround. Information technology is not automated and requires human dependency, which proves to be tiresome and has a high chance of failure. To avoid manual quality checks for providing a sign-off to the build, we ensure that we have an automated test suite that acts as a checkpoint in the Continuous Integrations through Continuous Deployment processes with Travis CI pipeline's help.

Cheers for reading the article. Accept a smashing solar day and Happy Testing!

Frequently Asked Questions

What does Travis Yml exercise?

.travis.yml is a configuration file, which provides instructions to the testing and edifice software on how to run tests and build whatever files required by the project. This file is part of the repository's git repository.

How To Use Travis Ci,

Source: https://www.lambdatest.com/blog/build-your-first-ci-cd-pipeline-with-travis-ci/

Posted by: jacksonsheyesseet.blogspot.com

0 Response to "How To Use Travis Ci"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel