Run tests after every push

The core rule of Continuous Integration is to test every single change before integrating it with main line of code. With Buddy, you can easily configure a pipeline that automatically runs tests whenever a change is pushed to the repository.

Continuous Integration pipeline

Project setup

The first step is adding a project and attaching the Git repository that you want to test. Buddy features dedicated integrations with GitHub, Bitbucket, and GitLab, but you can easily add custom repositories from any server. If you wish to keep your CI/CD process in one place, you can host your projects directly on Buddy as well.

Project configurationProject configuration

Pipeline setup

Once the project is added and synchronized, you are ready to add your CI pipeline. If you want to test every change introduced to the repository, regardless if it's a branch, a tag, or a pull request, configure the pipeline as follows:

  1. Switch the trigger mode to the Git push event.
  2. Set the code scope to Wildcard.
  3. Set the wildcard match to *.

Configuring wildcardConfiguring wildcard

You can also limit the pipeline to specific refs. For example, if you want to limit it to branches, set the pattern to: refs/heads/*.

Adding new pipelineAdding new pipeline

Adding actions

After specifying when your pipeline should be triggered, you need to define what it should do. In this example, we'll add an action which installs dependencies and runs unit tests on the application. Buddy offers pre-configured test environments for all popular languages and frameworks:

Build actions and task runnersBuild actions and task runners

Tip
You can also select your own Docker image as the environment in the build action's Image tab.

Clicking a build action brings up its configuration details. Here you can specify the desired commands – in this case npm install and npm test:

Build action with test ommandsBuild action with test ommands

As all actions in the pipeline share the same filesystem with repository files and artifacts, you can split the commands into two separate actions:

Example pipelineExample pipeline

Conditional notifications

On top of the build actions, you can add a notification action that will send a message to your team in case the tests have failed. Buddy lets you send messages via e-mail or SMS, and integrates with a wide array of communication services, including Slack, Discord, MS Teams, and Telegram. To restrict notifications to failed runs only, switch to the On Failure tab and add the desired messaging action:

On failure sectionOn failure section

Tip
You can also add a second notification that will notify you once the repository is stable again in the Back to Green section.

Expanding test range

With Buddy, you can automate not only unit tests, but also static analysis, end-to-end, integration and browsers tests, Selenium, and more. All you need to do is to extend your pipeline with proper actions. For example, adding the ESLint action will run a static analysis on your code:

ESlint pipeline exampleESlint pipeline example

Recommended
Last update:
Aug 27, 2024