Skip to content

Commit 4c0dcbb

Browse files
authored
Merge pull request #37 from fchimpan/feat/json-output-flag
feat: add --json flag for machine-readable output
2 parents ae740a7 + be86621 commit 4c0dcbb

File tree

3 files changed

+669
-349
lines changed

3 files changed

+669
-349
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,78 @@ Update jobs with warnings (missing commands or unknown execution time):
212212
gh slimify fix --force
213213
```
214214

215+
### JSON Output
216+
217+
Use `--json` to output results in machine-readable JSON format. This is useful for CI/CD pipelines, AI agents, or other tools that need to parse the results programmatically.
218+
219+
```bash
220+
gh slimify --json --all
221+
gh slimify fix --json --all
222+
```
223+
224+
**Example scan output:**
225+
226+
```json
227+
{
228+
"jobs": [
229+
{
230+
"workflow_path": ".github/workflows/ci.yml",
231+
"job_id": "lint",
232+
"job_name": "Lint",
233+
"line_number": 8,
234+
"status": "safe",
235+
"status_description": "Safe to migrate to ubuntu-slim. No missing commands and execution time is known.",
236+
"recommended_action": "migrate",
237+
"duration_seconds": 143
238+
},
239+
{
240+
"workflow_path": ".github/workflows/ci.yml",
241+
"job_id": "build",
242+
"job_name": "Build",
243+
"line_number": 25,
244+
"status": "warning",
245+
"status_description": "Can migrate but requires attention. Setup may be required for: docker.",
246+
"recommended_action": "review_before_migrate",
247+
"duration_seconds": 230,
248+
"missing_commands": ["docker"]
249+
}
250+
],
251+
"summary": {
252+
"safe": 1,
253+
"warning": 1,
254+
"ineligible": 0,
255+
"already_slim": 0,
256+
"total": 2
257+
}
258+
}
259+
```
260+
261+
**Scan job statuses:**
262+
263+
| Status | Recommended Action | Description |
264+
|---|---|---|
265+
| `safe` | `migrate` | Safe to migrate, no issues found |
266+
| `warning` | `review_before_migrate` | Can migrate but has missing commands or unknown duration |
267+
| `ineligible` | `do_not_migrate` | Cannot migrate to ubuntu-slim |
268+
| `already_slim` | `no_action_needed` | Already using ubuntu-slim |
269+
270+
**Fix job statuses:**
271+
272+
| Status | Recommended Action | Description |
273+
|---|---|---|
274+
| `updated` | `verify_workflow` | Successfully updated to ubuntu-slim |
275+
| `updated` (with warnings) | `verify_workflow_carefully` | Updated but requires careful verification |
276+
| `skipped` | `review_then_force` | Skipped due to warnings, use `--force` to update |
277+
| `error` | `investigate_error` | Failed to update |
278+
| `not_found` | `investigate_error` | Job not found in workflow file |
279+
215280
### Combine Options
216281

217282
```bash
218283
gh slimify fix .github/workflows/ci.yml --skip-duration --force
219284
gh slimify --all --skip-duration
220285
gh slimify fix --all --force
286+
gh slimify --json --all --skip-duration
221287
```
222288

223289
## 🔍 Migration Criteria
@@ -341,6 +407,7 @@ jobs:
341407
- Warning reasons in a single line
342408
- Relative file paths with line numbers (clickable in most terminals)
343409
- Execution durations
410+
- Machine-readable JSON output (`--json`) with status descriptions and recommended actions for AI agents and automation
344411
7. **Auto-Fix** (optional): Updates `runs-on: ubuntu-latest` to `runs-on: ubuntu-slim`:
345412
- By default: Only safe jobs are updated
346413
- With `--force`: All eligible jobs (including those with warnings) are updated

0 commit comments

Comments
 (0)