Skip to main content
Welcome to this comprehensive step-by-step guide on building End-to-End (E2E) testing ephemeral environments using GitHub Actions and Qovery. If you’ve been seeking ways to automate your testing processes, reduce operational overhead, and improve the efficiency of your development cycle, then you’re in the right place. This article is available in the webinar format as well

Why E2E Testing?

End-to-End testing is a critical phase in the software development lifecycle. It validates that your application works cohesively from start to finish, mimicking real-world scenarios.
E2E vs UI Tests vs Integration Tests vs Unit Tests - from SemaphoreCI
While unit tests and integration tests offer valuable insights, they do not replicate how multiple components interact in a live production environment. E2E testing fills that gap and ensures that your application performs as expected when it goes live.

The Importance of Ephemeral Environments

In the world of DevOps and CI/CD, ephemeral environments (aka Preview Environments) serve as temporary, isolated setups where you can test your applications. These environments are increasingly vital in agile development frameworks where frequent changes are the norm. They can be provisioned quickly, teared down when no longer needed, and replicated easily. This means you can push your changes more rapidly into production with confidence.

GitHub Actions and Qovery: A Perfect Match

GitHub Actions offers a powerful platform for automating workflows, allowing you to build, test, and deploy your code right from GitHub. Qovery, on the other hand, simplifies the provisioning and management of cloud resources, making it incredibly straightforward to set up ephemeral environments. When used in tandem, these tools provide a seamless, automated pipeline for E2E testing.

What You’ll Learn

This guide is designed to walk you through the entire process of setting up an automated E2E testing pipeline. We’ll start by setting up GitHub Actions, move on to configuring ephemeral environments with Qovery, and finally, integrate these components into a cohesive, automated testing solution. By the end of this guide, you’ll have a fully operational E2E testing pipeline that will allow you to:
  1. Automate your testing process
  2. Quickly provision and de-provision environments
  3. Integrate closely with your GitHub repository
  4. Save both time and operational costs
So, whether you are a developer, a DevOps engineer, a QA specialist, an engineering manager, or even a CTO, this guide offers valuable insights for anyone involved in the software development process. Let’s dive in!

Prerequisites

You have a GitHub account
For any questions, existing customers can reach out via Pylon directly in the Qovery console.

Tools

Here are the tools we will use in this guide:
  • Qovery for the infrastructure and the ephemeral environment
  • GitHub Actions for the CI/CD pipeline
  • K6 for the e2e tests

7 Steps to build E2E testing ephemeral environments with GitHub Actions and Qovery

Here is the big picture of what we will build:
e2e testing Workflow with github actions and Qovery
We will focus on the most important parts of the workflow - from label number 2 to 11. I assume that you already know GitHub and how to create a Pull Request :) Let’s go!

1. Prepare Qovery blueprint environment

If you are not already familiar with Qovery, I recommend you to What’s Qovery. In this guide, we will use Qovery to provision our ephemeral environments composed of a Java application (TODO app) and a PostgreSQL database. For this, we will create a blueprint environment that will be used as a template to create ephemeral environments.
You can skip this part if you already have an environment that you want to use as a base for your ephemeral environments.
Here are the steps I did to create my blueprint environment:
  1. Connect to Qovery.
  2. Create a new project.
  3. Create a new environment named blueprint.
  4. Add a PostgreSQL database inside your blueprint environment.
  5. Add a TODO app by using my ECR container registry where I push my image from GitHub Actions (cf next step).
At the end of those steps, you should have something like this:
Blueprint environment
If you want to use my TODO app as an example, you need to properly configure the environment variables of the application. Here is a table with the environment variables you need to set: You’re good to go! Now, let’s move on to the next step.

2. Build and push container image

In this step, we will build and push the container image of our application to our ECR container registry. We will use GitHub Actions to do that. Create your GitHub Actions workflow inside .github/workflows folder. I named mine build-and-push-image.yml. Here is the content of the file:
Find my complete file here
AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are stored as GitHub secrets.
The ECR registry is also connected to my Qovery account - so I can pull the pushed image from Qovery as well.

3. Create an Ephemeral Environment with GitHub Actions and Qovery

In this step, we will create an ephemeral environment with GitHub Actions and Qovery. We will use the Qovery CLI inside our GitHub Actions workflow to do that. Create your GitHub Actions workflow inside .github/workflows folder. I named mine pull-request-run-e2e-tests.yml. Here is the content of the file:
Basically, we use the qovery environment clone command to clone our blueprint environment into a new environment. Then, we use the qovery container update command to update the container tag of our application. Finally, we use the qovery environment deploy command to deploy our application. The option -w is used to wait for the deployment to be completed. We also use the qovery service list command to get the status of our environment and store it in a GitHub output variable. This variable will be used in the next step to display the status of the environment in the Pull Request.
Find my complete file here
You can see the result of this step in the Pull Request:
Ephemeral environment status in Pull Request

4. Run E2E tests with K6

In this step, we will run our E2E tests with K6. K6 is a modern load testing tool that allows you to write tests in JavaScript. It’s a great tool to run E2E tests as well. Here is the script we will use:
The complete script is available here
We will use the setup function to add some data to our database. Then, we will use the default function to get the list of items from our API. We will use the options variable to define the number of users we want to simulate. In this example, we will simulate 100 users for 5 minutes. You can find more information about the options variable here. To run our E2E tests, we will use the k6 run command inside our GitHub Actions workflow. Here is the content of the file:
The complete file is available here
We use the qovery container domain list command to get the domain of our application. Then, we use the k6 command to run our E2E tests. We store the result of the tests in a GitHub output variable.
The qovery container domain list command returns ANSI color codes. We use the sed -e 's/\x1b\[[0-9;]*m//g' command to remove them.

5. Display test results in Pull Request

In this step, we will display the result of our E2E tests in the Pull Request. We will use the GitHub Actions output variables to do that. Here is the content of the file:
$
The complete file is available here
You can see the result of this step in the Pull Request:
E2E report in Pull Request

6. Destroy Ephemeral Environment and clean up resources

Now we will destroy the ephemeral environment and clean up the resources when the Pull Request is closed or merged. Here is the yaml:
The complete file is available here
We just use the qovery environment delete command to delete the ephemeral environment. The option -w is used to wait for the deletion to be completed. Qovery will automatically release the resources used by the environment.

Wrapping up

Congratulations! You’ve successfully built an automated E2E testing pipeline with GitHub Actions and Qovery. You can now run your tests in a fully isolated environment, provisioned and de-provisioned automatically, and integrated with your GitHub repository. Some resources: