gitgreen 1.1.3 → 1.4.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 CHANGED
@@ -1,279 +1,383 @@
1
- # GitGreen CLI
1
+ <p align="center">
2
+ <h1 align="center">GitGreen</h1>
3
+ <p align="center">
4
+ <strong>Carbon footprint tracking for GitLab CI/CD pipelines</strong>
5
+ </p>
6
+ <p align="center">
7
+ <a href="#quick-start">Quick Start</a> •
8
+ <a href="#installation">Installation</a> •
9
+ <a href="#usage">Usage</a> •
10
+ <a href="#methodology">Methodology</a> •
11
+ <a href="#faq">FAQ</a>
12
+ </p>
13
+ </p>
14
+
15
+ ---
16
+
17
+ [![npm version](https://img.shields.io/npm/v/gitgreen.svg)](https://www.npmjs.com/package/gitgreen)
18
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
19
+ [![Node.js](https://img.shields.io/badge/Node.js-20+-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
20
+
21
+ GitGreen measures the carbon emissions of your CI/CD jobs using real CPU/RAM metrics, grid carbon intensity data, and research-backed power models. Works with **GCP** and **AWS** runners.
2
22
 
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`. Works with both GCP and AWS runners.
23
+ ```
24
+ Total emissions: 2.847 gCO₂e
25
+ ├── CPU: 1.923 gCO₂e
26
+ ├── RAM: 0.412 gCO₂e
27
+ └── Scope 3: 0.512 gCO₂e (embodied carbon)
28
+ ```
4
29
 
5
- ## Prerequisites
30
+ ## Quick Start
6
31
 
7
- Before installing GitGreen CLI, ensure you have the following installed and configured:
32
+ ```bash
33
+ # Install globally
34
+ npm install -g gitgreen
8
35
 
9
- ### Required
36
+ # Initialize in your GitLab project
37
+ cd your-repo
38
+ gitgreen init
39
+ ```
10
40
 
11
- - **Node.js** (v20 or higher) - [Download](https://nodejs.org/)
12
- - Required to run the CLI tool
13
- - Check version: `node --version`
41
+ The wizard configures everything: provider credentials, carbon budgets, and CI/CD integration.
14
42
 
15
- - **npm** or **pnpm** - Package manager (comes with Node.js)
16
- - This project uses `pnpm@8.15.4` as the package manager
17
- - Install pnpm: `npm install -g pnpm`
43
+ ## Table of Contents
18
44
 
19
- - **Git** - [Download](https://git-scm.com/)
20
- - Required for detecting GitLab project information during initialization
21
- - Check version: `git --version`
45
+ - [Installation](#installation)
46
+ - [Usage](#usage)
47
+ - [Advanced](#advanced)
48
+ - [Providers](#providers)
49
+ - [Output Integrations](#output-integrations)
50
+ - [Database Schema](#database-schema)
51
+ - [Methodology](#methodology)
52
+ - [Architecture](#architecture)
53
+ - [Configuration](#configuration)
54
+ - [FAQ](#faq)
55
+ - [Contributing](#contributing)
56
+ - [References](#references)
57
+ - [License](#license)
22
58
 
23
- ### Cloud Provider CLIs (Required based on provider)
59
+ ## Installation
24
60
 
25
- - **Google Cloud SDK (gcloud CLI)** - [Installation Guide](https://cloud.google.com/sdk/docs/install-sdk)
26
- - Required for GCP provider setup and authentication
27
- - After installation, authenticate: `gcloud auth login`
28
- - Set default project: `gcloud config set project YOUR_PROJECT_ID`
29
- - Check version: `gcloud --version`
61
+ ### Prerequisites
30
62
 
31
- - **AWS Credentials** - [AWS CLI Installation](https://aws.amazon.com/cli/) (optional, but recommended)
32
- - Required for AWS provider (can use environment variables or AWS CLI config)
33
- - Configure credentials: `aws configure`
34
- - Or set environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_REGION`
63
+ | Requirement | Version | Notes |
64
+ |-------------|---------|-------|
65
+ | Node.js | 20+ | [Download](https://nodejs.org/) |
66
+ | Git | Any | For GitLab project detection |
67
+ | gcloud CLI | Any | Required for GCP ([Install](https://cloud.google.com/sdk/docs/install-sdk)) |
68
+ | AWS CLI | Any | Required for AWS ([Install](https://aws.amazon.com/cli/)) |
69
+ | glab CLI | Any | Optional, for easier GitLab auth ([Install](https://docs.gitlab.com/cli/)) |
35
70
 
36
- ### Optional (but recommended)
71
+ ### Install
37
72
 
38
- - **GitLab CLI (glab)** - [Installation Guide](https://docs.gitlab.com/cli/)
39
- - Recommended for easier GitLab authentication and CI/CD variable management
40
- - After installation, authenticate: `glab auth login`
41
- - Check version: `glab --version`
42
- - If not installed, you'll need to provide a GitLab Personal Access Token manually
73
+ ```bash
74
+ npm install -g gitgreen
75
+ ```
43
76
 
44
77
  ### API Keys
45
78
 
46
- - **Electricity Maps API Key** - [Get free key](https://api-portal.electricitymaps.com)
47
- - Required for carbon intensity data
48
- - You'll be prompted for this during `gitgreen init`
79
+ - **Electricity Maps** (required): [Get free API key](https://api-portal.electricitymaps.com)
49
80
 
50
- ## Install
51
- - From npm (global CLI):
52
- ```bash
53
- npm install -g gitgreen
54
- gitgreen --help
55
- ```
81
+ ## Usage
56
82
 
57
- Run tests:
58
- ```bash
59
- npm test
60
- ```
83
+ ### Initialize a Project
61
84
 
62
- Stress test multiple live configs (build first, real APIs):
63
85
  ```bash
64
- npm build
65
- npm stress
86
+ gitgreen init
66
87
  ```
67
88
 
68
- ## Usage
89
+ The wizard will:
90
+ 1. Configure your cloud provider (GCP/AWS)
91
+ 2. Set machine type and region
92
+ 3. Configure carbon budgets
93
+ 4. Set up database exports (optional)
94
+ 5. Append the tracking job to `.gitlab-ci.yml`
95
+ 6. Store credentials in GitLab CI/CD variables
69
96
 
70
- ### Initializing a New GitLab Project
97
+ **That's it!** Run your next pipeline and carbon emissions will be calculated automatically. Results appear as MR comments, in your configured database, and are stored in carbon job artifacts.
71
98
 
72
- To get started with carbon tracking in any GitLab project (any project with a remote pointing to a GitLab instance), run:
99
+ ---
73
100
 
74
- ```bash
75
- # In your repo
76
- gitgreen init
77
- ```
101
+ ## Advanced
78
102
 
79
- The initialization wizard will guide you through the setup process:
80
- - Configure provider/machine/region settings
81
- - Set carbon budgets
82
- - Configure MR note preferences
83
- - Choose to use an existing runner or spin up a new one with supported providers
103
+ ### Providers
84
104
 
85
- After initialization, the wizard will:
86
- - Append a ready-made job to your `.gitlab-ci.yml`
87
- - Print the CI/CD variable checklist (ELECTRICITY_MAPS_API_KEY, provider credentials, budget flags)
105
+ | Provider | Metrics Source | Status |
106
+ |----------|---------------|--------|
107
+ | **GCP** | Cloud Monitoring API | Full support |
108
+ | **AWS** | CloudWatch API | Full support |
88
109
 
89
- ### How It Works
110
+ ### Output Integrations
90
111
 
91
- Once initialized, all subsequent pipelines will run on the configured runner, and their performance will be automatically measured. The carbon tracking is implemented using GitLab CI/CD components as a final step in your pipeline. The carbon tracking job itself is not computationally expensive, so it adds minimal overhead to your CI/CD workflows.
112
+ Export carbon data to external databases for analytics and dashboards.
92
113
 
93
- Key environment variables:
94
- - `ELECTRICITY_MAPS_API_KEY` (required) - Get a free key from https://api-portal.electricitymaps.com
95
- - `GCP_PROJECT_ID` / `GOOGLE_CLOUD_PROJECT` (required for GCP) - Your GCP project ID
96
- - `AWS_ACCESS_KEY_ID` / `AWS_SECRET_ACCESS_KEY` (required for AWS CloudWatch) - Credentials with CloudWatch read access on the runner
97
- - `AWS_REGION` (for AWS) - Region of the runner EC2 instance
114
+ #### Supported Connectors
98
115
 
99
- The `gitgreen init` wizard will automatically set all necessary GitLab CI/CD variables for you.
116
+ | Connector | Job Data | Runner Inventory |
117
+ |-----------|----------|------------------|
118
+ | MySQL | `GITGREEN_JOB_MYSQL_*` | `GITGREEN_RUNNER_MYSQL_*` |
119
+ | PostgreSQL | `GITGREEN_JOB_POSTGRES_*` | `GITGREEN_RUNNER_POSTGRES_*` |
100
120
 
101
- ## Providers
121
+ #### Database Migrations
102
122
 
103
- GitGreen supports multiple cloud providers:
123
+ ```bash
124
+ gitgreen migrate --scope job # Job emissions tables
125
+ gitgreen migrate --scope runner # Runner inventory tables
126
+ gitgreen migrate --scope all # Both
127
+ ```
104
128
 
105
- - **GCP**: Fully wired the CLI parser expects GCP Monitoring JSON, the GitLab component polls GCE metrics, and `gitgreen init` provisions or reuses GCP runners.
106
- - **AWS**: CloudWatch-backed — the CLI can pull metrics directly via `--from-cloudwatch`, the GitLab component fetches CloudWatch CPU/RAM data, and `gitgreen init` can configure or provision EC2 runners.
129
+ Migrations run automatically in CI pipelines.
130
+
131
+ ### Database Schema
132
+
133
+ <details>
134
+ <summary><strong>Job Table</strong> (per-job emissions)</summary>
135
+
136
+ | Column | Type | Description |
137
+ |--------|------|-------------|
138
+ | `id` | BIGSERIAL | Primary key |
139
+ | `ingested_at` | TIMESTAMPTZ | Insert timestamp |
140
+ | `provider` | TEXT | `gcp` or `aws` |
141
+ | `region` | TEXT | Cloud region/zone |
142
+ | `machine_type` | TEXT | Instance type |
143
+ | `runtime_seconds` | INT | Job duration |
144
+ | `total_emissions` | DOUBLE | Total gCO₂eq |
145
+ | `cpu_emissions` | DOUBLE | CPU gCO₂eq |
146
+ | `ram_emissions` | DOUBLE | RAM gCO₂eq |
147
+ | `scope3_emissions` | DOUBLE | Embodied gCO₂eq |
148
+ | `carbon_intensity` | DOUBLE | Grid intensity (gCO₂eq/kWh) |
149
+ | `pue` | DOUBLE | Power Usage Effectiveness |
150
+ | `carbon_budget` | DOUBLE | Budget threshold |
151
+ | `over_budget` | BOOLEAN | Budget exceeded |
152
+ | `gitlab_project_id` | BIGINT | GitLab project |
153
+ | `gitlab_pipeline_id` | BIGINT | Pipeline ID |
154
+ | `gitlab_job_id` | BIGINT | Job ID |
155
+ | `gitlab_job_name` | TEXT | Job name |
156
+ | `payload` | JSONB | Full result JSON |
157
+
158
+ </details>
159
+
160
+ <details>
161
+ <summary><strong>Timeseries Table</strong> (CPU/RAM metrics)</summary>
162
+
163
+ | Column | Type | Description |
164
+ |--------|------|-------------|
165
+ | `id` | BIGSERIAL | Primary key |
166
+ | `job_id` | BIGINT | Foreign key to job |
167
+ | `metric` | TEXT | `cpu`, `ram_used`, `ram_size` |
168
+ | `ts` | TIMESTAMPTZ | Timestamp |
169
+ | `value` | DOUBLE | Metric value |
170
+
171
+ </details>
172
+
173
+ <details>
174
+ <summary><strong>Runner Inventory Table</strong></summary>
175
+
176
+ | Column | Type | Description |
177
+ |--------|------|-------------|
178
+ | `id` | BIGSERIAL | Primary key |
179
+ | `runner_id` | TEXT | GitLab runner ID |
180
+ | `machine_type` | TEXT | Instance type |
181
+ | `provider` | TEXT | Cloud provider |
182
+ | `region` | TEXT | Region |
183
+ | `last_job_total_emissions` | DOUBLE | Last job emissions |
184
+ | `payload` | JSONB | Full metadata |
185
+
186
+ </details>
187
+
188
+ ## Methodology
189
+
190
+ GitGreen's calculations are based on peer-reviewed methodologies from [re:cinq](https://re-cinq.com/blog/cloud-cpu-energy-consumption) and [Teads](https://github.com/re-cinq/emissions-data).
191
+
192
+ ### Formula
107
193
 
108
- ## Architecture
109
- Runtime flow:
110
- ```
111
- CPU/RAM timeseries (GCP Monitoring JSON or custom collector)
112
- |
113
- v
114
- +------------------+ +----------------------------+
115
- | CLI (gitgreen) |--->| CarbonCalculator |
116
- | - parse metrics | | - PowerProfileRepository |<- machine data in data/*.json
117
- | - CLI/env opts | | - ZoneMapper (region→zone) |<- static + runtime PUE mapping
118
- +------------------+ | - IntensityProvider |<- Electricity Maps API
119
- +-------------+------------+
120
- |
121
- v
122
- +-----------------------------+
123
- | Report formatter |
124
- | - Markdown/JSON artifacts |
125
- | - Budget evaluation |
126
- +-------------+---------------+
127
- |
128
- v
129
- +-----------------------------+
130
- | GitLab client (optional) |
131
- | - MR note via CI_JOB_TOKEN |
132
- +-----------------------------+
133
194
  ```
195
+ E_total = E_operational + E_embodied
134
196
 
135
- GitLab CI path:
136
- ```
137
- Pipeline starts → component script fetches CPU/RAM timeseries from GCP Monitoring or AWS CloudWatch
138
- → writes JSON files → runs `gitgreen --provider gcp|aws ...`
139
- → emits `carbon-report.md` / `carbon-report.json`
140
- → optional MR note when CI_JOB_TOKEN is present
197
+ E_operational = (P_cpu + P_ram) × runtime_hours × PUE × carbon_intensity
198
+ E_embodied = scope3_hourly × runtime_hours
141
199
  ```
142
200
 
143
- ## Output Integrations
201
+ | Variable | Description | Source |
202
+ |----------|-------------|--------|
203
+ | `P_cpu` | CPU power (kW) | Interpolated from utilization |
204
+ | `P_ram` | RAM power (0.5 W/GB) | Industry standard for DDR4 |
205
+ | `PUE` | Data center efficiency | Google/AWS published data |
206
+ | `carbon_intensity` | Grid emissions (gCO₂eq/kWh) | Electricity Maps API |
207
+ | `scope3_hourly` | Embodied carbon rate | Dell R740 LCA study |
144
208
 
145
- During `gitgreen init` you can opt into exporting GitGreen data to external systems. The wizard includes an integration step with two optional sinks:
209
+ ### CPU Power Model
146
210
 
147
- - **Per-job carbon data** emissions, runtime, and runner tags for every CI job.
148
- - **Runner inventory** – the machine catalog that powers your GitLab runners, including machine type and scope 3 estimates.
211
+ CPU power is **non-linear** with utilization. We use cubic spline interpolation across measured data points:
149
212
 
150
- Built-in connectors today:
151
- - **MySQL** – populates `GITGREEN_JOB_MYSQL_*` / `GITGREEN_RUNNER_MYSQL_*` and inserts rows through a standard MySQL client.
152
- - **PostgreSQL** – captures host, port, credentials, schema, table, and SSL mode (`GITGREEN_JOB_POSTGRES_*` / `GITGREEN_RUNNER_POSTGRES_*`) for storage in Postgres.
213
+ | Utilization | Power (% of TDP) |
214
+ |-------------|------------------|
215
+ | 0% (idle) | 1.7% |
216
+ | 10% | 3.4% |
217
+ | 50% | 16.9% |
218
+ | 100% | 100% |
153
219
 
154
- When you select either connector, the wizard captures host, port, username, password, database, and target table names and stores them in CI/CD variables. It immediately connects with those credentials to ensure the database, schema, and table exist (job sinks also create a `<table>_timeseries` table linked via foreign key). During CI, the GitGreen CLI automatically detects those env vars and:
220
+ **VM Power Correction:** Cloud VMs share physical CPUs. We scale power by the ratio of VM vCPUs to physical threads:
155
221
 
156
- - runs `gitgreen migrate --scope job|runner` to apply any pending migrations (tracked per DB via `gitgreen_migrations`);
157
- - writes each carbon calculation (typed summary columns plus CPU/RAM timeseries rows) and optional runner inventory snapshot into the configured sink.
222
+ ```
223
+ P_vm = TDP × ratio × (vm_vcpus / physical_threads)
224
+ ```
158
225
 
159
- ### Extending the interface
226
+ | CPU | Cores | Threads | TDP | Source |
227
+ |-----|-------|---------|-----|--------|
228
+ | Intel Xeon Gold 6268CL | 24 | 48 | 205W | [Intel](https://www.ebay.com/p/2321792675) |
229
+ | Intel Xeon Platinum 8481C | 56 | 112 | 350W | [TechPowerUp](https://www.techpowerup.com/cpu-specs/xeon-platinum-8481c.c3992) |
230
+ | AMD EPYC 7B12 | 64 | 128 | 240W | [AMD](https://www.newegg.com/p/1FR-00G6-00026) |
231
+ | Ampere Altra Q64-30 | 64 | 64 | 180W | [Ampere](https://amperecomputing.com/en/briefs/ampere-altra-family-product-brief) |
160
232
 
161
- Additional connectors can be added without touching the wizard logic. Each destination implements the `OutputIntegration` interface in `src/lib/integrations/output-integrations.ts`, which specifies:
233
+ ### Scope 3 (Embodied Carbon)
162
234
 
163
- 1. Display metadata (`id`, `name`, `description`)
164
- 2. The data target it handles (`job` vs `runner`)
165
- 3. Prompted credential fields (label, env var key, input type, default, mask flag)
235
+ Manufacturing emissions amortized over hardware lifespan (6 years):
166
236
 
167
- To add another sink (for example PostgreSQL or a webhook), create a new entry in that file with the fields your integration needs. Re-run `gitgreen init` and the option will automatically appear in the integration step.
237
+ | Component | Emissions |
238
+ |-----------|-----------|
239
+ | Base server | ~1000 kgCO₂eq |
240
+ | Per CPU | ~100 kgCO₂eq |
241
+ | Per 32GB DIMM | ~44 kgCO₂eq |
242
+ | Per SSD | ~50-100 kgCO₂eq |
168
243
 
169
- ### Database migrations
244
+ *Source: Dell PowerEdge R740 Life Cycle Assessment*
170
245
 
171
- Structured sinks rely on migrations tracked in `gitgreen_migrations`. Run them whenever you update GitGreen or change table names:
246
+ ### Accuracy & Limitations
172
247
 
173
- ```bash
174
- gitgreen migrate --scope job # apply job sink migrations (summary + timeseries)
175
- gitgreen migrate --scope runner # apply runner inventory migrations
176
- gitgreen migrate --scope all # convenience wrapper (used by the GitLab component)
177
- ```
248
+ **Expected Accuracy:**
249
+ - Relative comparisons: Excellent (comparing job A vs B)
250
+ - Absolute values: ±15-25% for CPU-bound workloads
178
251
 
179
- The GitLab component automatically runs `gitgreen migrate --scope job` and `--scope runner` before calculating emissions, so pipelines stay in sync even when you change versions.
252
+ **Known Limitations:**
180
253
 
181
- ## Adding a provider
182
- 1. Extend `CloudProvider` and the provider guard in `src/index.ts` so the calculator accepts the new key.
183
- 2. Add machine power data (`<provider>_machine_power_profiles.json`) and, if needed, CPU profiles to `data/`, then update `PowerProfileRepository.loadMachineData` to load it.
184
- 3. Map regions to Electricity Maps zones and a PUE default in `ZoneMapper` (or via `data/runtime-pue-mappings.json` for runtime overrides).
185
- 4. Parse that provider's metrics into the `TimeseriesPoint` shape (timestamp + numeric value) alongside RAM size/usage, and update the CLI/init/templates to pull those metrics.
186
- 5. Wire any CI automation (runner tags, MR note flags) to pass the correct provider, machine type, and region strings.
254
+ | Limitation | Impact | Notes |
255
+ |------------|--------|-------|
256
+ | No GPU modeling | High | GPU jobs underestimated |
257
+ | Fixed RAM power | Low | 0.5 W/GB industry standard |
258
+ | No network/storage I/O | Low | <5% of typical job power |
187
259
 
188
- ## Publish
189
- - Ensure version bump in `package.json`
190
- - Run `pnpm -C node-module build && pnpm -C node-module test`
191
- - Publish: `pnpm -C node-module publish --access public`
260
+ ## Architecture
192
261
 
193
- ## FAQ
262
+ ```
263
+ ┌─────────────────────────────────────────────────────────────┐
264
+ │ GitLab Pipeline │
265
+ ├─────────────────────────────────────────────────────────────┤
266
+ │ ┌─────────────┐ ┌──────────────────────────────────┐ │
267
+ │ │ Your Jobs │───▶│ GitGreen Carbon Tracking Job │ │
268
+ │ └─────────────┘ │ ├─ Fetch CPU/RAM metrics │ │
269
+ │ │ ├─ Calculate emissions │ │
270
+ │ │ ├─ Post MR comment │ │
271
+ │ │ └─ Export to database │ │
272
+ │ └──────────────────────────────────┘ │
273
+ └─────────────────────────────────────────────────────────────┘
274
+
275
+ ┌────────────────────┼────────────────────┐
276
+ ▼ ▼ ▼
277
+ ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
278
+ │ GCP Monitoring │ │ Electricity Maps│ │ MySQL/Postgres │
279
+ │ AWS CloudWatch │ │ API │ │ (optional) │
280
+ └─────────────────┘ └─────────────────┘ └─────────────────┘
281
+ ```
194
282
 
195
- ### Are my API keys and credentials secure?
283
+ ## Configuration
196
284
 
197
- Yes. GitGreen does not save your keys locally. During `gitgreen init`, all sensitive credentials (API keys, service account keys, AWS credentials) are stored only in GitLab CI/CD variables, which are encrypted and managed by GitLab. The CLI never writes credentials to disk on your local machine.
285
+ ### Adding a New Provider
198
286
 
199
- ### Does GitGreen call any third-party APIs?
287
+ 1. Add machine power profiles to `data/<provider>_machine_power_profiles.json`
288
+ 2. Update `PowerProfileRepository.loadMachineData()`
289
+ 3. Map regions to Electricity Maps zones in `ZoneMapper`
290
+ 4. Parse metrics into `TimeseriesPoint` format
291
+ 5. Wire CI automation for provider-specific settings
200
292
 
201
- GitGreen only calls APIs that you explicitly configure and authorize:
293
+ ### Source Data Files
202
294
 
203
- - **Electricity Maps API** - For carbon intensity data (requires your API key)
204
- - **GitLab API** - Only when using `glab` CLI or providing a PAT, to set CI/CD variables
205
- - **GCP Monitoring API** - To fetch CPU/RAM metrics from your GCP project (requires your service account)
206
- - **AWS CloudWatch API** - To fetch CPU/RAM metrics from your AWS account (requires your AWS credentials)
295
+ | File | Description |
296
+ |------|-------------|
297
+ | `data/cpu_physical_specs.json` | Physical CPU specs with sources |
298
+ | `data/cpu_power_profiles.json` | TDP and power ratios |
299
+ | `data/gcp_machine_power_profiles.json` | GCP machine mappings |
300
+ | `data/aws_machine_power_profiles.json` | AWS instance mappings |
301
+ | `data/source/*.csv` | Original re:cinq research data |
207
302
 
208
- GitGreen does not operate any backend services or call any APIs owned by the GitGreen project. All API calls are made directly from your environment or CI/CD pipeline using your credentials.
303
+ ## FAQ
209
304
 
210
- ### How do I know GitGreen won't destroy my `.gitlab-ci.yml` file?
305
+ <details>
306
+ <summary><strong>Are my credentials secure?</strong></summary>
211
307
 
212
- GitGreen takes safety precautions when modifying your `.gitlab-ci.yml`:
308
+ Yes. GitGreen stores all credentials in GitLab CI/CD variables (encrypted). Nothing is written to your local disk.
309
+ </details>
213
310
 
214
- 1. **Automatic backups** - Before making any changes, GitGreen creates a backup of your existing `.gitlab-ci.yml` file
215
- 2. **Backup location** - The backup path is printed to the console (e.g., `/tmp/gitlab-ci-backup-{timestamp}.yml`)
216
- 3. **Append-only changes** - GitGreen only appends new content to your CI file; it never removes or modifies existing jobs
217
- 4. **Confirmation prompt** - You're asked to confirm before any changes are made
311
+ <details>
312
+ <summary><strong>What APIs does GitGreen call?</strong></summary>
218
313
 
219
- If something goes wrong, you can restore your file from the backup location that was printed.
314
+ Only APIs you explicitly configure:
315
+ - Electricity Maps API (carbon intensity)
316
+ - GCP Monitoring API (metrics)
317
+ - AWS CloudWatch API (metrics)
318
+ - GitLab API (MR comments, via CI_JOB_TOKEN)
220
319
 
221
- ### Can I use GitGreen without the `init` wizard?
320
+ GitGreen has no backend server.
321
+ </details>
222
322
 
223
- Yes. You can configure GitGreen manually by:
323
+ <details>
324
+ <summary><strong>Will it break my .gitlab-ci.yml?</strong></summary>
224
325
 
225
- 1. Setting the required CI/CD variables in your GitLab project settings
226
- 2. Adding the GitLab CI/CD component to your `.gitlab-ci.yml` manually
227
- 3. Running `gitgreen` directly with command-line options instead of using the component
326
+ No. GitGreen creates a backup before any changes, only appends content (never modifies existing jobs), and asks for confirmation.
327
+ </details>
228
328
 
229
- The `init` wizard is a convenience tool, but all functionality is available through manual configuration.
329
+ <details>
330
+ <summary><strong>Can I run it without the wizard?</strong></summary>
230
331
 
231
- ### What data does GitGreen collect?
332
+ Yes. Set CI/CD variables manually and run `gitgreen` with CLI options.
333
+ </details>
232
334
 
233
- GitGreen only collects:
335
+ ## Contributing
234
336
 
235
- - **CPU and RAM usage metrics** from your cloud provider (GCP Monitoring or AWS CloudWatch)
236
- - **Pipeline metadata** (start/end times) from GitLab CI/CD environment variables
337
+ 1. Fork the repository
338
+ 2. Create a feature branch
339
+ 3. Run tests: `npm test`
340
+ 4. Submit a pull request
237
341
 
238
- GitGreen does not collect any personal information, code, or data from your repositories. All calculations happen locally in your CI/CD pipeline.
342
+ ## References
239
343
 
240
- ### Can I run GitGreen locally for testing?
344
+ ### Research & Methodology
241
345
 
242
- Yes. You can run `gitgreen` directly with your own metrics files:
346
+ | Source | Description |
347
+ |--------|-------------|
348
+ | [re:cinq Cloud CPU Energy Consumption](https://re-cinq.com/blog/cloud-cpu-energy-consumption) | CPU power modeling methodology |
349
+ | [re:cinq emissions-data](https://github.com/re-cinq/emissions-data) | Machine power profiles and ratios |
350
+ | [Teads Engineering](https://engineering.teads.com/) | Original research on cloud carbon |
351
+ | Dell PowerEdge R740 LCA | Scope 3 embodied carbon data |
243
352
 
244
- **GCP example:**
245
- ```bash
246
- gitgreen --provider gcp \
247
- --machine e2-standard-4 \
248
- --region us-central1-a \
249
- --cpu-timeseries cpu.json \
250
- --ram-used-timeseries ram-used.json \
251
- --ram-size-timeseries ram-size.json \
252
- --out-md report.md
253
- ```
353
+ ### Data Sources
254
354
 
255
- **AWS example:**
256
- ```bash
257
- gitgreen --provider aws \
258
- --machine t3.medium \
259
- --region us-east-1 \
260
- --cpu-timeseries cpu.json \
261
- --ram-used-timeseries ram-used.json \
262
- --ram-size-timeseries ram-size.json \
263
- --out-md report.md
264
- ```
355
+ | Data | Source |
356
+ |------|--------|
357
+ | Real-time carbon intensity | [Electricity Maps API](https://www.electricitymaps.com/) |
358
+ | GCP machine specifications | [Google Cloud CPU Platforms](https://cloud.google.com/compute/docs/cpu-platforms) |
359
+ | GCP data center PUE | [Google Data Center Efficiency](https://www.google.com/about/datacenters/efficiency/) |
360
+ | Intel CPU specifications | [Intel ARK](https://ark.intel.com/) |
361
+ | AMD CPU specifications | [AMD Product Pages](https://www.amd.com/en/products/specifications/processors) |
362
+ | Ampere CPU specifications | [Ampere Product Briefs](https://amperecomputing.com/briefs) |
265
363
 
266
- Or use `--from-cloudwatch` to fetch metrics directly from AWS CloudWatch:
267
- ```bash
268
- gitgreen --provider aws \
269
- --machine t3.medium \
270
- --region us-east-1 \
271
- --from-cloudwatch \
272
- --out-md report.md
273
- ```
364
+ ### CPU Specifications Used
274
365
 
275
- This is useful for testing before integrating into your CI/CD pipeline.
366
+ | CPU | Cores | Threads | TDP | Source |
367
+ |-----|-------|---------|-----|--------|
368
+ | Intel Xeon Gold 6268CL | 24 | 48 | 205W | [Product Listing](https://www.ebay.com/p/2321792675) |
369
+ | Intel Xeon Gold 6253CL | 18 | 36 | 205W | [PassMark](https://www.cpubenchmark.net/cpu.php?cpu=Intel+Xeon+Gold+6253CL) |
370
+ | Intel Xeon Platinum 8481C | 56 | 112 | 350W | [TechPowerUp](https://www.techpowerup.com/cpu-specs/xeon-platinum-8481c.c3992) |
371
+ | Intel Xeon Platinum 8373C | 36 | 72 | 300W | [Wikipedia](https://en.wikipedia.org/wiki/List_of_Intel_Xeon_processors_(Ice_Lake-based)) |
372
+ | AMD EPYC 7B12 | 64 | 128 | 240W | [Newegg](https://www.newegg.com/p/1FR-00G6-00026) |
373
+ | Ampere Altra Q64-30 | 64 | 64 | 180W | [Ampere Brief](https://amperecomputing.com/en/briefs/ampere-altra-family-product-brief) |
276
374
 
277
375
  ## License
278
376
 
279
- MIT License - see [LICENSE](LICENSE) file for details.
377
+ MIT License - see [LICENSE](LICENSE) for details.
378
+
379
+ ---
380
+
381
+ <p align="center">
382
+ <sub>Built with care for a sustainable software future.</sub>
383
+ </p>