Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

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

    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

    • Every layer counts: Defense in depth for AI agents with Red Hat AI

    • Fun in the RUN instruction: Why container builds with distroless images can surprise you

    • Trusted software factory: Building trust in the agentic AI era

    • Build a zero trust AI pipeline with OpenShift and RHEL CVMs

    • Red Hat Hardened Images: Top 5 benefits for software developers

    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

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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

    Chat Support

    Please log in with your Red Hat account to access chat support.