The next thing to add is continuous integration (CI), using GitHub Actions (GHA). Continuous integration is a set of automated tasks or jobs that are run, usually triggered by some event in the repository. The goal of those tasks is usually to check whether functional tests are still green, and compilation has been successful.

Bear in mind that CI tasks are not limited to functional tests. They may check for other things such as whether code follows any format or naming conventions, or whether test coverage stays above its target percentage. It can also automatically publish your package, deploy your app and so on.

In other words, a CI service or platform gives you the ability to run any script on a set of triggers or events that help achieve some goal in a consistent and regular way.

Let's take a look at GitHub Actions.

This is a CI platform provided by GitHub. Its typical events include pushes into the repository, new pull requests, new tag pushed etc. The first workflow that we're going to implement will be a typical "run tests, run lint and check if it's all good" triggered by any push to the master or new pull request. If any of the jobs fail it means that the code is broken in some way and that it needs to be fixed before it can be merged into the master branch. If we wanted to push directly to the master where we have the rights, then at least we'll get notified that we've missed something.

So, to get our CI working with GHA, we need to create the folder .github/workflows and then the file ci.yml inside it, and paste in this code:

Let me explain step-by-step what's happening here.

Start a new discussion. All notification go to the author.