迁移自 mu-ref/est-ci-reusable(模板三修复版:est-bundle CA、verify 解释器 无关、build-arg 无内嵌引号、revision-arg-name、install+quality 单容器、 verdaccio add-host)+ Est-Infra 的 source-policy/REGISTER/ci-stats 上移; 全部去项目专名。架构依据 coordination runbooks/ci-repo-architecture.md。
27 lines
1.2 KiB
Bash
Executable File
27 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# ci-stats.sh — Gitea Actions run statistics (failure watch + duration trend).
|
|
# Run from ts, tn, or any host with the SSH tunnel to Gitea API.
|
|
# Requires: curl, jq, and a Gitea token with read:repository on est org.
|
|
set -eu
|
|
|
|
GITEA_BASE="${GITEA_BASE:-http://127.0.0.1:3300/api/v1}"
|
|
GITEA_TOKEN="${GITEA_TOKEN:?set GITEA_TOKEN (read:repository on est)}"
|
|
REPOS="${REPOS:?set REPOS (space-separated repo names under the org)}"
|
|
LIMIT="${LIMIT:-10}"
|
|
|
|
for repo in $REPOS; do
|
|
echo "=== est/$repo (latest $LIMIT) ==="
|
|
curl -s --max-time 20 -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_BASE/repos/est/$repo/actions/tasks?limit=$LIMIT" \
|
|
| jq -r '.workflow_runs[] |
|
|
(.updated_at | fromdateiso8601) as $up |
|
|
(.created_at | fromdateiso8601) as $cr |
|
|
[.run_number, .name, .status, (($up - $cr) | tostring + "s"), .display_title] | @tsv' \
|
|
| awk -F'\t' '{printf " %-6s %-14s %-9s %-8s %s\n", $1, $2, $3, $4, $5}'
|
|
echo " summary:"
|
|
curl -s --max-time 20 -H "Authorization: token $GITEA_TOKEN" \
|
|
"$GITEA_BASE/repos/est/$repo/actions/tasks?limit=100" \
|
|
| jq -r '[.workflow_runs[]?.status] | group_by(.) | map("\(.[0]): \(length)") | .[]' \
|
|
| sed 's/^/ /'
|
|
done
|