-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Wire all programs to org profile (org portability PR B) #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 14 commits
dfe55fa
f486d1c
b6f9818
f68c1fb
fd6319f
2b88df9
136542f
b1bde17
887c3d9
63a9e56
4c207da
a8d8f12
5b6333f
88a2c81
55034e1
f7d006a
a6cfa26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| reports/ | ||
| *.log | ||
|
|
||
| # Local copies of host cron/job state (contains deployment internals; never commit) | ||
| .host-backup/ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| # automation-health | ||
|
|
||
| Machine-generated reports from the automation programs. These files are | ||
| **overwritten in place on every run** by their generating scripts — do not edit | ||
| them by hand, and do not add dated copies. | ||
|
|
||
| | File | Generated by | Cadence | | ||
| |------|--------------|---------| | ||
| | `link-health.md` | `scripts/link-health-scanner.sh` | per scan run | | ||
| | `automation-health.md` | `scripts/automation-health-dashboard.sh` | per dashboard run | | ||
|
|
||
| ## Why a single overwritten file (not dated snapshots) | ||
|
|
||
| Trends are reconstructed by replaying the file's git commit history (parent by | ||
| parent), so each commit already captures a point-in-time snapshot. Storing dated | ||
| copies would duplicate what git already records — the files-vs-diffs-on-Git | ||
| anti-pattern. A future trend tool should read `git log` for these paths rather | ||
| than expect a directory of dated files. | ||
|
|
||
| See rossoctl/automation#44 for the decision. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,7 @@ | |
| set -euo pipefail | ||
|
|
||
| # ============================================================================= | ||
| # Automation Health Dashboard Generator — kagenti org | ||
| # Automation Health Dashboard Generator | ||
| # Combines link-health and dep-bump program metrics into a single executive- | ||
| # facing markdown dashboard. Pushes to a standing fork-based PR. | ||
| # | ||
|
|
@@ -13,23 +13,27 @@ set -euo pipefail | |
| # ============================================================================= | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||
| # shellcheck disable=SC1091 | ||
| source "$SCRIPT_DIR/program-lib.sh" | ||
|
|
||
| # --- CLI args --- | ||
| DRY_RUN=true | ||
| ORG="kagenti" | ||
| VERBOSE=false | ||
| SHOW_HELP=false | ||
| FORK_OWNER="${FORK_OWNER:-clawgenti}" | ||
| KAGENTI_DIR="${KAGENTI_DIR:-}" | ||
| MAIN_REPO_DIR="${MAIN_REPO_DIR:-${KAGENTI_DIR:-}}" | ||
|
|
||
| while [[ $# -gt 0 ]]; do | ||
| case $1 in | ||
| --dry-run) DRY_RUN=true; shift ;; | ||
| --live) DRY_RUN=false; shift ;; | ||
| --reports-dir) REPORTS_DIR="$2"; shift 2 ;; | ||
| --kagenti-dir) KAGENTI_DIR="$2"; shift 2 ;; | ||
| --org) ORG="$2"; shift 2 ;; | ||
| --fork-owner) FORK_OWNER="$2"; shift 2 ;; | ||
| --main-repo-dir) MAIN_REPO_DIR="$2"; shift 2 ;; | ||
| --kagenti-dir) # deprecated alias, remove after one release | ||
| echo "WARN: --kagenti-dir is deprecated; use --main-repo-dir" >&2 | ||
| MAIN_REPO_DIR="$2"; shift 2 ;; | ||
| --profile) PROFILE_FLAG="$2"; shift 2 ;; | ||
| --org) ORG_FLAG="$2"; shift 2 ;; | ||
| --fork-owner) FORK_OWNER_FLAG="$2"; shift 2 ;; | ||
| --verbose) VERBOSE=true; shift ;; | ||
| --help|-h) SHOW_HELP=true; shift ;; | ||
| *) echo "Unknown option: $1"; exit 1 ;; | ||
|
|
@@ -49,21 +53,42 @@ Usage: | |
| Options: | ||
| --dry-run Generate and preview dashboard (default) | ||
| --live Commit and push to fork, create/update PR | ||
| --reports-dir DIR Base reports directory (default: $REPORTS_DIR or ./reports) | ||
| --kagenti-dir DIR Path to kagenti repo clone (default: $KAGENTI_DIR) | ||
| --org NAME GitHub org (default: kagenti) | ||
| --fork-owner NAME Fork owner for PR workflow (default: clawgenti) | ||
| --verbose Print diagnostic output | ||
| --help, -h Show this help | ||
| --reports-dir DIR Base reports directory (default: $REPORTS_DIR or ./reports) | ||
| --main-repo-dir DIR Path to the report-target repo clone, overriding the | ||
| REPOS_DIR-derived default (default: $MAIN_REPO_DIR) | ||
| --kagenti-dir DIR Deprecated alias for --main-repo-dir | ||
| --profile NAME Org profile to load (config/org.<name>.env; default org.env) | ||
| --org NAME GitHub org (default: from profile, config/org.env) | ||
| --fork-owner NAME Fork owner for PR workflow (default: from profile) | ||
| --verbose Print diagnostic output | ||
| --help, -h Show this help | ||
|
|
||
| Environment: | ||
| REPORTS_DIR Base directory containing link-scan/ and dep-bump/ subdirs | ||
| KAGENTI_DIR Path to the org's main repo clone (for live mode git operations) | ||
| FORK_OWNER Fork owner for cross-fork PRs | ||
| REPORTS_DIR Base directory containing link-scan/ and dep-bump/ subdirs | ||
| MAIN_REPO_DIR Path to the report-target repo clone (live mode git ops); | ||
| overrides the REPOS_DIR-derived default | ||
| FORK_OWNER Fork owner for cross-fork PRs | ||
| HELP | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Resolve org identity (--flag > env > profile > default). Sets ORG, FORK_OWNER, | ||
| # MAIN_REPO, REPOS_DIR, REMAP. | ||
| load_org_profile | ||
|
|
||
| # Report-PR destination. The org main repo's docs/ folder feeds the docs site | ||
| # (rossoctl.dev) and cannot host machine-generated reports, so the standing | ||
| # dashboard PR lands under automation-health/ in the automation repo. A single | ||
| # file, overwritten in place each run: trend tooling reconstructs history by | ||
| # replaying git commit parents, so we store state (not dated snapshots) and | ||
| # avoid the files-vs-diffs-on-Git anti-pattern (rossoctl/automation#44). | ||
| REPORT_TARGET_REPO="$ORG/automation" | ||
| REPORT_TARGET_NAME="${REPORT_TARGET_REPO##*/}" | ||
| REPORT_TARGET_PATH="automation-health/automation-health.md" | ||
| # Clone dir for the report target: honor an explicit --main-repo-dir/MAIN_REPO_DIR | ||
| # override, else derive from REPOS_DIR. | ||
| REPORT_TARGET_DIR="${MAIN_REPO_DIR:-$REPOS_DIR/$REPORT_TARGET_NAME}" | ||
|
|
||
| # --- Validate inputs --- | ||
| if [ -z "${REPORTS_DIR:-}" ]; then | ||
| if [ -d "./reports" ]; then | ||
|
|
@@ -418,7 +443,7 @@ $COVERAGE_TABLE | |
| $CRON_TABLE | ||
|
|
||
| --- | ||
| *Generated by Kagenti Automation Health Dashboard. Do not edit manually.* | ||
| *Generated by Rossoctl Automation Health Dashboard. Do not edit manually.* | ||
| DASHBOARD_EOF | ||
|
|
||
| echo "Dashboard generated ($TMPDIR/automation-health.md)" | ||
|
|
@@ -433,28 +458,28 @@ if [ "$DRY_RUN" = true ]; then | |
| echo "---" | ||
| cat "$TMPDIR/automation-health.md" | ||
| echo "---" | ||
| echo "[DRY RUN] Would push docs/automation-health.md to fork and create/update PR" | ||
| echo "[DRY RUN] Would push $REPORT_TARGET_PATH to fork and create/update PR against $REPORT_TARGET_REPO" | ||
| else | ||
| if [ -z "$KAGENTI_DIR" ]; then | ||
| echo "ERROR: KAGENTI_DIR is not set (required for live mode)." | ||
| echo "Export it to the path of the kagenti/kagenti repo clone:" | ||
| echo " export KAGENTI_DIR=~/kagenti/kagenti" | ||
| if [ -z "$REPORT_TARGET_DIR" ]; then | ||
| echo "ERROR: report target clone dir is not set (required for live mode)." | ||
| echo "Export MAIN_REPO_DIR or set REPOS_DIR so $REPORT_TARGET_REPO can be found:" | ||
| echo " export MAIN_REPO_DIR=$REPOS_DIR/$REPORT_TARGET_NAME" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. L86 sets this now, so this appears to be dead code
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this guard is still valid against cases where neither There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not quite understanding. From the way L86 forms variables, I don't think it can derive empty especially with the L81 fallback, and a garbage case would not fall into this branch anyway with the emptiness guard (L459)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right, and my earlier reply was off. |
||
| exit 1 | ||
| fi | ||
|
|
||
| if [ ! -d "$KAGENTI_DIR/.git" ]; then | ||
| echo "ERROR: $KAGENTI_DIR does not appear to be a git repository." | ||
| if [ ! -d "$REPORT_TARGET_DIR/.git" ]; then | ||
| echo "ERROR: $REPORT_TARGET_DIR does not appear to be a git repository." | ||
| exit 1 | ||
| fi | ||
|
|
||
| FORK_REMOTE="$FORK_OWNER" | ||
| DASHBOARD_BRANCH="automation/health-dashboard" | ||
|
|
||
| cd "$KAGENTI_DIR" | ||
| cd "$REPORT_TARGET_DIR" | ||
|
|
||
| # Ensure fork remote exists | ||
| if ! git remote get-url "$FORK_REMOTE" &>/dev/null; then | ||
| git remote add "$FORK_REMOTE" "https://github.com/$FORK_OWNER/$ORG.git" | ||
| git remote add "$FORK_REMOTE" "https://github.com/$FORK_OWNER/${REPORT_TARGET_NAME}.git" | ||
| fi | ||
|
|
||
| # Fetch fork's branch if it exists, otherwise create from main | ||
|
|
@@ -466,19 +491,19 @@ else | |
| || git checkout -B "$DASHBOARD_BRANCH" | ||
| fi | ||
|
|
||
| mkdir -p docs | ||
| cp "$TMPDIR/automation-health.md" docs/automation-health.md | ||
| git add docs/automation-health.md | ||
| mkdir -p "$(dirname "$REPORT_TARGET_PATH")" | ||
| cp "$TMPDIR/automation-health.md" "$REPORT_TARGET_PATH" | ||
| git add "$REPORT_TARGET_PATH" | ||
| git commit -s -m "docs: Update automation health dashboard ($SCAN_TIME_ET)" 2>/dev/null || echo "No changes to commit" | ||
| git push "$FORK_REMOTE" "$DASHBOARD_BRANCH" 2>/dev/null || echo "WARN: Failed to push dashboard to fork" | ||
|
|
||
| # Create or update standing cross-fork PR | ||
| existing_pr=$(gh api "repos/$ORG/$ORG/pulls?head=$FORK_OWNER:$DASHBOARD_BRANCH&state=open" \ | ||
| existing_pr=$(gh api "repos/$REPORT_TARGET_REPO/pulls?head=$FORK_OWNER:$DASHBOARD_BRANCH&state=open" \ | ||
| --jq '.[0].number' 2>/dev/null || echo "") | ||
|
|
||
| pr_body="## Summary | ||
|
|
||
| Auto-updated by Kagenti Automation Health Dashboard. This PR is continuously updated with each generation. Merge when convenient. | ||
| Auto-updated by Rossoctl Automation Health Dashboard. This PR is continuously updated with each generation. Merge when convenient. | ||
|
|
||
| | Metric | Value | | ||
| |--------|-------| | ||
|
|
@@ -489,15 +514,19 @@ Auto-updated by Kagenti Automation Health Dashboard. This PR is continuously upd | |
|
|
||
| ## Related issue(s) | ||
|
|
||
| - kagenti/kagenti#1260" | ||
| - $MAIN_REPO#1260 | ||
|
|
||
| ## Automation program | ||
|
|
||
| Generated by the [Rossoctl Automation Health Dashboard](https://github.com/$SOURCE_REPO/blob/main/standing-orders/health-dashboard.md)." | ||
|
|
||
| if [ -z "$existing_pr" ] || [ "$existing_pr" = "null" ]; then | ||
| gh pr create --repo "$ORG/$ORG" \ | ||
| gh pr create --repo "$REPORT_TARGET_REPO" \ | ||
| --head "$FORK_OWNER:$DASHBOARD_BRANCH" --base main \ | ||
| --title "docs: Automation health dashboard (auto-updated)" \ | ||
| --body "$pr_body" 2>/dev/null || echo "WARN: Failed to create dashboard PR" | ||
| else | ||
| gh pr edit "$existing_pr" --repo "$ORG/$ORG" --body "$pr_body" 2>/dev/null || true | ||
| gh pr edit "$existing_pr" --repo "$REPORT_TARGET_REPO" --body "$pr_body" 2>/dev/null || true | ||
| fi | ||
|
|
||
| echo "Dashboard committed and pushed" | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
MAIN_REPO_DIRis seeded from${KAGENTI_DIR:-}as a silent migration alias. IfKAGENTI_DIRis still set in the environment from an old deployment, it will silently win over the profile-derived default, masking the newREPOS_DIR/automationpath. A deprecation warning here would match the explicit one added for--kagenti-dirat line 185: