Skip to main content

Continuous Integration

The ideal place to run GreenFrame is in a Continuous Integration (CI) pipeline. This way, you can run the analysis on every commit, and detect carbon leaks before they reach production.

GitHub Actions

  • Add to your repo settings a secret named GREENFRAME_SECRET_TOKEN with your API token.

  • Add a .github/workflows/greenframe.yml containing:

name: Greenframe Analysis
on: [push]
jobs:
greenframeci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all the git history
- run: curl https://assets.greenframe.io/install.sh | bash
# Start your application here
- run: greenframe analyze
env:
GREENFRAME_SECRET_TOKEN: ${{secrets.GREENFRAME_SECRET_TOKEN}}

GitHub actions disable the git history by default in order to speed up your build time. If you want to activate the automatic comparison with your base branch, GreenFrame CLI needs to be able to get the commit ID ancestor. Overwrite the fetch-depth parameter inside the checkout GitHub action:

- uses: actions/checkout@v2
with:
fetch-depth: 0 # Fetch all the git history

Travis CI

  • Add to your Travis settings a secret named GREENFRAME_SECRET_TOKEN with your API token.

  • Add a .travis.yml containing:

git:
depth: false # Fetch all the git history
before_install:
- sudo apt-get update
- curl https://assets.greenframe.io/install.sh | bash
script:
# Start your application here
- greenframe analyze

If you want to activate the automatic comparison with your base branch, GreenFrame CLI needs to be able to get the commit ID ancestor. Travis disables the git history by default to speed up your build time. You have to overwrite the git clone depth:

git:
depth: false # Fetch all the git history

Other CI

GreenFrame CLI can be used in any CI. You just have to install it and run the greenframe analyze command.

Installation

curl https://assets.greenframe.io/install.sh | bash

Configure The Analysis

Add a .greenframe.yml file at the root of your project:

baseURL: YOUR_APP_BASE_URL
scenarios:
- path: PATH_TO_YOUR_SCENARIO_FILE
name: My first scenario
threshold: 0.1
projectName: YOUR_PROJECT_NAME
samples: 3
distant: false
useAdblock: true
containers:
- "CONTAINER_NAME"
- "ANOTHER_CONTAINER_NAME"
databaseContainers:
- "DATABASE_CONTAINER_NAME"

See the configuration file reference for more details.

Set Your GreenFrame Token

Set your GreenFrame token in the GREENFRAME_SECRET_TOKEN environment variable.

Run The Analysis

greenframe analyze

Check the greenframe-cli documentation for more details