Courses

[NEW] Laravel Project PROCESS: From Start to Finish

Basic CI/CD: Autorun Tests with GitHub Actions

Summary of this lesson:
- Setting up automated testing
- Configuring test environment
- Managing database connections
- Adding NPM build process

Ok, so we have automated tests that check our code for potential bugs. But we need to run those tests manually every time. Wouldn't it be cool to automate that process?

This is a part of the so-called CI/CD process, automating some checks before deployment or merging the Pull Request.

One of the most common and easy-to-setup procedures is running tests automatically on each Pull Request. Then, the author of the PR immediately knows there's something to fix before the merging person (which may be the same developer) comes to approve the Pull Request.

The easiest tool to set it up is GitHub Actions. In this lesson, I will show you how to configure automated tests, and in the following lessons, we will add more automatic checks to this process.


Setting up GitHub Actions

GitHub Actions has a limited free version, you can find all the pricing on this official GitHub page.

To enable GitHub actions, we need only add a .github/workflows/[whatever_name].yml file with instructions to GitHub.

That .yml should contain the commands that would be executed on the virtual GitHub environment: setting up PHP, cloning our project's branch, and running the tests.

In our project, we did it in a few "attempts", let me show you step-by-step.

First, we create the GitHub issue to add GitHub Actions:

Then, we create a feature branch for this:

git checkout -b feature/github-actions

And now, we can push the code into that feature branch.

Get used to this process of issue -> branch -> push -> pull request -> merge, I want it to become a habit for you.

Next, here's the example of the initial...

The full lesson is only for Premium Members.
Want to access all 16 lessons of this course? (105 min read)

You also get:

  • 69 courses (majority in latest Laravel 11)
  • Premium tutorials
  • Access to repositories
  • Private Discord