#!/usr/bin/env bash # Sync the shared OIDC client module to both thin apps, and re-pin them. # # ops-docs/scripts/sync-oidc-module.sh # # The canonical module is scripts/shared/oidc_client.py in THIS repo. The two # consumer repos (member-dashboard, admin-panel) ship BYTE-IDENTICAL copies at # app/oidc.py so their login never depends on another app being up. Editing a # copy by hand is a dead end: this script overwrites it, and the repo's # tests/test_oidc_sync.py goes red on any drift from the pinned revision. # # What this does: # 1. copies the canonical module over both repos' app/oidc.py # 2. regenerates each repo's tests/test_oidc_sync.py with the CURRENT # canonical sha256 (the pin CI checks, since CI has no ops-docs checkout) # 3. py_compiles every touched file # 4. runs check-oidc-sync.py as the gate — a red check leaves the working # tree dirty so nothing can be silently committed half-synced # # After it passes: commit all three repos (ops-docs + both apps). set -euo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" REPOS="$(dirname "$(dirname "$HERE")")" # ops-docs/scripts -> ops-docs -> ~/repos CANONICAL="$HERE/shared/oidc_client.py" [ -f "$CANONICAL" ] || { echo "canonical module missing: $CANONICAL" >&2; exit 1; } SHA="$(sha256sum "$CANONICAL" | cut -d' ' -f1)" echo "canonical sha256: $SHA" gen_pin_test() { # local repo="$1" configure="$2" local dir="$REPOS/$repo" mkdir -p "$dir/tests" cat > "$dir/tests/test_oidc_sync.py" < $repo/app/oidc.py" python3 -m py_compile "$REPOS/$repo/app/oidc.py" "$REPOS/$repo/tests/test_oidc_sync.py" done echo "py_compile: OK (both copies + both pin tests)" python3 "$HERE/check-oidc-sync.py"