This post will teach us how to use GitHub Actions to create a continuous integration (CI) pipeline that automatically tests, vets, and lints your Golang code.
For solo projects, I usually create a pre-commit Git hook to carry out these kinds of checks, but for team projects or open-source work — where you don’t have control over everyone’s development environment — using a CI workflow is a great way to flag up potential problems and help catch bugs before they make it into production or a versioned release.
And suppose you’re already using GitHub to host your repository. In that case, it’s friendly and easy to use their built-in functionality to do this without needing additional third-party tools or services.
To demonstrate how it works, let’s run through a step-by-step example.
Please create a new repository and clone it to your local machine if you’d like to follow along. For this post I’m going to use the private repository
Creating a workflow file
We next want to create a workflow file that describes what we want to do in our CI checks and when we want them to run. By convention, this file should be stored in a
.github/workflow directory in the root of your repository and should be in YAML format.