The Problem

  • Developer doing manual API testing
  • Climate Change is also impacted by digital footprint carbon means our code has produced carbon

GreenStatus CI/CD Component

a CI/CD component that streamlines API testing by automating processes, accurately calculates carbon emissions (CO2.JS) for each API call made during testing, and generates comprehensive reports hosted on GitLab Pages. Additionally, it incorporates a vital sustainability feature, offering a carbon offset link to help mitigate environmental impact. By integrating these functionalities, teams can ensure software reliability, gain insights into environmental footprints, and contribute to sustainable development practices seamlessly within their CI/CD pipelines.

How it Work

To make it easy for you to understand how GreenStatus works, take a look to this picture:

Flow diagram showing how the GreenStatus works

Getting Started

to get started, add syntax below to your pipeline .gitlab-ci.yml

include:
  - component: gitlab.com/dimasna96/GreenStatus/greenstatus-component@<VERSION>
    inputs:
      workflow-file: <YOUR WORKFLOW FILE (YML)>
      stage: test
      estimated-req-avg: "<NUMBER OF ESTIMATED API REQUEST (INT)>"
#add pages job to generate report on GitLab Pages
pages:
  image: alpine:latest
  stage: deploy
  script:
    - ls
  artifacts:
      paths:
        - public

Inputs

Input Default value Description
workflow-file workflow.yml The Workflow's file path. example of file : workflow-example.yml or you can learn more on StepCI Docs
stage test The stage at which you aim to include the job.
estimated-req-avg "1000000" The number of estimated average API requests to calculate your total API carbon emissions and will used to offset carbon using Wren

Output

1. Report on GitLab Page LIVE DEMO

Report on GitLab Page

2. Report on Artifact public/data.json

Report on Artifact

{
    "tests": [
        {
            "id": "Authentication",
            "steps": [
              {
                "testId": "Login",
                "name": "POST /Login",
                "passed": true,
                "errored": false,
                "skipped": false,
                "duration": 1354,
                "co2": 0.011322024480000002
              },
              {
                "testId": "Login",
                "name": "POST /Logout",
                "passed": false,
                "errored": false,
                "skipped": false,
                "duration": 1354,
                "co2": 0.011322024480000002
              }
            ],
            "passed": false,
            "duration": 1354,
            "co2": 0.011322024480000002
          }

    ],
    "passed": false,
    "duration": 258,
    "co2": 0.011322024480000002,
    "estimatedReqAvg": 1000000
}

Goals & Success

  • Developers can save more time for API Testing
  • Developers aware of climate change
  • Many Developers will use GitLab Pages to generate API status page

Built With

  • gitlab
  • gitlab-ci-cd-component
  • gitlab-pages
  • react
Share this project:

Updates