Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Schedule tests the GitOps way with Testing Farm as GitHub Action

May 4, 2022
Petr Hracek Zuzana Miklankova
Related topics:
CI/CDDevOpsGitOpsLinux
Related products:
Red Hat Enterprise Linux

Share:

    Testing Farm is an open source test system that makes it easier to run unit tests on your projects. A previous article, Test GitHub projects with GitHub Actions and Testing Farm, showed you how to use the framework. This article introduces a new GitHub Action named Testing Farm as GitHub Action, which is available on GitHub Marketplace and integrates your tests into a GitOps environment so that you can ensure that tests are run at key points during development.

    Note: GitHub Marketplace is a central site where developers can find GitHub Actions along with other resources. Anyone with a GitHub account can publish an Action on GitHub Marketplace. Publishing the Action in the Marketplace brings additional visibility.

    Testing Farm is a service maintained by Red Hat, and is currently available to internal services, Red Hat Hybrid Cloud services, and open source projects related to Red Hat products. Any kind of test described with a Test Management Tool (TMT) plan can be executed. Your testing environment can be Red Hat Enterprise Linux, Fedora, CentOS, or CentOS Stream.

    We recommend that you read the previous article before this one to learn how Testing Farm works and how it fits into the development cycle.

    About Testing Farm as GitHub Action

    Testing Farm provides a common interface to many types of tests and makes it easy to run them in a uniform manner, but it's still the developer's job to schedule the tests. With Testing Farm as GitHub Action, you can decide at what points in your development cycle (creating, checking or merging a pull request (PR), etc.) you want to run tests, and have them run automatically by GitHub.

    Note: In order to avoid running malicious code on the Testing Farm infrastructure, it is important to have the tests reviewed by an authorized person.

    The Action can be used by developers, maintainers, or anyone else who wants to test a repository located on GitHub. We recommend that, to make sure unauthorized code doesn't run in a testing environment, you allow only members and owners of a repository to use the Action.

    Testing Farm as GitHub Action is a composite Action, intended to be used from other GitHub Actions. You can find more details about how composite actions work in the GitHub documentation. Testing Farm as GitHub Action schedules tests so that triggers in a GitHub repository run the tests on the Testing Farm infrastructure and, optionally, display their results.

    Action inputs

    Testing Farm as GitHub Action is highly configurable, but all the variables have defaults except the following, which must be configured by the user:

    • api_key: API key used to get access to Testing Farm
    • git_url: URL of a GitHub repository with one or more TMT plans

    To obtain your API key, send an email to tft@redhat.com as described in Testing Farm's onboarding documentation.

    Here's a minimal example of what it would look like to use Testing Farm as GitHub Action on a repository that you have checked out:

    - name: Schedule tests Testing Farm
      uses: sclorg/testing-farm-as-github-action@v1
      with:
          api_key: ${{ secrets.API_KEY }}
          git_url: <URL to a TMT plan>

    All other input values are optional. They fall into the following groups:

    • TMT metadata: Options for configuring the TMT specification, such as the URL for the Git repository with the TMT plan, or a regular expression that selects plans.
    • Testing Farm: Options for configuring Testing Farm itself. You can configure the API key, the URL to Testing Farm's API, and the scope (public or private) of the Testing Farm in use.
    • Test environment: Options for configuring the operating system and architecture where the test will be run. The supported Linux distributions are Fedora, CentOS (including CentOS Stream), and Red Hat Enterprise Linux 7 and 8. You can also specify the secrets and environment variables needed during test execution.
    • Test artifacts: Additional artifacts to install in the test environment. For more information, see Testing Farm's REST API documentation.
    • Miscellaneous: Settings for various options, such as whether the PR should be updated with test results after finishing the job and what should be written in the PR status.

    More information about the inputs can be found at the Action's GitHub repository.

    Action outputs

    Each run of Testing Farm as GitHub Action returns two outputs: a req_id and a results_url. You can combine these values to obtain a URL pointing to a log. Test logs and test results from the Testing Farm are collected here in text form.

    Optionally, if the event that triggers Testing Farm as GitHub Action is related to a PR, the user can enable a PR status update. This update places a summary of test results in a graphical form directly in the PR. By default, test results are displayed as a status using the GitHub statuses API. Figure 1 shows sample output.

    Output from Testing Farm shows the results of each test, with links to details.
    Figure 1. Output from Testing Farm shows the results of each test, with links to details.
    Figure 1: Output from Testing Farm shows the results of each test, with links to details.

    A Testing Farm as GitHub Action example

    The following configuration runs tests when a PR is created on the repository. (You can find the full example YAML file in the software collections GitHub repository.) This configuration follows the recommendation that the person running the tests must be an owner or member of the repository:

    name: upstream tests at Testing Farm
    on:
      issue_comment:
        types:
          - created
    
    jobs:
        build:
          name: A job run on explicit user request
          runs-on: ubuntu-20.04
    
     if: |
        github.event.issue.pull_request
        && contains(github.event.comment.body, '[test]')
        && contains(fromJson('["OWNER", "MEMBER"]'),
                    github.event.comment.author_association)

    The Action checks out the repository and switches to the branch of the PR branch:

    steps:
    
    - name: Checkout repo
      uses: actions/checkout@v2
      with:
            ref: "refs/pull/${{ github.event.issue.number }}/head"
    

    Now you can schedule tests on Testing Farm using the GitHub Action:

    
    - name: Schedule tests on external Testing Farm by Testing-Farm-as-github-action
      id: github_action
      uses: sclorg/testing-farm-as-github-action@v1
      with:
          api_key: ${{ secrets.TF_API_KEY }}
          git_url: "https://github.com/sclorg/sclorg-testing-farm"
          variables: "REPO_URL=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY;REPO_NAME=$GITHUB_REPOSITORY;PR_NUMBER=${{ github.event.issue.number }};OS=centos7;TEST_NAME=test"
          compose: "CentOS-7"
    

    Conclusion

    Testing Farm as GitHub Action lets you avoid the tedious work of setting up a testing infrastructure, writing a lot of GitHub Action workflows, and handling PR statuses. With just a TMT test plan and an API key, you can get access to a whole testing infrastructure that will meet your needs. Various processor architectures and Linux distributions are available as testing environments.

    To get started, all you need is to request an api_key from the Testing Farm team, write a simple GitHub workflow, and use the Action.

    Your tests are triggered by an event you specify in the configuration file. Logs and results from test execution are collected, reported, and stored in text form and optionally also transparently displayed in the PR status. Testing Farm as GitHub Action makes it easy to test project changes as soon as possible before your project goes to real customers.

    If you want to learn more about how GitOps can transform your workflow, check out Getting Started with ArgoCD and OpenShift GitOps Operator, a hands-on lab from Red Hat Developer.

    Last updated: September 26, 2024

    Related Posts

    • Test GitHub projects with GitHub Actions and Testing Farm

    Recent Posts

    • Run Qwen3-Next on vLLM with Red Hat AI: A step-by-step guide

    • How to implement observability with Python and Llama Stack

    • Deploy a lightweight AI model with AI Inference Server containerization

    • vLLM Semantic Router: Improving efficiency in AI reasoning

    • Declaratively assigning DNS records to virtual machines

    What’s up next?

    Getting GitOps e-book card

    Learn how to navigate the complex world of modern container-based software development and distribution with Getting GitOps: A Practical Platform with OpenShift, Argo CD, and Tekton.

    Download the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2025 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue