Continuous integration/continuous delivery (CI/CD) tools give developers the ability to automate the software development process. As soon as developers push code to git, your CI/CD system can build, test, stage, integration test, deploy, and scale. That’s fantastic!
In this tutorial, we will look at CircleCI orbs and how they can support your CI/CD practice. We’ll look at how to use multiple orbs and how orbs can help with multi-builds for a variety of application types.
Before you start, make sure you have the following requirements in place:
A clone of the demo application is available on GitHub. Set-up and installation instructions are available on each project directory.
What are orbs?
Orbs are reusable YAML configuration packages that reduce the configuration to a few lines of code, allowing developers to package, ship, and reuse configurations easily.
Orbs are useful because they:
- Save time spent on project setup
- Boost organizational efficiency
- Simplify third-party integrations
Orbs can be the heroes of your config file.
To use an orb, go to the CircleCI orb registry. There you will find the right orb for your tech stack along with instructions to get started. If you cannot find an orb for your technology stack, you can create a specialized orb by following the CircleCI Best Practices and Getting Started guides.
Using multiple orbs
CircleCI supports using multiple orbs in the same configuration file - this section will show you how, using the project you cloned earlier.
Why multiple orbs?
When configuring a CI/CD pipeline for this type of application, you should have all of your configurations in a single config file. That is because CircleCI requires a single config file in
Because orbs are flexible, we can combine orbs in a single
config.yml file to run our tests on CircleCI. Multiple orbs will result in faster project execution, a more robust CI/CD pipeline, and excellent reusability.
Setting up multiple orbs
The process of configuring multiple orbs is similar to that of configuring a single orb.
To begin, follow these steps:
- At the top of your
.circleci/config.ymlfile, add the line below to specify the CircleCI version
- Invoke the orbs you wish to use. For example:
orbs: node: firstname.lastname@example.org python: email@example.com
This code block lists the orbs right after the CircleCI version. We will then use the two throughout the script. Because the orbs are referenced using different names, they are entirely independent of one another.
- Introduce node elements into your existing workflows and jobs. At this point, the orb’s elements are available for use as
Now that you have covered the fundamentals of configuring multiple orbs, you can start configuring your cloned app with the Python and Node orbs. These orbs are unique, and proper configuration can be found in the orbs documentation guide.
Here is a breakdown of the config file into several chunks containing the
These are the specific orb versions to use in your pipelines:
You can consider having two separate jobs for each application because you are testing two. Each orb will have its own execution job.
Role: Testing the Python application
Orb used: Python orb
Orb used: Node orb
override-ci-command: npm install
npm run test
Workflows determine the order of execution of defined jobs.
Comparing configs with and without multiple orbs
A complete, packed version of the
config.yml is available for reference in the sample GitHub repository. The typical configuration does not use CircleCI orbs.
Aside from the organization and readability orbs offer, reviewing the workflow run time reveals more benefits orbs provide. A successful run for two workflows is shown in the following screenshot: one with the standard configuration and the other with orbs.
This graphic shows that the workflow that runs with the config that uses multiple orbs executes slightly faster than the one that runs with the standard config. There are minor differences in the time it takes each job in both workflows to complete.
Orbs triumph once more!
This tutorial showed the benefits of using multiple orbs in your CI pipelines. You were able to configure a CI pipeline to use multiple orbs based on the architecture of different applications. You have experienced how multiple orbs can speed up workflow runs, increase reusability, and ease integration with third-party applications. Until next time, keep building!
Waweru Mwaura is a software engineer and a life-long learner who specializes in quality engineering. He is an author at Packt and enjoys reading about engineering, finance, and technology. You can read more about him on his web profile.