gitgreen 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +77 -0
- package/data/aws_machine_power_profiles.json +54 -0
- package/data/cpu_power_profiles.json +275 -0
- package/data/gcp_machine_power_profiles.json +1802 -0
- package/data/runtime-pue-mappings.json +183 -0
- package/dist/cli.js +137 -0
- package/dist/config.js +43 -0
- package/dist/index.js +94 -0
- package/dist/init.js +773 -0
- package/dist/lib/carbon/carbon-calculator.js +105 -0
- package/dist/lib/carbon/intensity-provider.js +29 -0
- package/dist/lib/carbon/power-profile-repository.js +90 -0
- package/dist/lib/carbon/zone-mapper.js +107 -0
- package/dist/lib/gitlab/gitlab-client.js +28 -0
- package/dist/lib/gitlab/report-formatter.js +93 -0
- package/dist/lib/telemetry/gitlab-job-loader.js +23 -0
- package/dist/lib/telemetry/runner-parser.js +63 -0
- package/dist/types.js +2 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# GitGreen CLI
|
|
2
|
+
|
|
3
|
+
Self-contained carbon calculation CLI for GitLab jobs (no API server). It reuses the same power profiles and budget reporting as the existing implementation, pulls Electricity Maps intensity, and can post Merge Request notes via `CI_JOB_TOKEN`.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
- From npm (global CLI):
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add -g gitgreen-cli
|
|
9
|
+
# or: npm install -g gitgreen-cli
|
|
10
|
+
gitgreen --help
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- From this repo:
|
|
14
|
+
```bash
|
|
15
|
+
# from repo root
|
|
16
|
+
pnpm -C node-module install
|
|
17
|
+
# build happens via prepare; dist/ is ready for CI
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Run tests (pnpm preferred):
|
|
21
|
+
```bash
|
|
22
|
+
pnpm -C node-module test
|
|
23
|
+
# or: npm --prefix node-module test
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Stress test multiple live configs (build first, real APIs):
|
|
27
|
+
```bash
|
|
28
|
+
pnpm -C node-module build
|
|
29
|
+
pnpm -C node-module stress
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
```bash
|
|
34
|
+
gitgreen \
|
|
35
|
+
--provider gcp \
|
|
36
|
+
--machine e2-standard-4 \
|
|
37
|
+
--region us-central1-a \
|
|
38
|
+
--duration 1800 \
|
|
39
|
+
--cpu 55 \
|
|
40
|
+
--budget 500 \
|
|
41
|
+
--fail-on-budget \
|
|
42
|
+
--out-md carbon-report.md \
|
|
43
|
+
--out-json carbon-report.json \
|
|
44
|
+
--post-note
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Interactive GitLab setup
|
|
48
|
+
```bash
|
|
49
|
+
# In your repo
|
|
50
|
+
gitgreen init
|
|
51
|
+
```
|
|
52
|
+
The wizard asks for provider/machine/region, budgets, MR note preference, then offers to append a ready-made job to `.gitlab-ci.yml` and prints the CI/CD variable checklist (ELECTRICITY_MAPS_API_KEY, provider creds, budget flags).
|
|
53
|
+
|
|
54
|
+
Key environment variables (loaded automatically via dotenv):
|
|
55
|
+
- `ELECTRICITY_MAPS_API_KEY` (required)
|
|
56
|
+
- `ELECTRICITY_MAPS_BASE_URL` (optional, defaults to public endpoint)
|
|
57
|
+
- `GCP_PROJECT_ID` / `GOOGLE_CLOUD_PROJECT` (for GCP metric pull)
|
|
58
|
+
- `AWS_*` credentials (for CloudWatch metric pull)
|
|
59
|
+
- `DATA_DIR` (override bundled data)
|
|
60
|
+
- `DEFAULT_PROVIDER`, `PUE_FALLBACK`, `GITLAB_BASE_URL`
|
|
61
|
+
|
|
62
|
+
GitLab CI auto-detection uses:
|
|
63
|
+
- `CI_JOB_TOKEN`, `CI_PROJECT_ID`, `CI_JOB_ID`, `CI_PIPELINE_ID`, `CI_MERGE_REQUEST_IID`, `CI_SERVER_URL`
|
|
64
|
+
- `CI_RUNNER_TAGS` (comma/space separated) to infer machine/region and instance IDs
|
|
65
|
+
|
|
66
|
+
## GitLab snippet
|
|
67
|
+
Add variables `ELECTRICITY_MAPS_API_KEY`, `CARBON_BUDGET` (optional), `FAIL_ON_BUDGET` (true/false). Then call:
|
|
68
|
+
```bash
|
|
69
|
+
./scripts/carbon/install-cli.sh
|
|
70
|
+
./scripts/carbon/run-analysis.sh
|
|
71
|
+
```
|
|
72
|
+
Artifacts `carbon-report.md` and `carbon-report.json` will be produced; `POST_MR_NOTE=true` will post to the MR when `CI_JOB_TOKEN` is available.
|
|
73
|
+
|
|
74
|
+
## Publish
|
|
75
|
+
- Ensure version bump in `package.json`
|
|
76
|
+
- Run `pnpm -C node-module build && pnpm -C node-module test`
|
|
77
|
+
- Publish: `pnpm -C node-module publish --access public`
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"m5.large": {
|
|
3
|
+
"vcpus": 2,
|
|
4
|
+
"memory_gb": 8,
|
|
5
|
+
"platform_cpu": "Intel Xeon Platinum 8175",
|
|
6
|
+
"matched_cpu_profile": "Intel Xeon Platinum 8175",
|
|
7
|
+
"cpu_power_profile": [
|
|
8
|
+
{ "percentage": 0, "watts": 11.5 },
|
|
9
|
+
{ "percentage": 10, "watts": 23.0 },
|
|
10
|
+
{ "percentage": 50, "watts": 82.0 },
|
|
11
|
+
{ "percentage": 100, "watts": 150.0 }
|
|
12
|
+
],
|
|
13
|
+
"scope3_emissions_hourly": 18
|
|
14
|
+
},
|
|
15
|
+
"c5.xlarge": {
|
|
16
|
+
"vcpus": 4,
|
|
17
|
+
"memory_gb": 8,
|
|
18
|
+
"platform_cpu": "Intel Xeon Platinum 8275",
|
|
19
|
+
"matched_cpu_profile": "Intel Xeon Platinum 8275",
|
|
20
|
+
"cpu_power_profile": [
|
|
21
|
+
{ "percentage": 0, "watts": 14.0 },
|
|
22
|
+
{ "percentage": 10, "watts": 33.0 },
|
|
23
|
+
{ "percentage": 50, "watts": 115.0 },
|
|
24
|
+
{ "percentage": 100, "watts": 195.0 }
|
|
25
|
+
],
|
|
26
|
+
"scope3_emissions_hourly": 22
|
|
27
|
+
},
|
|
28
|
+
"m6g.large": {
|
|
29
|
+
"vcpus": 2,
|
|
30
|
+
"memory_gb": 8,
|
|
31
|
+
"platform_cpu": "AWS Graviton2",
|
|
32
|
+
"matched_cpu_profile": "AWS Graviton2",
|
|
33
|
+
"cpu_power_profile": [
|
|
34
|
+
{ "percentage": 0, "watts": 8.0 },
|
|
35
|
+
{ "percentage": 10, "watts": 16.0 },
|
|
36
|
+
{ "percentage": 50, "watts": 55.0 },
|
|
37
|
+
{ "percentage": 100, "watts": 95.0 }
|
|
38
|
+
],
|
|
39
|
+
"scope3_emissions_hourly": 15
|
|
40
|
+
},
|
|
41
|
+
"r6i.2xlarge": {
|
|
42
|
+
"vcpus": 8,
|
|
43
|
+
"memory_gb": 64,
|
|
44
|
+
"platform_cpu": "Intel Xeon Ice Lake",
|
|
45
|
+
"matched_cpu_profile": "Intel Xeon Ice Lake",
|
|
46
|
+
"cpu_power_profile": [
|
|
47
|
+
{ "percentage": 0, "watts": 26.0 },
|
|
48
|
+
{ "percentage": 10, "watts": 52.0 },
|
|
49
|
+
{ "percentage": 50, "watts": 200.0 },
|
|
50
|
+
{ "percentage": 100, "watts": 360.0 }
|
|
51
|
+
],
|
|
52
|
+
"scope3_emissions_hourly": 42
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
{
|
|
2
|
+
"AMD EPYC 7B12": {
|
|
3
|
+
"tdp_watts": 240.0,
|
|
4
|
+
"power_profile": [
|
|
5
|
+
{
|
|
6
|
+
"percentage": 0,
|
|
7
|
+
"watts": 4.08
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
"percentage": 10,
|
|
11
|
+
"watts": 8.16
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"percentage": 50,
|
|
15
|
+
"watts": 40.56
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"percentage": 100,
|
|
19
|
+
"watts": 240.0
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"Intel Xeon E5-2689": {
|
|
24
|
+
"tdp_watts": 115.0,
|
|
25
|
+
"power_profile": [
|
|
26
|
+
{
|
|
27
|
+
"percentage": 0,
|
|
28
|
+
"watts": 2.07
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"percentage": 10,
|
|
32
|
+
"watts": 4.14
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"percentage": 50,
|
|
36
|
+
"watts": 20.47
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"percentage": 100,
|
|
40
|
+
"watts": 115.0
|
|
41
|
+
}
|
|
42
|
+
]
|
|
43
|
+
},
|
|
44
|
+
"Intel Xeon E5-2696V3": {
|
|
45
|
+
"tdp_watts": 145.0,
|
|
46
|
+
"power_profile": [
|
|
47
|
+
{
|
|
48
|
+
"percentage": 0,
|
|
49
|
+
"watts": 2.61
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"percentage": 10,
|
|
53
|
+
"watts": 5.22
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"percentage": 50,
|
|
57
|
+
"watts": 25.81
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"percentage": 100,
|
|
61
|
+
"watts": 145.0
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
},
|
|
65
|
+
"Intel Xeon E5-2696V4": {
|
|
66
|
+
"tdp_watts": 150.0,
|
|
67
|
+
"power_profile": [
|
|
68
|
+
{
|
|
69
|
+
"percentage": 0,
|
|
70
|
+
"watts": 2.5500000000000003
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"percentage": 10,
|
|
74
|
+
"watts": 5.1000000000000005
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"percentage": 50,
|
|
78
|
+
"watts": 25.35
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
"percentage": 100,
|
|
82
|
+
"watts": 150.0
|
|
83
|
+
}
|
|
84
|
+
]
|
|
85
|
+
},
|
|
86
|
+
"Intel Xeon E7-8880V4": {
|
|
87
|
+
"tdp_watts": 150.0,
|
|
88
|
+
"power_profile": [
|
|
89
|
+
{
|
|
90
|
+
"percentage": 0,
|
|
91
|
+
"watts": 2.6999999999999997
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"percentage": 10,
|
|
95
|
+
"watts": 5.3999999999999995
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"percentage": 50,
|
|
99
|
+
"watts": 26.7
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"percentage": 100,
|
|
103
|
+
"watts": 150.0
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"Intel Xeon Gold 6253CL": {
|
|
108
|
+
"tdp_watts": 205.0,
|
|
109
|
+
"power_profile": [
|
|
110
|
+
{
|
|
111
|
+
"percentage": 0,
|
|
112
|
+
"watts": 3.4850000000000003
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"percentage": 10,
|
|
116
|
+
"watts": 6.970000000000001
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"percentage": 50,
|
|
120
|
+
"watts": 34.645
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"percentage": 100,
|
|
124
|
+
"watts": 205.0
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
},
|
|
128
|
+
"Intel Xeon Gold 6268CL": {
|
|
129
|
+
"tdp_watts": 205.0,
|
|
130
|
+
"power_profile": [
|
|
131
|
+
{
|
|
132
|
+
"percentage": 0,
|
|
133
|
+
"watts": 3.4850000000000003
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"percentage": 10,
|
|
137
|
+
"watts": 6.970000000000001
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"percentage": 50,
|
|
141
|
+
"watts": 34.645
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"percentage": 100,
|
|
145
|
+
"watts": 205.0
|
|
146
|
+
}
|
|
147
|
+
]
|
|
148
|
+
},
|
|
149
|
+
"Intel Xeon Platinum 8273CL": {
|
|
150
|
+
"tdp_watts": 165.0,
|
|
151
|
+
"power_profile": [
|
|
152
|
+
{
|
|
153
|
+
"percentage": 0,
|
|
154
|
+
"watts": 2.805
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"percentage": 10,
|
|
158
|
+
"watts": 5.61
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"percentage": 50,
|
|
162
|
+
"watts": 27.885
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"percentage": 100,
|
|
166
|
+
"watts": 165.0
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
"Intel Xeon Platinum 8280L": {
|
|
171
|
+
"tdp_watts": 205.0,
|
|
172
|
+
"power_profile": [
|
|
173
|
+
{
|
|
174
|
+
"percentage": 0,
|
|
175
|
+
"watts": 3.4850000000000003
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"percentage": 10,
|
|
179
|
+
"watts": 6.970000000000001
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"percentage": 50,
|
|
183
|
+
"watts": 34.645
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
"percentage": 100,
|
|
187
|
+
"watts": 205.0
|
|
188
|
+
}
|
|
189
|
+
]
|
|
190
|
+
},
|
|
191
|
+
"Intel Xeon Platinum 8373C": {
|
|
192
|
+
"tdp_watts": 300.0,
|
|
193
|
+
"power_profile": [
|
|
194
|
+
{
|
|
195
|
+
"percentage": 0,
|
|
196
|
+
"watts": 5.1000000000000005
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"percentage": 10,
|
|
200
|
+
"watts": 10.200000000000001
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"percentage": 50,
|
|
204
|
+
"watts": 50.7
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
"percentage": 100,
|
|
208
|
+
"watts": 300.0
|
|
209
|
+
}
|
|
210
|
+
]
|
|
211
|
+
},
|
|
212
|
+
"Intel Xeon Platinum 8481C": {
|
|
213
|
+
"tdp_watts": 350.0,
|
|
214
|
+
"power_profile": [
|
|
215
|
+
{
|
|
216
|
+
"percentage": 0,
|
|
217
|
+
"watts": 4.9
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
"percentage": 10,
|
|
221
|
+
"watts": 9.8
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
"percentage": 50,
|
|
225
|
+
"watts": 49.349999999999994
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"percentage": 100,
|
|
229
|
+
"watts": 350.0
|
|
230
|
+
}
|
|
231
|
+
]
|
|
232
|
+
},
|
|
233
|
+
"Intel Xeon Scalable Platinum 8173M": {
|
|
234
|
+
"tdp_watts": 165.0,
|
|
235
|
+
"power_profile": [
|
|
236
|
+
{
|
|
237
|
+
"percentage": 0,
|
|
238
|
+
"watts": 2.805
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
"percentage": 10,
|
|
242
|
+
"watts": 5.61
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
"percentage": 50,
|
|
246
|
+
"watts": 27.885
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
"percentage": 100,
|
|
250
|
+
"watts": 165.0
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
},
|
|
254
|
+
"Q64-30": {
|
|
255
|
+
"tdp_watts": 180.0,
|
|
256
|
+
"power_profile": [
|
|
257
|
+
{
|
|
258
|
+
"percentage": 0,
|
|
259
|
+
"watts": 3.06
|
|
260
|
+
},
|
|
261
|
+
{
|
|
262
|
+
"percentage": 10,
|
|
263
|
+
"watts": 6.12
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
"percentage": 50,
|
|
267
|
+
"watts": 30.42
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"percentage": 100,
|
|
271
|
+
"watts": 180.0
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
}
|