ops/dossiers-ngi: edition tree bar, 10min tip-skip rebuild, cleanup
This commit is contained in:
parent
e35205b6cd
commit
737d37a76d
22 changed files with 1458 additions and 173 deletions
|
|
@ -1,88 +1,109 @@
|
|||
# dossiers-ngi — cascade landing + hourly branch-status
|
||||
# dossiers-ngi — dynamic edition bar + 10‑min rebuild
|
||||
|
||||
SoT for the blank cascade landing on **dossiers.ngi.hacktivism.ch**
|
||||
(path roots only; no dossiers.2 / dossiers.3 ownership here).
|
||||
SoT for the sticky edition bar on **dossiers.ngi.hacktivism.ch**. Live freezes
|
||||
sit under `editions/<slug>/` on koopa; cookie `tdpd_edition` selects the build.
|
||||
The bar renders a **semi-graphic parent→children tree** from
|
||||
`/branch-status.json` (all `origin/*` tips, not a hard-coded ladder).
|
||||
|
||||
| Path | Role |
|
||||
|------|------|
|
||||
| `sites/dossiers.ngi.hacktivism.ch/` | Landing HTML (EN, ASCII ladder) |
|
||||
| `scripts/dossiers-ngi/branch-status-hourly.py` | Read tips from tdpd checkout → `branch-status.json` |
|
||||
| `configs/systemd/user/dossiers-ngi-branch-status.{timer,service}` | Hourly oneshot on koopa |
|
||||
| `sites/…/_cascade/` | Sticky bar shell + JS tree renderer |
|
||||
| `editions/` on koopa www | Full freezes switched by the bar |
|
||||
| `sites/…/cascade/` | Legacy tip stubs (optional) |
|
||||
| `scripts/dossiers-ngi/branch-status-hourly.py` | Fetch remotes → tree JSON → on-demand rebuild |
|
||||
| `scripts/dossiers-ngi/smoke-branch-tree.sh` | Temp-branch smoke (creates/deletes local origin only) |
|
||||
| `configs/systemd/user/dossiers-ngi-branch-status.{timer,service}` | Every **10 min** oneshot on koopa (`flock` against overlap) |
|
||||
|
||||
## Env
|
||||
|
||||
| Var | Default | Meaning |
|
||||
|-----|---------|---------|
|
||||
| `TDPD_ROOT` | `$HOME/git/src/ngi/tech-dossier-project-data` | tech-dossier-project-data checkout for tip SHAs |
|
||||
| `OUT` | `sites/dossiers.ngi.hacktivism.ch/branch-status.json` under kal | write path for JSON (live www on koopa) |
|
||||
| `ADMIN_LOG` | (script derives from `__file__`) | koopa-admin-log root |
|
||||
| `TDPD_ROOT` | `$HOME/git/src/ngi/tech-dossier-project-data` | tdpd git checkout (may be git-dir only) |
|
||||
| `TDPD_VENV` | `(TDPD_ROOT)/.venv` | Frozen-Flask venv; symlinked into worktrees |
|
||||
| `OUT` | kal `sites/…/branch-status.json` | write path (live www on koopa) |
|
||||
| `EDITIONS_ROOT` | (none) | `…/editions` — required for `--rebuild` |
|
||||
| `REBUILD` / `--rebuild` | off | rebuild when `.edition-tip` ≠ tip |
|
||||
| `FORCE_REBUILD` / `--force` | off | rebuild every branch (timing) |
|
||||
| `FETCH` / `--no-fetch` | fetch on | `git fetch --prune origin` |
|
||||
| `FREEZE_CMD` | (make/venv freeze) | stub for smoke tests; `{root}` `{branch}` `{slug}` |
|
||||
| `DEFAULT_BRANCH` | `feat/website-views` | behind cookie `flask` |
|
||||
| `HOST` | `https://dossiers.ngi.hacktivism.ch` | public host in JSON |
|
||||
|
||||
On koopa the clone often lives at `%h/src/koopa/koopa-admin-log`; set
|
||||
`TDPD_ROOT` and `OUT` in `~/.config/dossiers-ngi/branch-status.env` when the
|
||||
tdpd path or live www path differs from the laptop defaults.
|
||||
On koopa: `%h/src/koopa/koopa-admin-log` +
|
||||
`~/.config/dossiers-ngi/branch-status.env` for path overrides.
|
||||
NGI clone token lives in **koopa-admin-secrets-enc** (not this tree).
|
||||
|
||||
## Manual run
|
||||
|
||||
```bash
|
||||
# JSON only
|
||||
python3 scripts/dossiers-ngi/branch-status-hourly.py
|
||||
# → sites/dossiers.ngi.hacktivism.ch/branch-status.json
|
||||
|
||||
# rebuild stale freezes + timing block in JSON
|
||||
EDITIONS_ROOT=/var/www/monitoring-sites/dossiers.ngi.hacktivism.ch/editions \
|
||||
python3 scripts/dossiers-ngi/branch-status-hourly.py --rebuild
|
||||
|
||||
# force all branches (wall clock → rebuild_timing)
|
||||
… --rebuild --force
|
||||
```
|
||||
|
||||
`rebuild_timing` fields: `wall_seconds`, `built`, `skipped`, `errors`,
|
||||
`built_seconds_sum`, `built_seconds_max`. Per-branch `rebuild[name].seconds`.
|
||||
|
||||
Per branch in JSON / sticky bar:
|
||||
|
||||
| Field | Meaning |
|
||||
|-------|---------|
|
||||
| `tip` | short SHA |
|
||||
| `tip_time` | committer time of tip (`%cI`) |
|
||||
| `built_at` | when this edition freeze was written |
|
||||
| `build_seconds` | wall time of that freeze |
|
||||
|
||||
Rebuild runs **only when** `.edition-tip` ≠ current tip (timer never forces).
|
||||
Each run also: `git fetch --prune`, `worktree prune`, drop stale
|
||||
`editions/<slug>/` (gone remotes), purge leftover `tdpd-*` tmp dirs.
|
||||
|
||||
## Smoke
|
||||
|
||||
```bash
|
||||
bash scripts/dossiers-ngi/smoke-branch-tree.sh
|
||||
# → SMOKE_OK (temp origin + smoke/temp-sibling deleted)
|
||||
```
|
||||
|
||||
## Deploy landing (Freigabe)
|
||||
|
||||
```text
|
||||
hernani@koopa:/var/www/monitoring-sites/dossiers.ngi.hacktivism.ch/
|
||||
Do **not** `--delete` the whole www root. Sync:
|
||||
|
||||
```bash
|
||||
SITE="$HOME/git/admin-logs/local/koopa-admin-log/sites/dossiers.ngi.hacktivism.ch"
|
||||
WWW=hernani@koopa:/var/www/monitoring-sites/dossiers.ngi.hacktivism.ch
|
||||
rsync -avz --exclude .DS_Store "$SITE/_cascade/" "$WWW/_cascade/"
|
||||
rsync -avz --exclude .DS_Store "$SITE/branch-status.json" "$WWW/branch-status.json"
|
||||
# editions/ from a --rebuild run
|
||||
```
|
||||
|
||||
rsync from `sites/dossiers.ngi.hacktivism.ch/` — Freigabe this session required.
|
||||
Hourly JSON can sit next to the HTML once the timer is installed on koopa
|
||||
(Freigabe for host mutation).
|
||||
|
||||
## Ownership
|
||||
|
||||
Hourly builder belongs in **kal** (this tree). Do **not** put
|
||||
`scripts/branch-status-hourly.py` back into tdpd.
|
||||
|
||||
## Sticky cascade bar
|
||||
|
||||
Stock Caddy `templates` renders `{% include "_cascade/bar.html" . %}` on each
|
||||
HTML page. The include path has no leading slash. The dot passes the request,
|
||||
so `.Req.URL.Path` marks the active link with `class="is-active"` and
|
||||
`aria-current="page"`. Delimiters are `{%` `%}`, so a later `{{ }}` in real
|
||||
dossier HTML stays literal.
|
||||
`bar.js` fetches `/branch-status.json` and draws:
|
||||
|
||||
The bar lists cascade `/` plus the five branch paths. Seeded tips match
|
||||
`branch-status.json`. `/_cascade/bar.js` refreshes `[data-tip]` from that JSON
|
||||
(`cache: no-store`). CSS is `/_cascade/bar.css` (`position: sticky`).
|
||||
```
|
||||
main @ d2fbd79
|
||||
├── feat/sm-content @ …
|
||||
│ └── …
|
||||
└── project_template @ …
|
||||
```
|
||||
|
||||
Enable templates before rsync. A page without the include does not grow the
|
||||
bar. `{%` without the templates directive is shown as raw text.
|
||||
Each name links to `/_cascade/use/<edition>` (cookie + 302 `/`). Caddy map:
|
||||
|
||||
Templates apply is **host-local on koopa** (`~/bin/apply-dossiers-ngi-templates.sh`),
|
||||
not tracked in this repo. It edits `~/koopa-caddy/Caddyfile` only (this host;
|
||||
keeps `header Alt-Svc "clear"` and any `basic_auth`; leaves `.2` / `.3`
|
||||
untouched). Then reload with the usual home→`/etc` helper:
|
||||
```
|
||||
~^[A-Za-z0-9_-]+$ {http.request.cookie.tdpd_edition}
|
||||
```
|
||||
|
||||
so new branches need no Caddy edit — only an `editions/<slug>/` tree.
|
||||
|
||||
```bash
|
||||
bash ~/bin/apply-dossiers-ngi-templates.sh
|
||||
bash ~/bin/apply-dossiers-ngi-edition-switch.sh
|
||||
sudo ~/bin/caddy-apply
|
||||
```
|
||||
|
||||
The stanza body for hand-check / re-seed lives in
|
||||
`scripts/dossiers-ngi/caddy-dossiers-ngi.snippet`.
|
||||
`scripts/caddy/caddy-apply.sh --snippet` leaves an existing block unchanged.
|
||||
Leave `scripts/caddy/apply-goa-wdGet-full-replace.sh` and
|
||||
`scripts/caddy/apply-dossiers-ngi-basicauth.sh` unused. No response-body
|
||||
replace plugin.
|
||||
|
||||
After validate and reload succeed, rsync from the laptop (Freigabe):
|
||||
|
||||
```bash
|
||||
rsync -avz --delete --exclude .DS_Store \
|
||||
"$HOME/git/admin-logs/local/koopa-admin-log/sites/dossiers.ngi.hacktivism.ch/" \
|
||||
hernani@koopa:/var/www/monitoring-sites/dossiers.ngi.hacktivism.ch/
|
||||
```
|
||||
|
||||
`--delete` removes `_cascade/` on the server when the source tree is an older
|
||||
copy. The bar does not finish the dossier site. This section does not install
|
||||
the hourly timer.
|
||||
Stanza SoT: `scripts/dossiers-ngi/caddy-dossiers-ngi.snippet`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue