Loading...
Loading...
Analyze workflow runs - frequency, duration, success rates, and efficiency
npx skill4agent add laurigates/claude-plugins finops-workflowsgh repo view --json nameWithOwner --jq '.nameWithOwner' 2>/dev/null| Parameter | Description | Default |
|---|---|---|
| Repository in owner/name format | Current repository |
REPO="${1:-$(gh repo view --json nameWithOwner --jq '.nameWithOwner')}"
echo "Analyzing workflows for: $REPO"echo ""
echo "=== Active Workflows ==="
gh workflow list --repo "$REPO" --json id,name,state \
--jq '.[] | select(.state == "active") | " \(.name) (id: \(.id))"'echo ""
echo "=== Run Summary (last 30 days) ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
--jq '.workflow_runs | group_by(.name) |
map({
name: .[0].name,
total: length,
success: ([.[] | select(.conclusion == "success")] | length),
failure: ([.[] | select(.conclusion == "failure")] | length),
cancelled: ([.[] | select(.conclusion == "cancelled")] | length),
skipped: ([.[] | select(.conclusion == "skipped")] | length)
}) |
sort_by(-.total)[] |
"\(.name):\n Total: \(.total) | Success: \(.success) | Failure: \(.failure) | Cancelled: \(.cancelled) | Skipped: \(.skipped)\n Success rate: \(if .total > 0 then ((.success / .total * 100) | floor) else 0 end)%"'echo ""
echo "=== Duration Analysis ==="
gh api "/repos/$REPO/actions/runs?per_page=50&status=completed" \
--jq '.workflow_runs | group_by(.name) |
map({
name: .[0].name,
count: length,
durations: [.[] | (.run_started_at as $start | .updated_at as $end |
(($end | fromdateiso8601) - ($start | fromdateiso8601)))],
}) |
map({
name: .name,
count: .count,
avg_seconds: (if .count > 0 then (.durations | add / length | floor) else 0 end),
max_seconds: (if .count > 0 then (.durations | max) else 0 end),
total_seconds: (.durations | add)
}) |
sort_by(-.total_seconds)[] |
"\(.name):\n Runs: \(.count) | Avg: \(.avg_seconds / 60 | floor)m\(.avg_seconds % 60)s | Max: \(.max_seconds / 60 | floor)m\(.max_seconds % 60)s | Total: \(.total_seconds / 60 | floor)min"'echo ""
echo "=== Trigger Types ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
--jq '.workflow_runs | group_by(.event) |
map({event: .[0].event, count: length}) |
sort_by(-.count)[] |
" \(.event): \(.count) runs"'echo ""
echo "=== Recent Failures (last 10) ==="
gh api "/repos/$REPO/actions/runs?per_page=100&status=completed" \
--jq '[.workflow_runs[] | select(.conclusion == "failure")] | .[0:10][] |
" #\(.run_number) \(.name) - \(.created_at | split("T")[0]) - \(.html_url)"'echo ""
echo "=== High Frequency Workflows ==="
gh api "/repos/$REPO/actions/runs?per_page=100" \
--jq '.workflow_runs | group_by(.name) |
map(select(length > 60)) |
map({name: .[0].name, runs: length, per_day: (length / 30 | . * 10 | floor / 10)}) |
sort_by(-.runs)[] |
" \(.name): \(.runs) runs (~\(.per_day)/day) - consider path filters"'Analyzing workflows for: org/repo
=== Active Workflows ===
CI (id: 12345)
Deploy (id: 12346)
CodeQL (id: 12347)
=== Run Summary (last 30 days) ===
CI:
Total: 156 | Success: 140 | Failure: 10 | Cancelled: 4 | Skipped: 2
Success rate: 89%
Deploy:
Total: 45 | Success: 44 | Failure: 1 | Cancelled: 0 | Skipped: 0
Success rate: 97%
=== Duration Analysis ===
CI:
Runs: 50 | Avg: 4m32s | Max: 12m15s | Total: 226min
Deploy:
Runs: 20 | Avg: 2m10s | Max: 3m45s | Total: 43min
=== Trigger Types ===
push: 89 runs
pull_request: 67 runs
schedule: 30 runs
workflow_dispatch: 5 runs
=== Recent Failures (last 10) ===
#234 CI - 2025-01-28 - https://github.com/org/repo/actions/runs/...
#231 CI - 2025-01-27 - https://github.com/org/repo/actions/runs/...
=== High Frequency Workflows ===
CI: 156 runs (~5.2/day) - consider path filtersgh run view --log-failed/finops:waste