Running Automation Suite via GitHub Actions

Prasad Patharkar
3 min readJan 24, 2024

--

As the software development landscape continues to evolve, the need for efficient and automated testing processes becomes increasingly critical. GitHub Actions has emerged as a powerful tool that allows developers to automate workflows, including the execution of test suites. In this article, we will explore process of setting up and configuring your automated testing workflow to run an automation suite via GitHub Actions.

Step 1: Create a Workflow file

Create a .github/workflows directory in your repository and add a YAML file defining your workflow. This file will contain the configuration for your automated testing suite.

Step 2: Trigger events

Specify the events that should trigger your workflow. For instance, you might want to run tests on every push to the main branch or when a pull request is opened. GitHub Actions provides a variety of triggers to suit different development workflows. Below is my sample code:

(Find more details at https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows)

name: Automation Suite Run

on:
push:
branches:
- develop
pull_request:
branches:
- develop
schedule:
- cron: '0 0 * * *' #Will run at 12am daily as per UTC time

Step 3: Define Jobs and Steps

Jobs represent individual tasks, and steps are the individual actions performed within each job. Specify the testing environment, dependencies, and commands necessary to run your test suite. Below is the general template for

  • Specify runner: It configures the job to run on the latest version of Ubuntu. The job will execute on a fresh virtual machine hosted by GitHub. There are many more option apart from ‘ubuntu-latest’
jobs:
build:

runs-on: ubuntu-latest
  • Steps: It groups together all the steps that are defined in the yml file. There can be multiple steps in a yaml file. First step in our case is to checkout code from Github Repositories
steps:
- name: Checkout Repository Code
uses: actions/checkout@v2
  • Setup JDK: In this step we will setup JDK 17 with Zulu
      - name: Setup Java JDK 17
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: '17'
cache: 'gradle'
  • Test execution with Gradle (Change below if you are using maven): Here we are granting permission to run the test suite using gradle and in the next step we build and run the test suite
      - name: Make Gradle executable
run: chmod +x ./gradlew

- name: Gradle Build and Test
run: ./gradlew clean build test
  • Capture the Test Artifacts: Using below step you can capture the test execution result. Here I have added the path for Extent Report generated
      - name: Archive test results
uses: actions/upload-artifact@v2
with:
name: test-results
path: test-output/ExtentReport/ # Update with the actual path to your test output directory

Step 4: Push the code to your GitHub Repository

Once you are done with yaml file shown above, push your code to your GitHub Repository and you will see the new workflow added under Actions tab. Below is sample snapshot of how it will look:

If you click on the workflow, you will also see the details such as commit, status, time duration etc. You will also see the test execution report in Artifact section at bottom.

Feel free to comment below if you have any questions or facing any issues. If you would like to see more such articles, feel free to follow me here or on linkedIn. :)

In the next article, we will see how to publish test execution result on MS teams channel via GitHub Actions after the completion of test execution. Stay tuned!

--

--

Prasad Patharkar

Hey, thanks for finding me. I write articles about test automation with an intent to help the QA community. If this interests you, feel free to follow me.