Documentation

Looking for something in particular?

Parallel Execution in GitHub Actions using Targets

In ANT execution, everything configured under the target tag is considered part of the execution. ANT allows us to have multiple target tags in the same build.xml file. You can initialize the variables in Github actions using target names in secrets.

The following command is used to execute the build file with targets: 

ant -f build.xml target_name

You can run your workflow in parallel using Target by creating different jobs for the individual target.

Example: You have 100 test cases and want to execute 50 test cases in parallel. Then, you can have two targets in the build.xml file, each pointing to the 50 test cases to be completed.

Below is the .yml as an example of parallel execution in Github actions using multiple targets:

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on: 
  workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  build_Chrome:    
     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@v2     
     - name: Run in chrome
       env:
        BROWSER_NAME: Chrome
        TARGET1:${{secrets.TARGET1}}     
             run: |
        mkdir $GITHUB_WORKSPACE/ProvarHome
        curl -O https://download.provartesting.com/latest/Provar_ANT_latest.zip
        unzip -o Provar_ANT_latest.zip -d ProvarHome
        rm Provar_ANT_latest.zip
        sudo apt-get update && sudo apt-get upgrade       
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -        
        sudo echo "deb [arch=amd64]  http://dl.google.com/linux/chrome/deb/ stable main" >>sudo tee -a /etc/apt/sources.list.d/google-chrome.list
        sudo apt-get -y install google-chrome-stable
        sudo add-apt-repository ppa:mozillateam/firefox-next && sudo apt install firefox
        echo $PROVAR_HOM
        cd $GITHUB_WORKSPACE/test/AN
               
        xvfb-run ant -f build.xml $TARGET1
     - uses: actions/upload-artifact@v2
       with:
        name: Execution Report1
       path:${{ github.workspace }}/test/ANT/Results/*
     - uses: actions/upload-artifact@v2
       if: failure()
       with:
        name: Execution Report1
        path:${{ github.workspace }}/test/ANT/Results/*
build_ChromeHeadless:
     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@v2     
     - name: Run build Headless
       env:
        BROWSER_NAME: Chrome_Headless
        TARGET2:${{secrets.TARGET2}}           
       run: |
        mkdir $GITHUB_WORKSPACE/ProvarHome
        curl -O https://download.provartesting.com/latest/Provar_ANT_latest.zip
        unzip -o Provar_ANT_latest.zip -d ProvarHome
        rm Provar_ANT_latest.zip
        sudo apt-get update && sudo apt-get upgrade       
        wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -        
        sudo echo "deb [arch=amd64]  http://dl.google.com/linux/chrome/deb/ stable main" >>sudo tee -a /etc/apt/sources.list.d/google-chrome.list
        sudo apt-get -y install google-chrome-stable
        sudo add-apt-repository ppa:mozillateam/firefox-next && sudo apt install firefox
        echo $PROVAR_HOM
        cd $GITHUB_WORKSPACE/test/AN
               
        xvfb-run ant -f build.xml $TARGET2
    - uses: actions/upload-artifact@v2
       with:
        name: Execution Report2
       path:${{ github.workspace }}/test/ANT/Results/*
     - uses: actions/upload-artifact@v2
       if: failure()
       with:
        name: Execution Report2
         path:${{ github.workspace }}/test/ANT/Results/*

Feedback

Was this article helpful for you?
Documentation library

Trying to raise a case with our support team?

We use cookies to better understand how our website is used so we can tailor content for you. For more information about the different cookies we use please take a look at our Privacy Policy.

Scroll to Top