Automating Collection Testing in GitHub

Streamlining Ansible Collection Testing with GitHub Actions

Luca Berton

--

Introduction

GitHub Actions provides a powerful and flexible platform for automating workflows directly within your GitHub repository. One common use case is automating the testing of collections in Ansible, ensuring that each component functions as expected. This article will guide you through the setup of a GitHub Actions workflow for testing Ansible collections using the .github/test.yml configuration.

Understanding the Configuration

Let’s break down the structure of the .github/test.yml file:

name: GHA for foo.bar

concurrency:
group: ${{ github.head_ref || github.run_id }}
cancel-in-progress: true

on:
pull_request:
branches: [main]
workflow_dispatch:
schedule:
- cron: '0 0 * * *'
  • name: Describes the name of the GitHub Actions workflow.
  • concurrency: Specifies concurrency settings, ensuring that workflows do not interfere with each other. The group attribute combines workflows under the same conditions, and cancel-in-progress cancels any currently running workflow if a new one is triggered.
  • on: Defines the events that trigger the workflow. In this case, the workflow is triggered on pull requests targeting the main branch, manually using workflow_dispatch, and on a daily schedule.

Now, let’s look at the job definitions:

jobs:
ansible-lint:
uses: ansible-network/github_actions/.github/workflows/ansible-lint.yml@main
changelog:
uses: ansible-network/github_actions/.github/workflows/changelog.yml@main
integration:
uses: ansible-network/github_actions/.github/workflows/integration_simple.yml@main
sanity:
uses: ansible-network/github_actions/.github/workflows/sanity.yml@main
unit-galaxy:
uses: ansible-network/github_actions/.github/workflows/unit_galaxy.yml@main
  • jobs: Lists the individual jobs that will be executed. Each job is defined separately and utilizes existing workflows from the ansible-network/github_actions repository.

--

--

Luca Berton

I help creative Automation DevOps, Cloud Engineer, System Administrator, and IT Professional to succeed with Ansible Technology to automate more things everyday