How to host Extent Report on GitHub Pages with Github Actions

Last Updated On

HOME

This tutorial explains the steps to host Extent Reports on GitHub Pages with GitHub Actions.

Table of Contents

What is GitHub Action?

Important points

1. The Web Application tests need to run in the headless mode in GitHub Workflow.

          ChromeOptions options = new ChromeOptions();
          options.addArguments("--no-sandbox");
          options.addArguments("--disable-dev-shm-usage");
          options.addArguments("--headless");
	      driver = new ChromeDriver(options);

2. Use the below code to use gh-pages branch to host the Extent Report:

    - name: Deploy pages
      uses: JamesIves/github-pages-deploy-action@v4.5.0
      with:
        branch: gh-pages
        folder: ./ExtentReport/Reports

Implementation Steps

Step 1 – Create GitHub Actions and Workflows

I have a repository available in GitHub – ExtentReport_GitHubActions as shown in the below image. Go to the “Actions” tab.  Click on the “Actions” tab.

Step 2 – Select the type of Actions

You will see that GitHub recommends Actions depending on the project. In our case, it is recommending actions suitable for a Java project. I have selected the “Java with Maven” option as my project is built in Maven.

Step 3 – Generation of Sample pipeline

If you choose an existing option, it will automatically generate a .yaml for the project as shown below.

We will replace the current workflow with the following yml file that will generate the ExtentReport in the GitHub as shown below:

name: ExtentReport

on:
  push:
    branches: [ "main" ]
  pull_request:
    branches: [ "main" ]

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 17
      uses: actions/setup-java@v3
      with:
        java-version: '17'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      run: mvn clean test

    - name: Deploy pages
      uses: JamesIves/github-pages-deploy-action@v4.5.0
      with:
        branch: gh-pages
        folder: ./ExtentReport/Reports

Step 4 – Commit the changes

After the changes, hit the “Start Commit” button.

This will give the option to add a description for the commit. It will also enable the user to commit either to the main branch or commit to any other branch that exists in the project. Click on the “Commit new file” button to set up the workflow file.

Step 5 – Verify that the workflow is running

Next, head over to the “Actions” tab, and you will see your YAML workflow file present under the tab. The yellow sign represents that the job is in the queue. The pipeline will fail. It is because gh-pages is not configured yet now.

Click on the workflow and the below screen is displayed. It shows the status of the run of the workflow, the total time taken to run the workflow, and the name of the .yml file.

Below are all the steps of the workflow.

https://vibssingh.github.io/ExtentReport_GitHubActions/

The complete code can be found here on GitHub - vibssingh/ExtentReport_GitHubActions.

Congratulations! We just created our CI workflow for running the ExtentReport in GitHub.

GitHub Tutorials

HOME

GitHub is a web-based version control system and collaboration platform for developers. It is the centre around which all things involving git revolve. GitHub allows software developers and engineers to create remote, public-facing repositories on the cloud for free. Once you’ve set up a repository on GitHub, you can copy it to your device, add and modify files locally, and then “push” your changes back to the repository where your changes are displayed for the public.

Chapter 1 How to create a new repository on GitHub
Chapter 2 How to delete a repository on GitHub
Chapter 3 How to Fork a GitHub repository
Chapter 4 How to clone a project from GitHub using Eclipse
Chapter 5 How to copy code from another version control to GitHub – GitHub Importer
Chapter 6 What is pull request in GitHub?
Chapter 7 How to run Selenium tests with GitHub Actions
Chapter 8 How to upload Artifacts in GitHub
Chapter 9 How to run Gradle tests with GitHub Actions
Chapter 10 How to run SpringBoot tests with GitHub Actions
Chapter 11 How to run Serenity tests with GitHub Actions – NEW
Chapter 12 How to run Rest API tests with GitHub Actions – NEW
Chapter 13 How to host Extent Report on GitHub Pages with Github Actions – NEW

Extent Reports

HOME

We can create beautiful, interactive, and detailed reports for your tests using the Extent Reports library. Add events, screenshots, tags, devices, authors, or any other relevant information you deem necessary to create a descriptive and visually appealing report that you have complete control over.

Chapter 1  ExtentReports Version 4 with Selenium and TestNG
Chapter 2  ExtentReports Version 4 for Cucumber 5, Selenium, and TestNG
Chapter 3  ExtentReports Version 5 for Cucumber 6 and TestNG
Chapter 4  How to add Screenshot to Cucumber ExtentReports
Chapter 5  ExtentReports Version 5 for Cucumber 6 and JUnit4
Chapter 6  PDF ExtentReport for Cucumber and TestNG
Chapter 7  ExtentReports Version 5 for Cucumber 7 and TestNG
Chapter 8  Extent Reports Version 5 for Cucumber7 and JUnit5
Chapter 9  Gradle – Extent Report Version 5 for Cucumber, Selenium, and TestNG
Chapter 10  Gradle – ExtentReports Version 5 for Cucumber, Selenium and JUnit4
Chapter 11 How to host Extent Report on GitHub Pages with Github Actions – NEW