How to run Travis CI parallel jobs with build matrix feature fast
Travis CI allows you to run multiple concurrent jobs as part of the same CI build. They even allow for up to 200 parallel jobs for open source projects (the same for private repositories). You can leverage that using Travis build matrix feature to run your project way faster by splitting tests into many smaller jobs that will run a subset of your test suite.
How build matrix feature works?
Build matrix feature allows to automatically create a matrix of all possible combinations of language and environment dependent set of configuration options. For instance, when you want to test your project on 2 different programming language versions and with 2 different browsers then Travis would generate 4 parallel jobs running your tests for each programming language and browser.
Split tests across parallel jobs
We could use build matrix feature to split tests by adding to your project Knapsack Pro that will split your Ruby or Javascript tests automatically across parallel jobs in a way that all concurrent jobs would run subset of test suite and finish work in similar time so you would get the result of your test suite passing or not as fast as possible without waiting for the slowest job.
How to run Ruby tests on parallel jobs with knapsack_pro ruby gem:
How to run Cypress tests in JavaScript on concurrent jobs with @knapsack-pro/cypress:
By doing test suite split in a dynamic way across Travis parallel jobs we save more time and keep our CI build fast. I also call parallel jobs as CI nodes because they are part of a single CI build. Here on the video, I describe a few more problems that can be solved with dynamic test suite split.
Travis CI build matrix in action
The OSS Consul - Open Government and E-Participation Web Software is a great example of how Knapsack Pro helps split tests across parallel jobs.
I've got cup gift for GitHub contribution to #Consul - Open Government and E-Participation Web Software https://t.co/NNIAgO3uXX that empowers https://t.co/eGO3aj0slM The Consul team uses @KnapsackPro to run #ruby tests faster :) Thanks @bertocq @voodoorai2000 pic.twitter.com/8sowbeXlAJ
— Artur Trzop (@ArturTrzop) June 28, 2018
Summary
If you would like to learn more about testing with Knapsack Pro you can check other articles on our blog like testing with Cypress test runner.
In case you are contemplating using Travis CI, then this comparison of Travis CI with other solutions can be helpful to you. The comparison of Travis to Github Actions garners the most interest. Other popular pages include Travis vs AppVeyor and Travis vs Bitbucket Pipelines.