How to Setup CI/CD Pipeline for Automated API Tests

Yogesh Dhole
3 min readJun 26, 2023

--

Automating API test suite execution through CI/CD pipelines provides a significant advantage over local execution. By leveraging CI/CD, teams can obtain test results for all systems, improving the speed, quality, and reliability of tests. Manual triggering of API suite execution is not required, freeing up valuable time for team members.

In this blog post, we will guide you through the creation of a workflow file using GitHub Actions for your automated API tests. However, before diving into the creation of a CI/CD workflow, it’s essential to understand some crucial points for a better grasp of the concept.

Before we start creating a CI/CD workflow for our API tests I will suggest you first go through the API test automation framework here and also read this blog on creating a web test automation framework as it helps you to understand the different points which we all should consider before selecting the test automation framework. The API test automation framework is in Python language and has Behave library for BDD purposes.

Let’s understand some basic and important points to start with the CI/CD workflow.

What is CI/CD?

CI/CD refers to Continuous Integration and Continuous Delivery, which are processes and practices that help to deliver code changes more frequently and reliably. These processes involve automating the building, testing, and deployment of code changes, resulting in faster and higher-quality software releases for end-users.

The CI/CD pipeline follows a workflow that starts with continuous integration (CI), followed by continuous delivery (CD). The CI process involves integrating code changes into a shared repository and automatically building and testing them to identify errors early in the development process. Once the code has been tested and approved, the CD process takes over and automates the delivery of code changes to production environments.

The CI/CD pipeline workflow helps to reduce the risks and delays associated with manual code integration and deployment while ensuring that the changes are tested and delivered quickly and reliably. This approach enables organizations to innovate faster, respond more quickly to market demands, and improve overall software quality.

Process:

name: Python API CI/CD Pipeline
on:
push:
branches: [“main”]
# schedule:
# — cron: ’00 12 * * *’
jobs:
build:
runs-on: windows-latest
steps:
— uses: actions/checkout@v3
— name: Set up Python
uses: actions/setup-python@v3
with:
python-version: ‘3.8.9’
— name: Install dependencies
run: |
python -m pip install — upgrade pip
pip && pip install -r requirement.txt
— name: install allure
run: npm install -g allure-commandline
continue-on-error: true
— name: run test
run: behave Features -f allure_behave.formatter:AllureFormatter -o Report_Json
working-directory: .
continue-on-error: true
— name: html report
run: allure generate Report_Json -o Report_Html — clean
continue-on-error: true
— uses: actions/upload-artifact@v2
with:
name: HTML reports
path: Report_Html
continue-on-error: true

--

--

Yogesh Dhole
Yogesh Dhole

Written by Yogesh Dhole

Top-Tier SDET | Advanced in Manual & Automated Testing | Skilled in Full-Spectrum Testing & CI/CD | API, Mobile & Desktop App Automation | ISTQB Certified

No responses yet