Recently, we migrated all CI workflows in Hypertrace repositories to GitHub Actions. This blog post summarises our reasons for migration, some things we learned about GitHub Actions and our experience with it.
What is GitHub Actions?
Everyone who's worked in the software industry for a while knows the importance of CI/CD. CI plays an important role in automating validations, tests, packaging and releases for Open Source projects like Hypertrace. GitHub Actions is one of the easiest ways to create event-drive automated workflows for your software development life cycle tasks.
For example, when someone commits a change to code, and you want to run unit tests, or you want to release artifacts when the changes are pushed to your
main branch, you can trigger a GiHub Action workflow.
Before I go into further detail about GitHub actions, I'd like to summarize why we shifted to GitHub Actions from our previous CI provider.
Why GitHub Actions?
Easy to setup
GitHub actions is way easier to setup than any other alternative because you don't need to sign up or login somewhere to setup or check it's status. It's right there on your repository homepage. You just create a yaml file, save it in the
.github/workflows directory, and you can see your action workflows running as per trigger in actions section in GitHub repo.
|Componenets of GitHub Actions|
Here are some of the components of GitHub actions:
- Event means trigger for workflow
- Workflow consists of the automated procedure which combines a number of jobs
- A job is a set of steps that execute on the same runner. By default, a workflow with multiple jobs will run those jobs in parallel.
- Steps are components of jobs
- Actions are standalone commands that are combined into steps to create a job. Actions are the smallest portable building block of a workflow.
Want to know how to use it?
Let's start with 'Hello World' like every 'Intro to ...' lesson!
on: push jobs: first-job: name: Say hi runs-on: ubuntu-latest steps: - name: Print a greeting run: echo "Hello World!"
This simple worflow will print 'hello world' when run, and it will run on each commit. Isn't this simple?
No installation, No configuration
GitHub Actions comes with pre-configured Linux, macOS and Windows machine with all the general purpose developer tools pre-installed. So, hey! you don't need to waste time in installing software on your barebone machines every time your workflow gets triggered.
You can see the details for all available virtual enviroments here: https://github.com/actions/virtual-environments
One of the major missing feature for us was customizable machine configurations for more intensive or specialized workflows. GitHub provides you option to use self-hosted runners which solves this issue for many people. GitHub managed configurable machine are also in pipeline as per GitHub's public roadmap and you can track that issue here.
As more and more projects are migrating to GitHub actions, their community is growing fast. And one of the benefits of wider community is if you get into an issue, there's someone who has it already solved for you.
You can ask questions or search for existing question on GitHub community forum which is available here.
Yes! When something changes in your software developement workflow, reusable custom Actions can save a lot of time and effort when reproducing those changes across multiple repos in your organisation. You just make the change in the custom action and you are good to go!
GitHub Marketplace has thousands of actions for a variety of needs. You want an action for Docker login, deploying a Cloudformation template on AWS or maybe just to upload some files to GCS buckets, you will those actions and a lot more.
GitHub Marketplace reduces the need to reinvent already solved problems. You can find available actions in the GitHub Actions Marketplace here. We have created some custom actions to satisfy our specific use-cases for Hypertrace which you can find here. I could also tell you about how to create your own custom action. But let's keep that for another day.
No freemium shenanigans
GitHub actions doesn't have credit or usage limits for Open Source projects. So you'll never have to worry about burning all of your CI/CD budget or exceeding quota. As per GitHub's docs, GitHub Actions usage is free for both public repositories and self-hosted runners.
Seamless integration with GitHub
Since it's managed by GitHub, GitHub actions provide a seamless experience. Even if someone forks your project the GitHub actions workflows are available to them automatically. So they can easily test changes or create releases from a fork.
You can find your action workflow by visiting the
actions tab on your GitHub repository as shown below
|Action workflow runs|
You can check the status of your workflows which are triggered by the
pull_request event right there on your
pull_request page as shown below
|Checks on Pull Request|
One of the recently added features is workflow visualisations. GitHub Actions generate a visual graph of your workflow on every run. You can see your workflow run visualisation right from your workflow home page, as shown below:
|Workflow run visualisations|
Apart from these, there are many other interesting features you will find out once you enter the world of GitHub Actions. GitHub Actions is evolving fast and they are adding interesting features as we speak.
In a nutshell,
GitHub Actions solves many issues and delivers on most of its promises. I found it to be one of the simplest CI to use, with lots of interesting features and great community support. We've moved our entire CI pipelines to GitHub actions and are happy to share our journey. The our blog post, we will show you how to create your own GitHub Actions in 10 mins. So stay tuned!
- Security measures: https://securitylab.github.com/research/github-actions-preventing-pwn-requests
- GitHub actions docs: https://docs.github.com/en/free-pro-team@latest/actions
- Workflow syntax: https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions
- Event triggers: https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows
- Creating actions: https://docs.github.com/en/free-pro-team@latest/actions/creating-actions
- Parallelism analysis: https://rnorth.org/faster-parallel-github-builds/
- Intro to GitHub actions: https://towardsdatascience.com/introduction-to-github-actions-7fcb30d0f959
- Jenkins vs GitHub actions: https://blog.bitsrc.io/github-actions-or-jenkins-making-the-right-choice-for-you-9ac774684c8
|Jayesh is a founding engineer at Traceable where he works on Hypertrace and Hypertrace community building. He loves reading. You can find him on twitter and linkedin to discuss anything around tech.|