GitHub Checks Integration

Setup guide for Integrating Github with HyperTest.

Pre-requisites

  1. Your repositories are hosted on GitHub.

  2. You have owner permission to the GitHub repository

  3. HyperTest CLI is called from your CI tool(GitHub Actions, Jenkins, etc) on pull request events. Refer CI Integration

Sample file

A sample CI file for github-actions can be found below

.github-actions.yml
# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the workflow will run
on:
  # Triggers the workflow on push or pull request events but only for the "main" branch
#   push:
#     branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

env:
  HT_BASE_URL: '${{ secrets.HT_BASE_URL }}'
  HT_COMMIT_HASH: '${{ github.event.pull_request.head.sha }}' ## required because checkout creates a detached commit with a different sha  HT_API_TOKEN: '${{ secrets.HT_API_TOKEN }}'
  HT_API_TOKEN: '${{ secrets.HT_API_TOKEN }}' ## required only for K8s based HT setup, Not for Linux based HT setup
  ## Read below documentation for these Variables, if you are passing variables here you dont need to do Step 3
  GITHUB_CONFIG_REPO_URL: '${{ secrets.GITHUB_CONFIG_REPO_URL }}' ## your github repository URL
  GITHUB_CONFIG_INSTALLATION_ID: '${{ secrets.HT_BASE_URL }}' # HyperTest's Github App Installation ID
  
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v3

      # Runs a single command using the runners shell
      - name: Run a one-line script
        run: echo Hello, world!

      # Runs a set of commands using the runners shell
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
      
  deploy-to-test-env:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Run a multi-line script
        run: |
          echo Add other actions to build,
          echo test, and deploy your project.
          printenv | sort

  hypertest-start-test:
    runs-on: ubuntu-latest
    steps:
    - name: download HyperTest cli
      run: wget -O ht-cli.tar.xz https://hypertest-binaries-1.s3.ap-south-1.amazonaws.com/ht-cli/ht-cli-latest.tar.xz && tar xvf ht-cli.tar.xz
    
    - name: check if HypertTest can run test
      run: ./hypertest can-run-test
   
    - name: start new test from HyperTest CLI
      run: ./hypertest start-new-test

Steps to integrate Github Checks

Step 1: Add the HyperTest app to your repo

Go to github.com/apps/hypertest-app

Click install and select the repositories for which you would like to install the HyperTest app.

Alternatively, you may also check if you have already installed the hypertest app, by navigating to the repository settings

Under "Integrations", select "GitHub apps"

Click on the "Configure" button.

Step 2: Copy the GitHub installation ID and repo URL

Copy the GitHub installation ID from the address bar of your browser. Refer to the Image below. Here the installation ID is 24858790

Step 3: Update HyperTest Configuration

To publish reports on your CI, we need to provide above ID's etc to HyperTest. You can either add it is a configuration in HyperTest Dashboard's Service Configuration or pass it as environment variable in your CI, while starting a test.

If you have already passed the Github Repo Url and Installation ID in your CI file, you dont need to do Step 3.

Below is example for both

a. HyperTest's Dashboard Configuration

Add both the installation ID and Repo URL in HyperTest's configuration. This can be done by navigating to the Settings page in HyperTest Dashboard. Click on Service Configuration and paste the ID and repo URL.

GITHUB_CONFIG: 
   GITHUB_REPO_URL: <github_url> 
   GITHUB_INSTALLATION_ID: <installation_id>

b. Add the below enviornment variables in your CI pipeline

See details in github actions file above

GITHUB_CONFIG_REPO_URL: <github_url>
GITHUB_CONFIG_INSTALLATION_ID: <installation_id>

Click on "Update" and you have successfully integrated Github Checks with HyperTest.

Now every time your CI(Github Actions or other CI tools) triggers a test through HyperTest CLI, HyperTest will add Check reports to your commits.

By default, checks will be in a failed state in order for you to read the HyperTest Report.

Click on Details to view the HyperTest Report

Devs can see the detailed report from the HyperTest dashboard.

Last updated