- Add setup_forge() to bin/disinto: provisions Forgejo via Docker, creates admin + bot users (dev-bot, review-bot), generates API tokens, creates repo, and pushes code — all automated - Rename env vars: CODEBERG_TOKEN→FORGE_TOKEN, REVIEW_BOT_TOKEN→ FORGE_REVIEW_TOKEN, CODEBERG_REPO→FORGE_REPO, CODEBERG_API→ FORGE_API, CODEBERG_WEB→FORGE_WEB, CODEBERG_BOT_USERNAMES→ FORGE_BOT_USERNAMES (with backwards-compat fallbacks) - Rename API helpers: codeberg_api()→forge_api(), codeberg_api_all() →forge_api_all() (with compat aliases) - Add forge_url field to project TOML; load-project.sh derives FORGE_API/FORGE_WEB from forge_url + repo - Update parse_repo_slug() to accept any host URL, not just codeberg - Forgejo data stored under ~/.disinto/forgejo/ (not in factory repo) - Update all 58 files: agent scripts, formulas, docs, site HTML Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
78 lines
2.3 KiB
Bash
Executable file
78 lines
2.3 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# ci-debug.sh — Query Woodpecker CI (CLI for logs, API for structure)
|
|
#
|
|
# Usage:
|
|
# ci-debug.sh status [pipeline] — pipeline overview + step states
|
|
# ci-debug.sh logs <pipeline> <step#> — full logs for a step
|
|
# ci-debug.sh failures [pipeline] — all failed step logs
|
|
# ci-debug.sh list [count] — recent pipelines (default 10)
|
|
|
|
set -euo pipefail
|
|
|
|
# Load shared environment
|
|
source "$(dirname "$0")/../lib/env.sh"
|
|
|
|
# WOODPECKER_TOKEN loaded from .env via env.sh
|
|
REPO="${FORGE_REPO}"
|
|
API="${WOODPECKER_SERVER}/api/repos/${WOODPECKER_REPO_ID}"
|
|
|
|
api() {
|
|
curl -sf -H "Authorization: Bearer ${WOODPECKER_TOKEN}" "${API}/$1"
|
|
}
|
|
|
|
get_latest() {
|
|
api "pipelines?per_page=1" | jq -r '.[0].number'
|
|
}
|
|
|
|
case "${1:-help}" in
|
|
list)
|
|
COUNT="${2:-10}"
|
|
api "pipelines?per_page=${COUNT}" | \
|
|
jq -r '.[] | "#\(.number) \(.status) \(.event) \(.commit[:7]) \(.message | split("\n")[0][:60])"'
|
|
;;
|
|
|
|
status)
|
|
P="${2:-$(get_latest)}"
|
|
echo "Pipeline #${P}:"
|
|
api "pipelines/${P}" | \
|
|
jq -r '" Status: \(.status) Event: \(.event) Commit: \(.commit[:7])"'
|
|
echo "Steps:"
|
|
api "pipelines/${P}" | \
|
|
jq -r '.workflows[]? | " [\(.name)]", (.children[]? | " [\(.pid)] \(.name) → \(.state) (exit \(.exit_code))")'
|
|
;;
|
|
|
|
logs)
|
|
P="${2:?Usage: ci-debug.sh logs <pipeline> <step#>}"
|
|
S="${3:?Usage: ci-debug.sh logs <pipeline> <step#>}"
|
|
woodpecker-cli pipeline log show "$REPO" "$P" "$S"
|
|
;;
|
|
|
|
failures)
|
|
P="${2:-$(get_latest)}"
|
|
FAILED=$(api "pipelines/${P}" | \
|
|
jq -r '.workflows[]?.children[]? | select(.state=="failure") | "\(.pid)\t\(.name)"')
|
|
|
|
if [ -z "$FAILED" ]; then
|
|
echo "No failed steps in pipeline #${P}"
|
|
exit 0
|
|
fi
|
|
|
|
while IFS=$'\t' read -r pid name; do
|
|
echo "=== FAILED: ${name} (step ${pid}) ==="
|
|
woodpecker-cli pipeline log show "$REPO" "$P" "$pid" 2>/dev/null | tail -200
|
|
echo ""
|
|
done <<< "$FAILED"
|
|
;;
|
|
|
|
help|*)
|
|
cat <<'EOF'
|
|
ci-debug.sh — Query Woodpecker CI
|
|
|
|
Commands:
|
|
list [count] Recent pipelines (default 10)
|
|
status [pipeline] Pipeline overview + step states
|
|
logs <pipeline> <step#> Full step logs (step# = pid from status)
|
|
failures [pipeline] All failed step logs (last 200 lines each)
|
|
EOF
|
|
;;
|
|
esac
|