You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adding possiblity to use constant CO2 value (#132)
* Adding possiblity to use constant CO2 value
* Added grid intensity constant test
* Adapted tests to use new co2-calculation-method
* Var was not assigned after removing bracket
* Using new ECO_CI_CO2_GRID_INTENSITY_API_TOKEN
* using different constant for world
* Relaxing power values slightly
* Relaxing power values more for high load
* Typos, Indents and clarifications
-`task`: (required) (options are `start-measurement`, `get-measurement`, `display-results`)
125
126
+`start-measurement`: Initialize the action and starts the measurement. This must be called, and only *once* per job. If called again data will be reset.
- Constant value to be used to calculate the CO2 from the estimated energy.
133
+
- We use the worldwide average value from Ember compiled by The Green Web Foundation from https://github.com/thegreenwebfoundation/co2.js/blob/main/data/output/average-intensities.json#L1314 as default and update it annually.
134
+
- `co2-grid-intensity-api-token`: (optional)
135
+
- API token for the API of your choice regarding the grid intensity. See details below under [Grid Intensity API Token](#grid-intensity-api-token) which APIs are currently supported.
136
+
- Note that when using an API Eco CI also needs to resolve the location of the IP. Currently implemented via https://ipapi.co/
- Used to correctly identify this CI run for the Badge. Especially in PRs this will be very cryptic like `merge/72` and you might want to set this to something nicer
128
139
- `label`: (optional) (default: 'measurement ##')
129
140
- `send-data`: (optional) (default: true)
130
141
- Send metrics data to metrics.green-coding.io to create and display badge, and see an overview of the energy of your CI runs. Set to false to send no data. The data we send are: the energy value and duration of measurement; cpu model; repository name/branch/workflow_id/run_id; commit_hash; source (GitHub or GitLab). We use this data to display in our green-metrics-tool front-end here: https://metrics.green-coding.io/ci-index.html
131
-
- `calculate-co2`: (optional) (default: true)
132
-
- You might typically always want this value to be shown unless you are in a restricted network and cannot make outbound requests
133
-
- Gets the location using https://ipapi.co/
134
-
- Get the CO2 grid intensity for the location from https://www.electricitymaps.com/
135
-
- Estimates the amount of carbon the measurement has produced
- Eco CI uses the github api to post/edit PR comments and get the workflow id
138
144
- set to github's default api, but can be changed if you are using github enterprise
@@ -150,8 +156,6 @@ jobs:
150
156
- When using the GMT Dashboard and / or CarbonDB specify the endpoint URL to send to. Defaults to "https://api.green-coding.io/v2/ci/measurement/add"
151
157
- `api-endpoint-badge-get`: (optional)
152
158
- When using the GMT Dashboard and / or CarbonDB specify the endpoint URL to get the badge from to. Defaults to "https://api.green-coding.io//v1/ci/badge/get
153
-
- `electricitymaps-api-token`: (optional)
154
-
- API token for electricitymaps in case you get rate-limited. See details below.
155
159
-`get-measurement`: Measures the energy at this point in time since either the start-measurement or last get-measurement action call.
156
160
-`label`: (optional) (default: 'measurement ##')
157
161
@@ -167,15 +171,26 @@ jobs:
167
171
-`json-output`: (optional) (default: false)
168
172
- will output data to JSON to `/tmp/eco-ci/lap-data.json`
169
173
170
-
#### Electricity Maps Token
174
+
#### Grid Intensity API Token
175
+
Used to get the grid intensity for a given location.
176
+
We currently only support ElectricityMaps. WattTime and Entso-e are on the way! (Speed it up with a PR! ❤️)
177
+
178
+
##### ElectricityMaps
179
+
It is free for personal use but sadly it is locked to a single zone. This means that if you get it for the Zone Germany the API will fail when requesting values for the US.
180
+
181
+
This is very problematic on GitHub Actions as the Us is comprised out of different zones and the machines come up in different zones. Either you buy a multi-zone key or you will have a lot of missing values.
171
182
172
-
We use ElectricityMaps to get the grid intensity for a given location.
173
-
If you want carbon values to be displayed you must set this token. It is free for personal use. In case you need a commercial license it does not matter which zones you select, as we only use the real-time endpoint which is zone free.
174
183
Get your key here: [https://api-portal.electricitymaps.com/](https://api-portal.electricitymaps.com/)
175
184
176
185
After having obtained the token you must set it as secret and pass it in the initalization of the action (see documentation above).
177
186
To learn how to create a secret see the GitHub documentation: https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions
178
187
188
+
##### WattTime
189
+
TODO - (Speed it up with a PR! ❤️)
190
+
191
+
##### Entso-e
192
+
TODO - (Speed it up with a PR! ❤️)
193
+
179
194
#### Continuing on Errors
180
195
181
196
Once you have initially set up Eco CI and have given it a test spin we recommend running our action
@@ -471,6 +486,15 @@ export PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" # if macOS
471
486
+ We do **not** recommend this as it might contain beta features. We recommend using the releases and tagged versions only
472
487
473
488
489
+
## Restricted Environments
490
+
If you are running in restricted environments, such as an enterprise with a heavily constrained network, you can tell Eco CI to not make any outbound requests.
491
+
492
+
Set:
493
+
- `send-data`to `false`
494
+
- Otherwise data will be sent to the API endpoint configured in `api-endpoint-add`
495
+
- `co2-calculation-method`to `constant`
496
+
- Otherwise the IP will be resolved to a location
497
+
474
498
## Limitations / Compatibility
475
499
- At the moment this will only work with linux based pipelines, mainly tested on ubuntu images.
Copy file name to clipboardExpand all lines: action.yml
+11-8Lines changed: 11 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,6 @@ inputs:
25
25
description: 'Send metrics data to dashboard (default: metrics.green-coding.io) to create and display badge, and see an overview of the energy of your CI runs. Set to false to send no data.'
26
26
default: true
27
27
required: false
28
-
calculate-co2:
29
-
description: 'Uses the grid carbon intensity of the run location to estimate the emitted carbon for the measurements.'
30
-
default: true
31
-
required: false
32
28
display-table:
33
29
description: 'Show the energy reading results in a table during display-results step'
34
30
default: true
@@ -81,9 +77,16 @@ inputs:
81
77
description: 'The URL for the GMT Dashboard. Punch in yours if self-hosted. Defaults to "https://metrics.green-coding.io"'
82
78
default: 'https://metrics.green-coding.io'
83
79
required: false
84
-
85
-
electricitymaps-api-token:
86
-
description: 'API token for electricitymaps in case you get rate-limited. See documentation for details'
80
+
co2-calculation-method:
81
+
description: 'CO2 calculation can be a constant and will use a supplied fixed grid intensity. Or it can also be location based where it will use a grid intensity API provider to determine the carbon intensity value of the current machine IP.'
82
+
default: 'constant'
83
+
required: false
84
+
co2-grid-intensity-constant:
85
+
description: "Constant value to be used to calculate the CO2 from the estimated energy. We use the worldwide average value from Ember compiled by The Green Web Foundation from https://github.com/thegreenwebfoundation/co2.js/blob/main/data/output/average-intensities.json#L1314 as default and update it annually."
86
+
default: 472
87
+
required: false
88
+
co2-grid-intensity-api-token:
89
+
description: 'API token for the API of your choice regarding the grid intensity. See documentation for details'
0 commit comments